Skip to content

Commit a4ffc39

Browse files
committed
Clear (existing) error cond from Subscription, once error resolved
Closes #3162 Signed-off-by: Anik Bhattacharjee <[email protected]>
1 parent 1bb6009 commit a4ffc39

File tree

2 files changed

+61
-16
lines changed

2 files changed

+61
-16
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,16 +1393,14 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
13931393
}
13941394

13951395
// Make sure that we no longer indicate unpacking progress
1396-
subs = o.setSubsCond(subs, v1alpha1.SubscriptionCondition{
1397-
Type: v1alpha1.SubscriptionBundleUnpacking,
1398-
Status: corev1.ConditionFalse,
1399-
})
1396+
subs = o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpacking)
14001397

14011398
// Remove BundleUnpackFailed condition from subscriptions
1402-
o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpackFailed)
1399+
subs = o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpackFailed)
14031400

14041401
// Remove resolutionfailed condition from subscriptions
1405-
o.removeSubsCond(subs, v1alpha1.SubscriptionResolutionFailed)
1402+
subs = o.removeSubsCond(subs, v1alpha1.SubscriptionResolutionFailed)
1403+
14061404
newSub := true
14071405
for _, updatedSub := range updatedSubs {
14081406
updatedSub.Status.RemoveConditions(v1alpha1.SubscriptionResolutionFailed)
@@ -1685,7 +1683,6 @@ func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alph
16851683
var (
16861684
lastUpdated = o.now()
16871685
)
1688-
var subList []*v1alpha1.Subscription
16891686
for _, sub := range subs {
16901687
cond := sub.Status.GetCondition(condType)
16911688
// if status is ConditionUnknown, the condition doesn't exist. Just skip
@@ -1694,9 +1691,8 @@ func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alph
16941691
}
16951692
sub.Status.LastUpdated = lastUpdated
16961693
sub.Status.RemoveConditions(condType)
1697-
subList = append(subList, sub)
16981694
}
1699-
return subList
1695+
return subs
17001696
}
17011697

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

pkg/controller/operators/catalog/operator_test.go

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,13 +1261,6 @@ func TestSyncResolvingNamespace(t *testing.T) {
12611261
Status: v1alpha1.SubscriptionStatus{
12621262
CurrentCSV: "",
12631263
State: "",
1264-
Conditions: []v1alpha1.SubscriptionCondition{
1265-
{
1266-
Type: v1alpha1.SubscriptionBundleUnpacking,
1267-
Status: corev1.ConditionFalse,
1268-
},
1269-
},
1270-
LastUpdated: now,
12711264
},
12721265
},
12731266
},
@@ -1399,6 +1392,62 @@ func TestSyncResolvingNamespace(t *testing.T) {
13991392
},
14001393
wantErr: fmt.Errorf("some error"),
14011394
},
1395+
{
1396+
name: "HadErrorShouldClearError",
1397+
fields: fields{
1398+
clientOptions: []clientfake.Option{clientfake.WithSelfLinks(t)},
1399+
existingOLMObjs: []runtime.Object{
1400+
&v1alpha1.Subscription{
1401+
TypeMeta: metav1.TypeMeta{
1402+
Kind: v1alpha1.SubscriptionKind,
1403+
APIVersion: v1alpha1.SchemeGroupVersion.String(),
1404+
},
1405+
ObjectMeta: metav1.ObjectMeta{
1406+
Name: "sub",
1407+
Namespace: testNamespace,
1408+
},
1409+
Spec: &v1alpha1.SubscriptionSpec{
1410+
CatalogSource: "src",
1411+
CatalogSourceNamespace: testNamespace,
1412+
},
1413+
Status: v1alpha1.SubscriptionStatus{
1414+
InstalledCSV: "sub-csv",
1415+
State: "AtLatestKnown",
1416+
Conditions: []v1alpha1.SubscriptionCondition{
1417+
{
1418+
Type: v1alpha1.SubscriptionResolutionFailed,
1419+
Reason: "ConstraintsNotSatisfiable",
1420+
Message: "constraints not satisfiable: no operators found from catalog src in namespace testNamespace referenced by subscrition sub, subscription sub exists",
1421+
Status: corev1.ConditionTrue,
1422+
},
1423+
},
1424+
},
1425+
},
1426+
},
1427+
resolveErr: nil,
1428+
},
1429+
wantSubscriptions: []*v1alpha1.Subscription{
1430+
{
1431+
TypeMeta: metav1.TypeMeta{
1432+
Kind: v1alpha1.SubscriptionKind,
1433+
APIVersion: v1alpha1.SchemeGroupVersion.String(),
1434+
},
1435+
ObjectMeta: metav1.ObjectMeta{
1436+
Name: "sub",
1437+
Namespace: testNamespace,
1438+
},
1439+
Spec: &v1alpha1.SubscriptionSpec{
1440+
CatalogSource: "src",
1441+
CatalogSourceNamespace: testNamespace,
1442+
},
1443+
Status: v1alpha1.SubscriptionStatus{
1444+
InstalledCSV: "sub-csv",
1445+
State: "AtLatestKnown",
1446+
LastUpdated: now,
1447+
},
1448+
},
1449+
},
1450+
},
14021451
}
14031452
for _, tt := range tests {
14041453
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)