Skip to content

Commit

Permalink
Use logger with formatter
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Dye <[email protected]>
  • Loading branch information
andrewwdye committed Jan 19, 2024
1 parent 2866d5a commit d596a2e
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions flyteadmin/dataproxy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ func (s Service) CreateUploadLocation(ctx context.Context, req *service.CreateUp
base32Digest := base32.StdEncoding.EncodeToString(req.ContentMd5)
base64Digest := base64.StdEncoding.EncodeToString(req.ContentMd5)
if hexDigest != metadata.Etag() && base32Digest != metadata.Etag() && base64Digest != metadata.Etag() {
logger.Debug(ctx, "File already exists at location [%v] but hashes do not match", knownLocation)
logger.Debugf(ctx, "File already exists at location [%v] but hashes do not match", knownLocation)

Check warning on line 84 in flyteadmin/dataproxy/service.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/dataproxy/service.go#L84

Added line #L84 was not covered by tests
return nil, errors.NewFlyteAdminErrorf(codes.AlreadyExists, "file already exists at location [%v], specify a matching hash if you wish to rewrite", knownLocation)
}
logger.Debug(ctx, "File already exists at location [%v] but allowing rewrite", knownLocation)
logger.Debugf(ctx, "File already exists at location [%v] but allowing rewrite", knownLocation)
}
}

Expand Down
6 changes: 3 additions & 3 deletions flyteadmin/scheduler/executor/executor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (w *executor) Execute(ctx context.Context, scheduledTime time.Time, s model
}, scheduledTime)

if err != nil {
logger.Error(ctx, "failed to generate execution identifier for schedule %+v due to %v", s, err)
logger.Errorf(ctx, "failed to generate execution identifier for schedule %+v due to %v", s, err)

Check warning on line 65 in flyteadmin/scheduler/executor/executor_impl.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/scheduler/executor/executor_impl.go#L65

Added line #L65 was not covered by tests
return err
}

Expand Down Expand Up @@ -107,7 +107,7 @@ func (w *executor) Execute(ctx context.Context, scheduledTime time.Time, s model
return false
}
w.metrics.FailedExecutionCounter.Inc()
logger.Error(ctx, "failed to create execution create request %+v due to %v", executionRequest, err)
logger.Errorf(ctx, "failed to create execution create request %+v due to %v", executionRequest, err)

Check warning on line 110 in flyteadmin/scheduler/executor/executor_impl.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/scheduler/executor/executor_impl.go#L110

