Skip to content

Commit 51df3a4

Browse files
Merge pull request #430 from kstrenkova/fix-logger-and-move-failure-case
Fix logger and move failure case
2 parents a3a13af + f771884 commit 51df3a4

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

internal/controller/common.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
ctrl "sigs.k8s.io/controller-runtime"
3232
"sigs.k8s.io/controller-runtime/pkg/client"
3333
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
34+
"sigs.k8s.io/controller-runtime/pkg/log"
3435
)
3536

3637
const (
@@ -489,8 +490,8 @@ func (r *Reconciler) EnsureLogsPVCExists(
489490
}
490491

491492
// GetLogger returns the logger instance
492-
func (r *Reconciler) GetLogger() logr.Logger {
493-
return r.Log
493+
func (r *Reconciler) GetLogger(ctx context.Context) logr.Logger {
494+
return log.FromContext(ctx)
494495
}
495496

496497
// GetScheme returns the runtime scheme
@@ -555,7 +556,7 @@ func (r *Reconciler) AcquireLock(
555556

556557
// ReleaseLock releases the lock for the given instance
557558
func (r *Reconciler) ReleaseLock(ctx context.Context, instance client.Object) (bool, error) {
558-
Log := r.GetLogger()
559+
Log := r.GetLogger(ctx)
559560

560561
cm, err := r.GetLockInfo(ctx, instance)
561562
if err != nil && k8s_errors.IsNotFound(err) {

internal/controller/common_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ func CommonReconcile[T TestResource](
180180
}
181181

182182
nextAction, workflowStepIndex, err := r.NextAction(ctx, instance, workflowLength)
183+
if nextAction == Failure {
184+
return ctrl.Result{}, err
185+
}
183186

184187
// Apply workflow step overrides to the base spec
185188
if config.SupportsWorkflow && workflowStepIndex < workflowLength {
@@ -200,9 +203,6 @@ func CommonReconcile[T TestResource](
200203
}
201204

202205
switch nextAction {
203-
case Failure:
204-
return ctrl.Result{}, err
205-
206206
case Wait:
207207
Log.Info(InfoWaitingOnPod)
208208
return ctrl.Result{RequeueAfter: RequeueAfterValue}, nil

0 commit comments

Comments
 (0)