Skip to content

Commit

Permalink
Use logger with formatter (#4747)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewwdye authored Jan 20, 2024
1 parent a62743d commit 6f5c471
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 23 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)
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)
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)
// 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)
return err
}
w.metrics.SuccessfulExecutionCounter.Inc()
Expand Down
4 changes: 2 additions & 2 deletions flyteadmin/tests/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func truncateAllTablesForTestingOnly() {
ctx := context.Background()
db, err := repositories.GetDB(ctx, getDbConfig(), getLoggerConfig())
if err != nil {
logger.Fatal(ctx, "Failed to open DB connection due to %v", err)
logger.Fatalf(ctx, "Failed to open DB connection due to %v", err)
}
sqlDB, err := db.DB()
if err != nil {
Expand Down Expand Up @@ -110,7 +110,7 @@ func populateWorkflowExecutionForTestingOnly(project, domain, name string) {
db, err := repositories.GetDB(context.Background(), getDbConfig(), getLoggerConfig())
ctx := context.Background()
if err != nil {
logger.Fatal(ctx, "Failed to open DB connection due to %v", err)
logger.Fatalf(ctx, "Failed to open DB connection due to %v", err)
}
sqlDB, err := db.DB()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion flyteadmin/tests/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func populateWorkflowExecutionsForTestingOnly() {
db, err := repositories.GetDB(context.Background(), getDbConfig(), getLoggerConfig())
ctx := context.Background()
if err != nil {
logger.Fatal(ctx, "Failed to open DB connection due to %v", err)
logger.Fatalf(ctx, "Failed to open DB connection due to %v", err)
}
sqlDB, err := db.DB()
if err != nil {
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 flyteidl/clients/go/admin/pkce/auth_flow_orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (f TokenOrchestrator) FetchTokenFromAuthFlow(ctx context.Context) (*oauth2.

go func() {
if err = server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
logger.Fatal(ctx, "Couldn't start the callback http server on host %v due to %v", redirectURL.Host,
logger.Fatalf(ctx, "Couldn't start the callback http server on host %v due to %v", redirectURL.Host,
err)
}
}()
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)
}

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)
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)

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))

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)

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)

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]",
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)
}

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)
}
}()

Expand Down

0 comments on commit 6f5c471

Please sign in to comment.