Skip to content

Commit 01cef29

Browse files
committed
Move slowCOUpdatePrefix Reason instead of Message
1 parent ba7f4f7 commit 01cef29

File tree

1 file changed

+56
-49
lines changed

1 file changed

+56
-49
lines changed

pkg/cvo/status.go

+56-49
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,13 @@ func updateClusterVersionStatus(cvStatus *configv1.ClusterVersionStatus, status
328328
failingCondition.Message = failingMessage
329329
}
330330
if failure != nil &&
331-
skipFailure &&
332-
(progressReason == "ClusterOperatorUpdating" || progressReason == "ClusterOperatorsUpdating") &&
333-
strings.HasPrefix(progressMessage, slowCOUpdatePrefix) {
334-
progressMessage = strings.TrimPrefix(progressMessage, slowCOUpdatePrefix)
331+
strings.HasPrefix(progressReason, slowCOUpdatePrefix) {
335332
failingCondition.Status = configv1.ConditionUnknown
336333
failingCondition.Reason = "SlowClusterOperator"
337334
failingCondition.Message = progressMessage
338335
}
336+
progressReason = strings.TrimPrefix(progressReason, slowCOUpdatePrefix)
337+
339338
resourcemerge.SetOperatorStatusCondition(&cvStatus.Conditions, failingCondition)
340339

341340
// update progressing
@@ -566,59 +565,67 @@ func convertErrorToProgressing(now time.Time, statusFailure error) (reason strin
566565
case payload.UpdateEffectReport:
567566
return uErr.Reason, uErr.Error(), false
568567
case payload.UpdateEffectNone:
569-
var exceeded []string
570-
names := uErr.Names
571-
if len(names) == 0 {
572-
names = []string{uErr.Name}
573-
}
574-
var machineConfig bool
575-
for _, name := range names {
576-
m := 30 * time.Minute
577-
// It takes longer to upgrade MCO
578-
if name == "machine-config" {
579-
m = 3 * m
580-
}
581-
t := payload.COUpdateStartTimesGet(name)
582-
if (!t.IsZero()) && t.Before(now.Add(-(m))) {
583-
if name == "machine-config" {
584-
machineConfig = true
585-
} else {
586-
exceeded = append(exceeded, name)
587-
}
588-
}
589-
}
590-
// returns true in those slow cases because it is still only a suspicion
591-
if len(exceeded) > 0 && !machineConfig {
592-
return uErr.Reason, fmt.Sprintf("%swaiting on %s over 30 minutes which is longer than expected", slowCOUpdatePrefix, strings.Join(exceeded, ", ")), true
593-
}
594-
if len(exceeded) > 0 && machineConfig {
595-
return uErr.Reason, fmt.Sprintf("%swaiting on %s over 30 minutes and machine-config over 90 minutes which is longer than expected", slowCOUpdatePrefix, strings.Join(exceeded, ", ")), true
596-
}
597-
if len(exceeded) == 0 && machineConfig {
598-
return uErr.Reason, fmt.Sprintf("%swaiting on machine-config over 90 minutes which is longer than expected", slowCOUpdatePrefix), true
599-
}
600-
return uErr.Reason, fmt.Sprintf("waiting on %s", strings.Join(names, ", ")), true
568+
return convertErrorToProgressingForUpdateEffectNone(uErr, now)
601569
case payload.UpdateEffectFail:
602570
return "", "", false
603571
case payload.UpdateEffectFailAfterInterval:
604-
var exceeded []string
605-
threshold := now.Add(-(40 * time.Minute))
606-
names := uErr.Names
607-
if len(names) == 0 {
608-
names = []string{uErr.Name}
609-
}
610-
for _, name := range names {
611-
if payload.COUpdateStartTimesGet(name).Before(threshold) {
572+
return convertErrorToProgressingForUpdateEffectFailAfterInterval(uErr, now)
573+
}
574+
return "", "", false
575+
}
576+
577+
func convertErrorToProgressingForUpdateEffectNone(uErr *payload.UpdateError, now time.Time) (string, string, bool) {
578+
var exceeded []string
579+
names := uErr.Names
580+
if len(names) == 0 {
581+
names = []string{uErr.Name}
582+
}
583+
var machineConfig bool
584+
for _, name := range names {
585+
m := 30 * time.Minute
586+
// It takes longer to upgrade MCO
587+
if name == "machine-config" {
588+
m = 3 * m
589+
}
590+
t := payload.COUpdateStartTimesGet(name)
591+
if (!t.IsZero()) && t.Before(now.Add(-(m))) {
592+
if name == "machine-config" {
593+
machineConfig = true
594+
} else {
612595
exceeded = append(exceeded, name)
613596
}
614597
}
615-
if len(exceeded) > 0 {
616-
return uErr.Reason, fmt.Sprintf("wait has exceeded 40 minutes for these operators: %s", strings.Join(exceeded, ", ")), false
617-
} else {
618-
return uErr.Reason, fmt.Sprintf("waiting up to 40 minutes on %s", uErr.Name), true
598+
}
599+
// returns true in those slow cases because it is still only a suspicion
600+
if len(exceeded) > 0 && !machineConfig {
601+
return slowCOUpdatePrefix + uErr.Reason, fmt.Sprintf("waiting on %s over 30 minutes which is longer than expected", strings.Join(exceeded, ", ")), true
602+
}
603+
if len(exceeded) > 0 && machineConfig {
604+
return slowCOUpdatePrefix + uErr.Reason, fmt.Sprintf("waiting on %s over 30 minutes and machine-config over 90 minutes which is longer than expected", strings.Join(exceeded, ", ")), true
605+
}
606+
if len(exceeded) == 0 && machineConfig {
607+
return slowCOUpdatePrefix + uErr.Reason, "waiting on machine-config over 90 minutes which is longer than expected", true
608+
}
609+
return uErr.Reason, fmt.Sprintf("waiting on %s", strings.Join(names, ", ")), true
610+
}
611+
612+
func convertErrorToProgressingForUpdateEffectFailAfterInterval(uErr *payload.UpdateError, now time.Time) (string, string, bool) {
613+
var exceeded []string
614+
threshold := now.Add(-(40 * time.Minute))
615+
names := uErr.Names
616+
if len(names) == 0 {
617+
names = []string{uErr.Name}
618+
}
619+
for _, name := range names {
620+
if payload.COUpdateStartTimesGet(name).Before(threshold) {
621+
exceeded = append(exceeded, name)
619622
}
620623
}
621-
return "", "", false
624+
if len(exceeded) > 0 {
625+
return uErr.Reason, fmt.Sprintf("wait has exceeded 40 minutes for these operators: %s", strings.Join(exceeded, ", ")), false
626+
} else {
627+
return uErr.Reason, fmt.Sprintf("waiting up to 40 minutes on %s", uErr.Name), true
628+
}
622629
}
623630

624631
// syncFailingStatus handles generic errors in the cluster version. It tries to preserve

0 commit comments

Comments
 (0)