Skip to content

Clear (existing) error cond from Subscription, once error resolved #3166

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

Merged
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
18 changes: 5 additions & 13 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1393,16 +1393,14 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
}

// Make sure that we no longer indicate unpacking progress
subs = o.setSubsCond(subs, v1alpha1.SubscriptionCondition{
Type: v1alpha1.SubscriptionBundleUnpacking,
Status: corev1.ConditionFalse,
})
o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpacking)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to keep the condition, I think alternative fix will be something like this:

Suggested change
o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpacking)
o.setSubsCond(subs, v1alpha1.SubscriptionCondition{
Type: v1alpha1.SubscriptionBundleUnpacking,
Status: corev1.ConditionFalse,
})

Because setSubsCond returns a new slice of pointers containing updated subs only (similar to old implementation of removeSubsCond).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing condition can potentially break clients, but given the fact:

  1. It is relatively recent change
  2. And not consistent with other conditions

I think it might be ok to remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My vote would be to remove it. Reasons I say that are:

  • When I asked around I wasn't able to get a "a user asked for it and hence it was added in there" answer.
  • Which feeds into the doubts about the usefulness of clients needing to know if BundleUnpacking is true or false. As opposed to for example, the usefulness of clients needing to know if ResolutionFailed is true or false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it! :shipit:


// Remove BundleUnpackFailed condition from subscriptions
o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpackFailed)

// Remove resolutionfailed condition from subscriptions
o.removeSubsCond(subs, v1alpha1.SubscriptionResolutionFailed)

newSub := true
for _, updatedSub := range updatedSubs {
updatedSub.Status.RemoveConditions(v1alpha1.SubscriptionResolutionFailed)
Expand Down Expand Up @@ -1679,13 +1677,9 @@ func (o *Operator) setSubsCond(subs []*v1alpha1.Subscription, cond v1alpha1.Subs
return subList
}

// removeSubsCond will remove the condition to the subscription if it exists
// Only return the list of updated subscriptions
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) []*v1alpha1.Subscription {
var (
lastUpdated = o.now()
)
var subList []*v1alpha1.Subscription
// removeSubsCond removes the given condition from all of the subscriptions in the input
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) {
lastUpdated := o.now()
for _, sub := range subs {
cond := sub.Status.GetCondition(condType)
// if status is ConditionUnknown, the condition doesn't exist. Just skip
Expand All @@ -1694,9 +1688,7 @@ func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alph
}
sub.Status.LastUpdated = lastUpdated
sub.Status.RemoveConditions(condType)
subList = append(subList, sub)
}
return subList
}

func (o *Operator) updateSubscriptionStatuses(subs []*v1alpha1.Subscription) ([]*v1alpha1.Subscription, error) {
Expand Down
63 changes: 56 additions & 7 deletions pkg/controller/operators/catalog/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,13 +1261,6 @@ func TestSyncResolvingNamespace(t *testing.T) {
Status: v1alpha1.SubscriptionStatus{
CurrentCSV: "",
State: "",
Conditions: []v1alpha1.SubscriptionCondition{
{
Type: v1alpha1.SubscriptionBundleUnpacking,
Status: corev1.ConditionFalse,
},
},
LastUpdated: now,
},
},
},
Expand Down Expand Up @@ -1399,6 +1392,62 @@ func TestSyncResolvingNamespace(t *testing.T) {
},
wantErr: fmt.Errorf("some error"),
},
{
name: "HadErrorShouldClearError",
fields: fields{
clientOptions: []clientfake.Option{clientfake.WithSelfLinks(t)},
existingOLMObjs: []runtime.Object{
&v1alpha1.Subscription{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.SubscriptionKind,
APIVersion: v1alpha1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "sub",
Namespace: testNamespace,
},
Spec: &v1alpha1.SubscriptionSpec{
CatalogSource: "src",
CatalogSourceNamespace: testNamespace,
},
Status: v1alpha1.SubscriptionStatus{
InstalledCSV: "sub-csv",
State: "AtLatestKnown",
Conditions: []v1alpha1.SubscriptionCondition{
{
Type: v1alpha1.SubscriptionResolutionFailed,
Reason: "ConstraintsNotSatisfiable",
Message: "constraints not satisfiable: no operators found from catalog src in namespace testNamespace referenced by subscrition sub, subscription sub exists",
Status: corev1.ConditionTrue,
},
},
},
},
},
resolveErr: nil,
},
wantSubscriptions: []*v1alpha1.Subscription{
{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.SubscriptionKind,
APIVersion: v1alpha1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "sub",
Namespace: testNamespace,
},
Spec: &v1alpha1.SubscriptionSpec{
CatalogSource: "src",
CatalogSourceNamespace: testNamespace,
},
Status: v1alpha1.SubscriptionStatus{
InstalledCSV: "sub-csv",
State: "AtLatestKnown",
LastUpdated: now,
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/subscription_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@ var _ = Describe("Subscription", func() {
},
5*time.Minute,
interval,
).Should(Equal(corev1.ConditionFalse))
).Should(Equal(corev1.ConditionUnknown))

By("verifying that the subscription is not reporting unpacking errors")
Eventually(
Expand Down