Skip to content

Commit d8beb68

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

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

pkg/controller/operators/catalog/operator.go

+6
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,12 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
12821282
return updateErr
12831283
}
12841284
return err
1285+
} else {
1286+
// remove any potential error message from a previous resolution attempt,
1287+
// since the current resolution was successful
1288+
o.updateSubscriptionStatuses(
1289+
o.removeSubsCond(subs, v1alpha1.SubscriptionResolutionFailed),
1290+
)
12851291
}
12861292

12871293
// Attempt to unpack bundles before installing

pkg/controller/operators/catalog/operator_test.go

+67
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,73 @@ func TestSyncResolvingNamespace(t *testing.T) {
13991399
},
14001400
wantErr: fmt.Errorf("some error"),
14011401
},
1402+
{
1403+
name: "HadErrorShouldClearError",
1404+
fields: fields{
1405+
clientOptions: []clientfake.Option{clientfake.WithSelfLinks(t)},
1406+
existingOLMObjs: []runtime.Object{
1407+
&v1alpha1.Subscription{
1408+
TypeMeta: metav1.TypeMeta{
1409+
Kind: v1alpha1.SubscriptionKind,
1410+
APIVersion: v1alpha1.SchemeGroupVersion.String(),
1411+
},
1412+
ObjectMeta: metav1.ObjectMeta{
1413+
Name: "sub",
1414+
Namespace: testNamespace,
1415+
},
1416+
Spec: &v1alpha1.SubscriptionSpec{
1417+
CatalogSource: "src",
1418+
CatalogSourceNamespace: testNamespace,
1419+
},
1420+
Status: v1alpha1.SubscriptionStatus{
1421+
InstalledCSV: "sub-csv",
1422+
State: "AtLatestKnown",
1423+
Conditions: []v1alpha1.SubscriptionCondition{
1424+
{
1425+
Type: v1alpha1.SubscriptionBundleUnpacking,
1426+
Status: corev1.ConditionFalse,
1427+
},
1428+
{
1429+
Type: v1alpha1.SubscriptionResolutionFailed,
1430+
Reason: "ConstraintsNotSatisfiable",
1431+
Message: "constraints not satisfiable: no operators found from catalog src in namespace testNamespace referenced by subscrition sub, subscription sub exists",
1432+
Status: corev1.ConditionTrue,
1433+
},
1434+
},
1435+
LastUpdated: now,
1436+
},
1437+
},
1438+
},
1439+
resolveErr: nil,
1440+
},
1441+
wantSubscriptions: []*v1alpha1.Subscription{
1442+
{
1443+
TypeMeta: metav1.TypeMeta{
1444+
Kind: v1alpha1.SubscriptionKind,
1445+
APIVersion: v1alpha1.SchemeGroupVersion.String(),
1446+
},
1447+
ObjectMeta: metav1.ObjectMeta{
1448+
Name: "sub",
1449+
Namespace: testNamespace,
1450+
},
1451+
Spec: &v1alpha1.SubscriptionSpec{
1452+
CatalogSource: "src",
1453+
CatalogSourceNamespace: testNamespace,
1454+
},
1455+
Status: v1alpha1.SubscriptionStatus{
1456+
InstalledCSV: "sub-csv",
1457+
State: "AtLatestKnown",
1458+
LastUpdated: now,
1459+
Conditions: []v1alpha1.SubscriptionCondition{
1460+
{
1461+
Type: v1alpha1.SubscriptionBundleUnpacking,
1462+
Status: corev1.ConditionFalse,
1463+
},
1464+
},
1465+
},
1466+
},
1467+
},
1468+
},
14021469
}
14031470
for _, tt := range tests {
14041471
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)