Skip to content

Commit 8e6f9eb

Browse files
Merge pull request #686 from anik120/release-4.14
OCPBUGS-29192: [release-4.14]: Clear (existing) error cond from Subscription, once error resolved
2 parents c6e9911 + 79fe501 commit 8e6f9eb

File tree

4 files changed

+68
-35
lines changed

4 files changed

+68
-35
lines changed

Diff for: 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) {

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

+2-2
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(
@@ -2672,7 +2672,7 @@ properties:
26722672
if err != nil {
26732673
return err
26742674
}
2675-
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpacking); cond.Status != corev1.ConditionFalse {
2675+
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpacking); cond.Status != corev1.ConditionUnknown {
26762676
return fmt.Errorf("subscription condition %s has unexpected value %s, expected %s", v1alpha1.SubscriptionBundleUnpacking, cond.Status, corev1.ConditionFalse)
26772677
}
26782678
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed); cond.Status != corev1.ConditionUnknown {

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)