Skip to content

Commit 5729f6d

Browse files
status: Report a percentage when performing the initial sync
During both initial cluster init and upgrade it is valuable to show the user how far we have gotten. Use the fraction reported by status to show an approximate percentage of our progress through the payload. During reconcilation, we show nothing.
1 parent 4c2d5e0 commit 5729f6d

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

pkg/cvo/cvo_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,10 @@ func TestOperator_sync(t *testing.T) {
879879
},
880880
},
881881
{
882-
name: "after desired update is cancelled, go to reconciling",
882+
name: "after desired update is cancelled, revert to progressing",
883883
syncStatus: &SyncWorkerStatus{
884-
Actual: configv1.Update{Image: "image/image:v4.0.1", Version: "4.0.1"},
884+
Actual: configv1.Update{Image: "image/image:v4.0.1", Version: "4.0.1"},
885+
Fraction: 0.334,
885886
},
886887
optr: Operator{
887888
releaseImage: "image/image:v4.0.1",
@@ -978,7 +979,7 @@ func TestOperator_sync(t *testing.T) {
978979
{Type: configv1.OperatorAvailable, Status: configv1.ConditionFalse},
979980
{Type: configv1.OperatorFailing, Status: configv1.ConditionFalse},
980981
// we correct the message that was incorrect from the previous state
981-
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Message: "Working towards 4.0.1"},
982+
{Type: configv1.OperatorProgressing, Status: configv1.ConditionTrue, Message: "Working towards 4.0.1: 33%"},
982983
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionFalse},
983984
},
984985
},

pkg/cvo/status.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,14 @@ func (optr *Operator) syncStatus(original, config *configv1.ClusterVersion, stat
211211
LastTransitionTime: now,
212212
})
213213
} else {
214-
message := fmt.Sprintf("Working towards %s", version)
215-
if len(validationErrs) > 0 {
214+
var message string
215+
switch {
216+
case len(validationErrs) > 0:
216217
message = fmt.Sprintf("Reconciling %s: the cluster version is invalid", version)
218+
case status.Fraction > 0:
219+
message = fmt.Sprintf("Working towards %s: %.0f%%", version, status.Fraction*100)
220+
default:
221+
message = fmt.Sprintf("Working towards %s", version)
217222
}
218223
resourcemerge.SetOperatorStatusCondition(&config.Status.Conditions, configv1.ClusterOperatorStatusCondition{
219224
Type: configv1.OperatorProgressing,

0 commit comments

Comments
 (0)