Skip to content

Commit

Permalink
components, logger: use one function for ctx creation
Browse files Browse the repository at this point in the history
Move both logger and component creation to one function.

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
  • Loading branch information
ykaliuta committed Oct 18, 2024
1 parent 2d3efe2 commit 1ef9266
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(ctx context.Context
}
}
// Reconcile component
componentLogger := newComponentLogger(log, componentName)
componentCtx := logf.IntoContext(ctx, componentLogger)
componentCtx := newComponentContext(ctx, log, componentName)
err := component.ReconcileComponent(componentCtx, r.Client, instance, r.DataScienceCluster.DSCISpec, platform, installedComponentValue)

// TODO: replace this hack with a full refactor of component status in the future
Expand Down Expand Up @@ -364,8 +363,8 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(ctx context.Context
return instance, nil
}

func newComponentLogger(logger logr.Logger, componentName string) logr.Logger {
return logger.WithName(componentName).WithValues("component", componentName)
func newComponentContext(ctx context.Context, log logr.Logger, componentName string) context.Context {
return logf.IntoContext(ctx, log.WithName(componentName).WithValues("component", componentName))
}

func (r *DataScienceClusterReconciler) reportError(err error, instance *dscv1.DataScienceCluster, message string) *dscv1.DataScienceCluster {
Expand Down

0 comments on commit 1ef9266

Please sign in to comment.