Skip to content

Commit e3c7dd1

Browse files
Merge pull request #360 from wking/precondition-logging
Bug 1827166: pkg/cvo/sync_worker: Log precondition handling
2 parents 2c4931d + 1a511af commit e3c7dd1

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
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

pkg/payload/precondition/clusterversion/upgradeable.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
configv1listers "github.com/openshift/client-go/config/listers/config/v1"
99
apierrors "k8s.io/apimachinery/pkg/api/errors"
1010
"k8s.io/apimachinery/pkg/api/meta"
11+
"k8s.io/klog"
1112

1213
"github.com/openshift/cluster-version-operator/lib/resourcemerge"
1314
precondition "github.com/openshift/cluster-version-operator/pkg/payload/precondition"
@@ -46,12 +47,18 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
4647

4748
// if we are upgradeable==true we can always upgrade
4849
up := resourcemerge.FindOperatorStatusCondition(cv.Status.Conditions, configv1.OperatorUpgradeable)
49-
if up == nil || up.Status != configv1.ConditionFalse {
50+
if up == nil {
51+
klog.V(4).Infof("Precondition %s passed: no Upgradeable condition on ClusterVersion.", pf.Name())
52+
return nil
53+
}
54+
if up.Status != configv1.ConditionFalse {
55+
klog.V(4).Infof("Precondition %s passed: Upgradeable %s since %v: %s: %s", pf.Name(), up.Status, up.LastTransitionTime, up.Reason, up.Message)
5056
return nil
5157
}
5258

5359
// we can always allow the upgrade if there isn't a version already installed
5460
if len(cv.Status.History) == 0 {
61+
klog.V(4).Infof("Precondition %s passed: no release history.", pf.Name())
5562
return nil
5663
}
5764

@@ -60,6 +67,7 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
6067

6168
// if there is no difference in the minor version (4.y.z where 4.y is the same for current and desired), then we can still upgrade
6269
if currentMinor == desiredMinor {
70+
klog.V(4).Infof("Precondition %q passed: minor from the current %s matches minor from the target %s (both %s).", pf.Name(), cv.Status.History[0].Version, releaseContext.DesiredVersion, currentMinor)
6371
return nil
6472
}
6573

0 commit comments

Comments
 (0)