Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logger with formatter #4747

Merged
merged 2 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
}, 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 @@
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 @@
},
)
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
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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@

_, 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 @@
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
Loading