From bfd9e985c2f6ed7b9f45322368034e1320a2bb11 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Tue, 6 Mar 2018 16:25:04 -0800 Subject: [PATCH] Changing %v to %+v for composite structs. Removing a repetitive statement for the Aurora return code. --- monitors.go | 2 +- realis.go | 42 +++++++++++++++++++++--------------------- retry.go | 3 --- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/monitors.go b/monitors.go index 3587f66..c6d8127 100644 --- a/monitors.go +++ b/monitors.go @@ -69,7 +69,7 @@ func (m *Monitor) JobUpdate(updateKey aurora.JobUpdateKey, interval int, timeout // if we encounter an inactive state and it is not at rolled forward, update failed switch status { case aurora.JobUpdateStatus_ROLLED_FORWARD: - m.Client.RealisConfig().infoLogger.Println("Update succeded") + m.Client.RealisConfig().infoLogger.Println("Update succeeded") return true, nil case aurora.JobUpdateStatus_FAILED: m.Client.RealisConfig().infoLogger.Println("Update failed") diff --git a/realis.go b/realis.go index 87ca6e7..0eb893e 100644 --- a/realis.go +++ b/realis.go @@ -470,7 +470,7 @@ func (r *realisClient) GetInstanceIds(key *aurora.JobKey, states map[aurora.Sche Statuses: states, } - r.debugLogger.Printf("GetTasksWithoutConfig sThrift Payload: %v\n", *taskQ) + r.debugLogger.Printf("GetTasksWithoutConfigs Thrift Payload: %+v\n", taskQ) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.GetTasksWithoutConfigs(taskQ) @@ -492,7 +492,7 @@ func (r *realisClient) GetInstanceIds(key *aurora.JobKey, states map[aurora.Sche } func (r *realisClient) GetJobUpdateSummaries(jobUpdateQuery *aurora.JobUpdateQuery) (*aurora.Response, error) { - r.debugLogger.Printf("GetJobUpdateSummaries Thrift Payload: %v\n", *jobUpdateQuery) + r.debugLogger.Printf("GetJobUpdateSummaries Thrift Payload: %+v\n", jobUpdateQuery) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.readonlyClient.GetJobUpdateSummaries(jobUpdateQuery) @@ -526,7 +526,7 @@ func (r *realisClient) GetJobs(role string) (*aurora.Response, *aurora.GetJobsRe // Kill specific instances of a job. func (r *realisClient) KillInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) { - r.debugLogger.Printf("KillTasks Thrift Payload: %v %v\n", *key, instances) + r.debugLogger.Printf("KillTasks Thrift Payload: %+v %v\n", key, instances) instanceIds := make(map[int32]bool) @@ -551,7 +551,7 @@ func (r *realisClient) RealisConfig() *RealisConfig { // Sends a kill message to the scheduler for all active tasks under a job. func (r *realisClient) KillJob(key *aurora.JobKey) (*aurora.Response, error) { - r.debugLogger.Printf("KillTasks Thrift Payload: %v %v\n", *key, nil) + r.debugLogger.Printf("KillTasks Thrift Payload: %+v\n", key) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { // Giving the KillTasks thrift call an empty set tells the Aurora scheduler to kill all active shards @@ -570,7 +570,7 @@ func (r *realisClient) KillJob(key *aurora.JobKey) (*aurora.Response, error) { // Use this API to create ad-hoc jobs. func (r *realisClient) CreateJob(auroraJob Job) (*aurora.Response, error) { - r.debugLogger.Printf("CreateJob Thrift Payload: %v\n", *auroraJob.JobConfig()) + r.debugLogger.Printf("CreateJob Thrift Payload: %+v\n", auroraJob.JobConfig()) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.CreateJob(auroraJob.JobConfig()) @@ -602,7 +602,7 @@ func (r *realisClient) CreateService(auroraJob Job, settings *aurora.JobUpdateSe } func (r *realisClient) ScheduleCronJob(auroraJob Job) (*aurora.Response, error) { - r.debugLogger.Printf("ScheduleCronJob Thrift Payload: %v\n", *auroraJob.JobConfig()) + r.debugLogger.Printf("ScheduleCronJob Thrift Payload: %+v\n", auroraJob.JobConfig()) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.ScheduleCronJob(auroraJob.JobConfig()) @@ -616,7 +616,7 @@ func (r *realisClient) ScheduleCronJob(auroraJob Job) (*aurora.Response, error) func (r *realisClient) DescheduleCronJob(key *aurora.JobKey) (*aurora.Response, error) { - r.debugLogger.Printf("DescheduleCronJob Thrift Payload: %v\n", *key) + r.debugLogger.Printf("DescheduleCronJob Thrift Payload: %+v\n", key) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.DescheduleCronJob(key) @@ -632,7 +632,7 @@ func (r *realisClient) DescheduleCronJob(key *aurora.JobKey) (*aurora.Response, func (r *realisClient) StartCronJob(key *aurora.JobKey) (*aurora.Response, error) { - r.debugLogger.Printf("StartCronJob Thrift Payload: %v\n", *key) + r.debugLogger.Printf("StartCronJob Thrift Payload: %+v\n", key) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.StartCronJob(key) @@ -647,7 +647,7 @@ func (r *realisClient) StartCronJob(key *aurora.JobKey) (*aurora.Response, error // Restarts specific instances specified func (r *realisClient) RestartInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) { - r.debugLogger.Printf("RestartShards Thrift Payload: %v %v\n", *key, instances) + r.debugLogger.Printf("RestartShards Thrift Payload: %+v %v\n", key, instances) instanceIds := make(map[int32]bool) @@ -673,7 +673,7 @@ func (r *realisClient) RestartJob(key *aurora.JobKey) (*aurora.Response, error) return nil, errors.Wrap(err1, "Could not retrieve relevant task instance IDs") } - r.debugLogger.Printf("RestartShards Thrift Payload: %v %v\n", *key, instanceIds) + r.debugLogger.Printf("RestartShards Thrift Payload: %+v %v\n", key, instanceIds) if len(instanceIds) > 0 { resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { @@ -693,7 +693,7 @@ func (r *realisClient) RestartJob(key *aurora.JobKey) (*aurora.Response, error) // Update all tasks under a job configuration. Currently gorealis doesn't support for canary deployments. func (r *realisClient) StartJobUpdate(updateJob *UpdateJob, message string) (*aurora.Response, error) { - r.debugLogger.Printf("StartJobUpdate Thrift Payload: %v %v\n", *updateJob, message) + r.debugLogger.Printf("StartJobUpdate Thrift Payload: %+v %v\n", updateJob, message) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.StartJobUpdate(updateJob.req, message) @@ -708,7 +708,7 @@ func (r *realisClient) StartJobUpdate(updateJob *UpdateJob, message string) (*au // Abort Job Update on Aurora. Requires the updateId which can be obtained on the Aurora web UI. func (r *realisClient) AbortJobUpdate(updateKey aurora.JobUpdateKey, message string) (*aurora.Response, error) { - r.debugLogger.Printf("AbortJobUpdate Thrift Payload: %v %v\n", updateKey, message) + r.debugLogger.Printf("AbortJobUpdate Thrift Payload: %+v %v\n", updateKey, message) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.AbortJobUpdate(&updateKey, message) @@ -723,7 +723,7 @@ func (r *realisClient) AbortJobUpdate(updateKey aurora.JobUpdateKey, message str //Pause Job Update. UpdateID is returned from StartJobUpdate or the Aurora web UI. func (r *realisClient) PauseJobUpdate(updateKey *aurora.JobUpdateKey, message string) (*aurora.Response, error) { - r.debugLogger.Printf("PauseJobUpdate Thrift Payload: %v %v\n", updateKey, message) + r.debugLogger.Printf("PauseJobUpdate Thrift Payload: %+v %v\n", updateKey, message) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.PauseJobUpdate(updateKey, message) @@ -739,7 +739,7 @@ func (r *realisClient) PauseJobUpdate(updateKey *aurora.JobUpdateKey, message st //Resume Paused Job Update. UpdateID is returned from StartJobUpdate or the Aurora web UI. func (r *realisClient) ResumeJobUpdate(updateKey *aurora.JobUpdateKey, message string) (*aurora.Response, error) { - r.debugLogger.Printf("ResumeJobUpdate Thrift Payload: %v %v\n", updateKey, message) + r.debugLogger.Printf("ResumeJobUpdate Thrift Payload: %+v %v\n", updateKey, message) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.ResumeJobUpdate(updateKey, message) @@ -755,7 +755,7 @@ func (r *realisClient) ResumeJobUpdate(updateKey *aurora.JobUpdateKey, message s //Pulse Job Update on Aurora. UpdateID is returned from StartJobUpdate or the Aurora web UI. func (r *realisClient) PulseJobUpdate(updateKey *aurora.JobUpdateKey) (*aurora.Response, error) { - r.debugLogger.Printf("PulseJobUpdate Thrift Payload: %v\n", updateKey) + r.debugLogger.Printf("PulseJobUpdate Thrift Payload: %+v\n", updateKey) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.PulseJobUpdate(updateKey) @@ -772,7 +772,7 @@ func (r *realisClient) PulseJobUpdate(updateKey *aurora.JobUpdateKey) (*aurora.R // instance to scale up. func (r *realisClient) AddInstances(instKey aurora.InstanceKey, count int32) (*aurora.Response, error) { - r.debugLogger.Printf("AddInstances Thrift Payload: %v %v\n", instKey, count) + r.debugLogger.Printf("AddInstances Thrift Payload: %+v %v\n", instKey, count) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.AddInstances(&instKey, count) @@ -810,7 +810,7 @@ func (r *realisClient) RemoveInstances(key *aurora.JobKey, count int32) (*aurora // Get information about task including a fully hydrated task configuration object func (r *realisClient) GetTaskStatus(query *aurora.TaskQuery) (tasks []*aurora.ScheduledTask, e error) { - r.debugLogger.Printf("GetTasksStatus Thrift Payload: %v\n", *query) + r.debugLogger.Printf("GetTasksStatus Thrift Payload: %+v\n", query) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.GetTasksStatus(query) @@ -826,7 +826,7 @@ func (r *realisClient) GetTaskStatus(query *aurora.TaskQuery) (tasks []*aurora.S // Get information about task including without a task configuration object func (r *realisClient) GetTasksWithoutConfigs(query *aurora.TaskQuery) (tasks []*aurora.ScheduledTask, e error) { - r.debugLogger.Printf("GetTasksWithoutConfigs Thrift Payload: %v\n", *query) + r.debugLogger.Printf("GetTasksWithoutConfigs Thrift Payload: %+v\n", query) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.GetTasksWithoutConfigs(query) @@ -854,7 +854,7 @@ func (r *realisClient) FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.Task Statuses: aurora.ACTIVE_STATES, } - r.debugLogger.Printf("GetTasksStatus Thrift Payload: %v\n", *taskQ) + r.debugLogger.Printf("GetTasksStatus Thrift Payload: %+v\n", taskQ) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.GetTasksStatus(taskQ) @@ -880,7 +880,7 @@ func (r *realisClient) FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.Task func (r *realisClient) JobUpdateDetails(updateQuery aurora.JobUpdateQuery) (*aurora.Response, error) { - r.debugLogger.Printf("GetJobUpdateDetails Thrift Payload: %v\n", updateQuery) + r.debugLogger.Printf("GetJobUpdateDetails Thrift Payload: %+v\n", updateQuery) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.GetJobUpdateDetails(&updateQuery) @@ -895,7 +895,7 @@ func (r *realisClient) JobUpdateDetails(updateQuery aurora.JobUpdateQuery) (*aur func (r *realisClient) RollbackJobUpdate(key aurora.JobUpdateKey, message string) (*aurora.Response, error) { - r.debugLogger.Printf("RollbackJobUpdate Thrift Payload: %v %v\n", key, message) + r.debugLogger.Printf("RollbackJobUpdate Thrift Payload: %+v %v\n", key, message) resp, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) { return r.client.RollbackJobUpdate(&key, message) diff --git a/retry.go b/retry.go index 6cb2c69..8b4ec6c 100644 --- a/retry.go +++ b/retry.go @@ -173,9 +173,6 @@ func (r *realisClient) thriftCallWithRetries(thriftCall auroraThriftCall) (*auro return nil, errors.New("Response from aurora is nil") } - // Log response code for debugging - r.debugLogger.Printf("Aurora replied with code: %v\n", resp.GetResponseCode().String()) - // Check Response Code from thrift and make a decision to continue retrying or not. switch responseCode := resp.GetResponseCode(); responseCode {