Skip to content

feat(sub): Include IP failure condition message in sub status condition #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package subscription

import (
"bytes"
"context"
"fmt"

Expand Down Expand Up @@ -452,7 +453,7 @@ func (i *installPlanReferencedState) CheckInstallPlanStatus(now *metav1.Time, cl
if cond.Reason == "" {
cond.Reason = string(phase)
}

cond.Message = extractMessage(status)
cond.Type = v1alpha1.SubscriptionInstallPlanPending
cond.Status = corev1.ConditionTrue
out.Status.SetCondition(cond)
Expand All @@ -472,6 +473,7 @@ func (i *installPlanReferencedState) CheckInstallPlanStatus(now *metav1.Time, cl
}

cond.Type = v1alpha1.SubscriptionInstallPlanFailed
cond.Message = extractMessage(status)
cond.Status = corev1.ConditionTrue
out.Status.SetCondition(cond)

Expand Down Expand Up @@ -508,6 +510,26 @@ func (i *installPlanReferencedState) CheckInstallPlanStatus(now *metav1.Time, cl
return known, nil
}

func extractMessage(status *v1alpha1.InstallPlanStatus) string {
str := ""
if len(status.BundleLookups) > 0 {
var b bytes.Buffer
for _, lookup := range status.BundleLookups {
if cond := lookup.GetCondition(v1alpha1.BundleLookupPending); cond.Status != corev1.ConditionUnknown {
b.WriteString(cond.Message)
b.WriteString(".")
}
}
str = b.String()
}
if cond := status.GetCondition(v1alpha1.InstallPlanInstalled); cond.Status != corev1.ConditionUnknown {
if cond.Message != "" {
str = cond.Message
}
}
return str
}

type installPlanKnownState struct {
InstallPlanReferencedState
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,14 @@ func TestCheckInstallPlanStatus(t *testing.T) {
now: &now,
status: &v1alpha1.InstallPlanStatus{
Phase: v1alpha1.InstallPlanPhaseInstalling,
Conditions: []v1alpha1.InstallPlanCondition{
{
Type: v1alpha1.InstallPlanInstalled,
Message: "no operatorgroup found that is managing this namespace",
Reason: v1alpha1.InstallPlanConditionReason("Installing"),
Status: corev1.ConditionFalse,
},
},
},
},
want: want{
Expand All @@ -1346,7 +1354,7 @@ func TestCheckInstallPlanStatus(t *testing.T) {
},
Status: v1alpha1.SubscriptionStatus{
Conditions: []v1alpha1.SubscriptionCondition{
planPendingCondition(corev1.ConditionTrue, string(v1alpha1.InstallPlanPhaseInstalling), "", &now),
planPendingCondition(corev1.ConditionTrue, string(v1alpha1.InstallPlanPhaseInstalling), "no operatorgroup found that is managing this namespace", &now),
},
LastUpdated: now,
},
Expand Down Expand Up @@ -1535,6 +1543,17 @@ func TestCheckInstallPlanStatus(t *testing.T) {
Reason: v1alpha1.InstallPlanReasonComponentFailed,
},
},
BundleLookups: []v1alpha1.BundleLookup{
{
Conditions: []v1alpha1.BundleLookupCondition{
{
Type: v1alpha1.BundleLookupPending,
Status: corev1.ConditionTrue,
Message: "unpack job not completed: Unpack pod(olm/c5a4) container(pull) is pending. Reason: ImagePullBackOff, Message: Back-off pulling image",
},
},
},
},
},
},
want: want{
Expand All @@ -1545,7 +1564,7 @@ func TestCheckInstallPlanStatus(t *testing.T) {
},
Status: v1alpha1.SubscriptionStatus{
Conditions: []v1alpha1.SubscriptionCondition{
planFailedCondition(corev1.ConditionTrue, string(v1alpha1.InstallPlanReasonComponentFailed), "", &now),
planFailedCondition(corev1.ConditionTrue, string(v1alpha1.InstallPlanReasonComponentFailed), "unpack job not completed: Unpack pod(olm/c5a4) container(pull) is pending. Reason: ImagePullBackOff, Message: Back-off pulling image.", &now),
},
LastUpdated: now,
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.