Added line #L110 was not covered by tests
// TODO: Handle the case when admin launch plan state is archived but the schedule is active.
// After this bug is fixed in admin https://github.com/flyteorg/flyte/issues/1354
return true
Expand All @@ -118,7 +118,7 @@ func (w *executor) Execute(ctx context.Context, scheduledTime time.Time, s model
},
)
if err != nil && status.Code(err) != codes.AlreadyExists {
logger.Error(ctx, "failed to create execution create request %+v due to %v after all retries", executionRequest, err)
logger.Errorf(ctx, "failed to create execution create request %+v due to %v after all retries", executionRequest, err)

Check warning on line 121 in flyteadmin/scheduler/executor/executor_impl.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/scheduler/executor/executor_impl.go#L121

Added line #L121 was not covered by tests
return err
}
w.metrics.SuccessfulExecutionCounter.Inc()
Expand Down
2 changes: 1 addition & 1 deletion flytecopilot/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func init() {
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
err := flag.CommandLine.Parse([]string{})
if err != nil {
logger.Error(context.TODO(), "Error in initializing: %v", err)
logger.Errorf(context.TODO(), "Error in initializing: %v", err)
os.Exit(-1)
}
labeled.SetMetricKeys(contextutils.ProjectKey, contextutils.DomainKey, contextutils.WorkflowIDKey, contextutils.TaskIDKey)
Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/pluginmachinery/ioutils/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func ConstructCheckpointPath(store storage.ReferenceConstructor, rawOutputPrefix
func constructPath(store storage.ReferenceConstructor, base storage.DataReference, suffix string) storage.DataReference {
res, err := store.ConstructReference(context.Background(), base, suffix)
if err != nil {
logger.Error(context.Background(), "Failed to construct path. Base[%v] Error: %v", base, err)
logger.Errorf(context.Background(), "Failed to construct path. Base[%v] Error: %v", base, err)

Check warning on line 46 in flyteplugins/go/tasks/pluginmachinery/ioutils/paths.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/pluginmachinery/ioutils/paths.go#L46

Added line #L46 was not covered by tests
}

return res
Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/plugins/array/awsbatch/jobs_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func syncBatches(_ context.Context, client Client, handler EventHandler, batchCh
for _, jobDetail := range response {
job, found := jobIDsMap[*jobDetail.JobId]
if !found {
logger.Warn(ctx, "Received an update for unrequested job id [%v]", jobDetail.JobId)
logger.Warnf(ctx, "Received an update for unrequested job id [%v]", jobDetail.JobId)

Check warning on line 275 in flyteplugins/go/tasks/plugins/array/awsbatch/jobs_store.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/plugins/array/awsbatch/jobs_store.go#L275

Added line #L275 was not covered by tests
continue
}

Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/plugins/array/awsbatch/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func CheckSubTasksState(ctx context.Context, tCtx core.TaskExecutionContext, job

// If job isn't currently being monitored (recovering from a restart?), add it to the sync-cache and return
if job == nil {
logger.Info(ctx, "Job not found in cache, adding it. [%v]", jobName)
logger.Infof(ctx, "Job not found in cache, adding it. [%v]", jobName)

_, err = jobStore.GetOrCreate(jobName, &Job{
ID: *currentState.ExternalJobID,
Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/plugins/webapi/athena/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (p Plugin) Delete(ctx context.Context, tCtx webapi.DeleteContext) error {
return err
}

logger.Info(ctx, "Deleted query execution [%v]", resp)
logger.Infof(ctx, "Deleted query execution [%v]", resp)

Check warning on line 131 in flyteplugins/go/tasks/plugins/webapi/athena/plugin.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/plugins/webapi/athena/plugin.go#L131

Added line #L131 was not covered by tests

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/plugins/webapi/bigquery/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (p Plugin) Delete(ctx context.Context, taskCtx webapi.DeleteContext) error
return err
}

logger.Info(ctx, "Cancelled job [%s]", formatJobReference(resourceMeta.JobReference))
logger.Infof(ctx, "Cancelled job [%s]", formatJobReference(resourceMeta.JobReference))

Check warning on line 259 in flyteplugins/go/tasks/plugins/webapi/bigquery/plugin.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/plugins/webapi/bigquery/plugin.go#L259

Added line #L259 was not covered by tests

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/plugins/webapi/databricks/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (p Plugin) Delete(ctx context.Context, taskCtx webapi.DeleteContext) error
return err
}
defer resp.Body.Close()
logger.Info(ctx, "Deleted query execution [%v]", resp)
logger.Infof(ctx, "Deleted query execution [%v]", resp)

Check warning on line 206 in flyteplugins/go/tasks/plugins/webapi/databricks/plugin.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/plugins/webapi/databricks/plugin.go#L206

Added line #L206 was not covered by tests

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/plugins/webapi/snowflake/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (p Plugin) Delete(ctx context.Context, taskCtx webapi.DeleteContext) error
return err
}
defer resp.Body.Close()
logger.Info(ctx, "Deleted query execution [%v]", resp)
logger.Infof(ctx, "Deleted query execution [%v]", resp)

Check warning on line 182 in flyteplugins/go/tasks/plugins/webapi/snowflake/plugin.go

View check run for this annotation

Codecov / codecov/patch

flyteplugins/go/tasks/plugins/webapi/snowflake/plugin.go#L182

Added line #L182 was not covered by tests

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion flytepropeller/cmd/kubectl-flyte/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func init() {
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
err := flag.CommandLine.Parse([]string{})
if err != nil {
logger.Error(context.TODO(), "Error in initializing: %v", err)
logger.Errorf(context.TODO(), "Error in initializing: %v", err)
os.Exit(-1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion flytepropeller/pkg/controller/nodes/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ func (c *nodeExecutor) attemptRecovery(ctx context.Context, nCtx interfaces.Node
state.PreviousNodeExecutionCheckpointURI = storage.DataReference(metadata.TaskNodeMetadata.CheckpointUri)
err = nCtx.NodeStateWriter().PutTaskNodeState(state)
if err != nil {
logger.Warn(ctx, "failed to save recovered checkpoint uri for [%+v]: [%+v]",
logger.Warnf(ctx, "failed to save recovered checkpoint uri for [%+v]: [%+v]",

Check warning on line 586 in flytepropeller/pkg/controller/nodes/executor.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/executor.go#L586

Added line #L586 was not covered by tests
nCtx.NodeExecutionMetadata().GetNodeExecutionID(), err)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (a *adminLaunchPlanExecutor) Launch(ctx context.Context, launchCtx LaunchCo

_, err = a.cache.GetOrCreate(executionID.String(), executionCacheItem{WorkflowExecutionIdentifier: *executionID})
if err != nil {
logger.Info(ctx, "Failed to add ExecID [%v] to auto refresh cache", executionID)
logger.Infof(ctx, "Failed to add ExecID [%v] to auto refresh cache", executionID)

Check warning on line 151 in flytepropeller/pkg/controller/nodes/subworkflow/launchplan/admin.go

View check run for this annotation

Codecov / codecov/patch

flytepropeller/pkg/controller/nodes/subworkflow/launchplan/admin.go#L151

Added line #L151 was not covered by tests
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (b *SimpleBackOffBlocker) reset() {
}

func (b *SimpleBackOffBlocker) backOff(ctx context.Context) time.Duration {
logger.Debug(ctx, "BackOff params [BackOffBaseSecond: %v] [BackOffExponent: %v] [MaxBackOffDuration: %v]",
logger.Debugf(ctx, "BackOff params [BackOffBaseSecond: %v] [BackOffExponent: %v] [MaxBackOffDuration: %v]",
b.BackOffBaseSecond, b.BackOffExponent, b.MaxBackOffDuration)

backOffDuration := time.Duration(time.Second.Nanoseconds() * int64(math.Pow(float64(b.BackOffBaseSecond),
Expand Down
2 changes: 1 addition & 1 deletion flytestdlib/random/weighted_random_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func NewWeightedRandom(ctx context.Context, entries []Entry) (WeightedRandomList
currentTotal += 1.0 / float32(numberOfEntries)
} else if e.Weight == 0 {
// Entries which have zero weight are ignored
logger.Debug(ctx, "ignoring entry due to empty weight %v", e)
logger.Debugf(ctx, "ignoring entry due to empty weight %v", e)
continue
}

Expand Down
2 changes: 1 addition & 1 deletion flytestdlib/storage/protobuf_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s DefaultProtobufStore) ReadProtobuf(ctx context.Context, reference DataRe
defer func() {
err = rc.Close()
if err != nil {
logger.Warn(ctx, "Failed to close reference [%v]. Error: %v", reference, err)
logger.Warnf(ctx, "Failed to close reference [%v]. Error: %v", reference, err)

Check warning on line 49 in flytestdlib/storage/protobuf_store.go

View check run for this annotation

Codecov / codecov/patch

flytestdlib/storage/protobuf_store.go#L49

Added line #L49 was not covered by tests
}
}()

Expand Down

0 comments on commit d596a2e

Please sign in to comment.