Skip to content

Commit 8f53300

Browse files
committed
Update extractMessage to exit quicker
When building the subscription condition message, check if the status of the InstallPlan is available before iterating through bundle lookup conditions. Signed-off-by: Alexander Greene <greene.al1991@gmail.com>
1 parent b4a2199 commit 8f53300

File tree

1 file changed

+11
-13
lines changed
  • pkg/controller/operators/catalog/subscription

1 file changed

+11
-13
lines changed

pkg/controller/operators/catalog/subscription/state.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -511,23 +511,21 @@ func (i *installPlanReferencedState) CheckInstallPlanStatus(now *metav1.Time, cl
511511
}
512512

513513
func extractMessage(status *v1alpha1.InstallPlanStatus) string {
514-
str := ""
515-
if len(status.BundleLookups) > 0 {
516-
var b bytes.Buffer
517-
for _, lookup := range status.BundleLookups {
518-
if cond := lookup.GetCondition(v1alpha1.BundleLookupPending); cond.Status != corev1.ConditionUnknown {
519-
b.WriteString(cond.Message)
520-
b.WriteString(".")
521-
}
522-
}
523-
str = b.String()
524-
}
525514
if cond := status.GetCondition(v1alpha1.InstallPlanInstalled); cond.Status != corev1.ConditionUnknown {
526515
if cond.Message != "" {
527-
str = cond.Message
516+
return cond.Message
528517
}
529518
}
530-
return str
519+
520+
var b bytes.Buffer
521+
for _, lookup := range status.BundleLookups {
522+
if cond := lookup.GetCondition(v1alpha1.BundleLookupPending); cond.Status != corev1.ConditionUnknown {
523+
b.WriteString(cond.Message)
524+
b.WriteString(".")
525+
}
526+
}
527+
528+
return b.String()
531529
}
532530

533531
type installPlanKnownState struct {

0 commit comments

Comments
 (0)