Skip to content

Commit d8bed00

Browse files
committed
Clear (existing) error cond from Subscription, once error resolved (#3166)
The func `removeSubsCond` takes in a list of pointers to Subscription objects, modifies the objects that the pointers point to, but return a new list of those pointers. A [PR](operator-framework/operator-lifecycle-manager#2942) included in the v0.25.0 release [changed the way the output of that function was being used](https://github.com/operator-framework/operator-lifecycle-manager/pull/2942/files#diff-a1760d9b7ac1e93734eea675d8d8938c96a50e995434b163c6f77c91bace9990R1146-R1155) leading to a regression. This PR fixes the `removeSubsCond` function, fixing the regression as a result. Closes #3162 Signed-off-by: Anik Bhattacharjee <[email protected]> Upstream-repository: operator-lifecycle-manager Upstream-commit: 54da66a9996632315827ba37e14823de6405b4d9
1 parent 1a03f4b commit d8bed00

File tree

4 files changed

+67
-34
lines changed

4 files changed

+67
-34
lines changed

Diff for: staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

+5-13
Original file line numberDiff line numberDiff line change
@@ -1153,16 +1153,14 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
11531153
}
11541154

11551155
// Make sure that we no longer indicate unpacking progress
1156-
subs = o.setSubsCond(subs, v1alpha1.SubscriptionCondition{
1157-
Type: v1alpha1.SubscriptionBundleUnpacking,
1158-
Status: corev1.ConditionFalse,
1159-
})
1156+
o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpacking)
11601157

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

11641161
// Remove resolutionfailed condition from subscriptions
11651162
o.removeSubsCond(subs, v1alpha1.SubscriptionResolutionFailed)
1163+
11661164
newSub := true
11671165
for _, updatedSub := range updatedSubs {
11681166
updatedSub.Status.RemoveConditions(v1alpha1.SubscriptionResolutionFailed)
@@ -1439,13 +1437,9 @@ func (o *Operator) setSubsCond(subs []*v1alpha1.Subscription, cond v1alpha1.Subs
14391437
return subList
14401438
}
14411439

1442-
// removeSubsCond will remove the condition to the subscription if it exists
1443-
// Only return the list of updated subscriptions
1444-
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) []*v1alpha1.Subscription {
1445-
var (
1446-
lastUpdated = o.now()
1447-
)
1448-
var subList []*v1alpha1.Subscription
1440+
// removeSubsCond removes the given condition from all of the subscriptions in the input
1441+
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) {
1442+
lastUpdated := o.now()
14491443
for _, sub := range subs {
14501444
cond := sub.Status.GetCondition(condType)
14511445
// if status is ConditionUnknown, the condition doesn't exist. Just skip
@@ -1454,9 +1448,7 @@ func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alph
14541448
}
14551449
sub.Status.LastUpdated = lastUpdated
14561450
sub.Status.RemoveConditions(condType)
1457-
subList = append(subList, sub)
14581451
}
1459-
return subList
14601452
}
14611453

14621454
func (o *Operator) updateSubscriptionStatuses(subs []*v1alpha1.Subscription) ([]*v1alpha1.Subscription, error) {

Diff for: staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator_test.go

+56-7
Original file line numberDiff line numberDiff line change
@@ -1253,13 +1253,6 @@ func TestSyncResolvingNamespace(t *testing.T) {
12531253
Status: v1alpha1.SubscriptionStatus{
12541254
CurrentCSV: "",
12551255
State: "",
1256-
Conditions: []v1alpha1.SubscriptionCondition{
1257-
{
1258-
Type: v1alpha1.SubscriptionBundleUnpacking,
1259-
Status: corev1.ConditionFalse,
1260-
},
1261-
},
1262-
LastUpdated: now,
12631256
},
12641257
},
12651258
},
@@ -1391,6 +1384,62 @@ func TestSyncResolvingNamespace(t *testing.T) {
13911384
},
13921385
wantErr: fmt.Errorf("some error"),
13931386
},
1387+
{
1388+
name: "HadErrorShouldClearError",
1389+
fields: fields{
1390+
clientOptions: []clientfake.Option{clientfake.WithSelfLinks(t)},
1391+
existingOLMObjs: []runtime.Object{
1392+
&v1alpha1.Subscription{
1393+
TypeMeta: metav1.TypeMeta{
1394+
Kind: v1alpha1.SubscriptionKind,
1395+
APIVersion: v1alpha1.SchemeGroupVersion.String(),
1396+
},
1397+
ObjectMeta: metav1.ObjectMeta{
1398+
Name: "sub",
1399+
Namespace: testNamespace,
1400+
},
1401+
Spec: &v1alpha1.SubscriptionSpec{
1402+
CatalogSource: "src",
1403+
CatalogSourceNamespace: testNamespace,
1404+
},
1405+
Status: v1alpha1.SubscriptionStatus{
1406+
InstalledCSV: "sub-csv",
1407+
State: "AtLatestKnown",
1408+
Conditions: []v1alpha1.SubscriptionCondition{
1409+
{
1410+
Type: v1alpha1.SubscriptionResolutionFailed,
1411+
Reason: "ConstraintsNotSatisfiable",
1412+
Message: "constraints not satisfiable: no operators found from catalog src in namespace testNamespace referenced by subscrition sub, subscription sub exists",
1413+
Status: corev1.ConditionTrue,
1414+
},
1415+
},
1416+
},
1417+
},
1418+
},
1419+
resolveErr: nil,
1420+
},
1421+
wantSubscriptions: []*v1alpha1.Subscription{
1422+
{
1423+
TypeMeta: metav1.TypeMeta{
1424+
Kind: v1alpha1.SubscriptionKind,
1425+
APIVersion: v1alpha1.SchemeGroupVersion.String(),
1426+
},
1427+
ObjectMeta: metav1.ObjectMeta{
1428+
Name: "sub",
1429+
Namespace: testNamespace,
1430+
},
1431+
Spec: &v1alpha1.SubscriptionSpec{
1432+
CatalogSource: "src",
1433+
CatalogSourceNamespace: testNamespace,
1434+
},
1435+
Status: v1alpha1.SubscriptionStatus{
1436+
InstalledCSV: "sub-csv",
1437+
State: "AtLatestKnown",
1438+
LastUpdated: now,
1439+
},
1440+
},
1441+
},
1442+
},
13941443
}
13951444
for _, tt := range tests {
13961445
t.Run(tt.name, func(t *testing.T) {

Diff for: staging/operator-lifecycle-manager/test/e2e/subscription_e2e_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,7 @@ var _ = Describe("Subscription", func() {
24522452
},
24532453
5*time.Minute,
24542454
interval,
2455-
).Should(Equal(corev1.ConditionFalse))
2455+
).Should(Equal(corev1.ConditionUnknown))
24562456

24572457
By("verifying that the subscription is not reporting unpacking errors")
24582458
Eventually(

Diff for: vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

+5-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)