Skip to content

Commit 2d0e624

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 c6e9911 commit 2d0e624

File tree

4 files changed

+67
-34
lines changed

4 files changed

+67
-34
lines changed

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

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

11601160
// Make sure that we no longer indicate unpacking progress
1161-
subs = o.setSubsCond(subs, v1alpha1.SubscriptionCondition{
1162-
Type: v1alpha1.SubscriptionBundleUnpacking,
1163-
Status: corev1.ConditionFalse,
1164-
})
1161+
o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpacking)
11651162

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

11691166
// Remove resolutionfailed condition from subscriptions
11701167
o.removeSubsCond(subs, v1alpha1.SubscriptionResolutionFailed)
1168+
11711169
newSub := true
11721170
for _, updatedSub := range updatedSubs {
11731171
updatedSub.Status.RemoveConditions(v1alpha1.SubscriptionResolutionFailed)
@@ -1444,13 +1442,9 @@ func (o *Operator) setSubsCond(subs []*v1alpha1.Subscription, cond v1alpha1.Subs
14441442
return subList
14451443
}
14461444

1447-
// removeSubsCond will remove the condition to the subscription if it exists
1448-
// Only return the list of updated subscriptions
1449-
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) []*v1alpha1.Subscription {
1450-
var (
1451-
lastUpdated = o.now()
1452-
)
1453-
var subList []*v1alpha1.Subscription
1445+
// removeSubsCond removes the given condition from all of the subscriptions in the input
1446+
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) {
1447+
lastUpdated := o.now()
14541448
for _, sub := range subs {
14551449
cond := sub.Status.GetCondition(condType)
14561450
// if status is ConditionUnknown, the condition doesn't exist. Just skip
@@ -1459,9 +1453,7 @@ func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alph
14591453
}
14601454
sub.Status.LastUpdated = lastUpdated
14611455
sub.Status.RemoveConditions(condType)
1462-
subList = append(subList, sub)
14631456
}
1464-
return subList
14651457
}
14661458

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

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) {

staging/operator-lifecycle-manager/test/e2e/subscription_e2e_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2456,7 +2456,7 @@ var _ = Describe("Subscription", func() {
24562456
},
24572457
5*time.Minute,
24582458
interval,
2459-
).Should(Equal(corev1.ConditionFalse))
2459+
).Should(Equal(corev1.ConditionUnknown))
24602460

24612461
By("verifying that the subscription is not reporting unpacking errors")
24622462
Eventually(

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)