Skip to content

Commit 47aae56

Browse files
committed
pkg/cvo/sync_worker: Log precondition handling
To make it easier to debug precondition failures like [1]. [1]: https://bugzilla.redhat.com/show_bug.cgi?id=1827166
1 parent 2c4931d commit 47aae56

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

pkg/cvo/sync_worker.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,11 @@ func (w *SyncWorker) syncOnce(ctx context.Context, work *SyncWork, maxWorkers in
512512
payloadUpdate.LoadedAt = time.Now()
513513

514514
// need to make sure the payload is only set when the preconditions have been successful
515-
if !info.Local && len(w.preconditions) > 0 {
515+
if len(w.preconditions) == 0 {
516+
klog.V(4).Info("No preconditions configured.")
517+
} else if info.Local {
518+
klog.V(4).Info("Skipping preconditions for a local operator image payload.")
519+
} else {
516520
reporter.Report(SyncWorkerStatus{
517521
Generation: work.Generation,
518522
Step: "PreconditionChecks",
@@ -521,17 +525,21 @@ func (w *SyncWorker) syncOnce(ctx context.Context, work *SyncWork, maxWorkers in
521525
Actual: update,
522526
Verified: info.Verified,
523527
})
524-
if err := precondition.Summarize(w.preconditions.RunAll(ctx, precondition.ReleaseContext{DesiredVersion: payloadUpdate.ReleaseVersion})); err != nil && !update.Force {
525-
reporter.Report(SyncWorkerStatus{
526-
Generation: work.Generation,
527-
Failure: err,
528-
Step: "PreconditionChecks",
529-
Initial: work.State.Initializing(),
530-
Reconciling: work.State.Reconciling(),
531-
Actual: update,
532-
Verified: info.Verified,
533-
})
534-
return err
528+
if err := precondition.Summarize(w.preconditions.RunAll(ctx, precondition.ReleaseContext{DesiredVersion: payloadUpdate.ReleaseVersion})); err != nil {
529+
if update.Force {
530+
klog.V(4).Infof("Forcing past precondition failures: %s", err)
531+
} else {
532+
reporter.Report(SyncWorkerStatus{
533+
Generation: work.Generation,
534+
Failure: err,
535+
Step: "PreconditionChecks",
536+
Initial: work.State.Initializing(),
537+
Reconciling: work.State.Reconciling(),
538+
Actual: update,
539+
Verified: info.Verified,
540+
})
541+
return err
542+
}
535543
}
536544
}
537545

0 commit comments

Comments
 (0)