Skip to content

OCPBUGS-29192: [release-4.14]: Clear (existing) error cond from Subscription, once error resolved #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1158,16 +1158,14 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
}

// Make sure that we no longer indicate unpacking progress
subs = o.setSubsCond(subs, v1alpha1.SubscriptionCondition{
Type: v1alpha1.SubscriptionBundleUnpacking,
Status: corev1.ConditionFalse,
})
o.removeSubsCond(subs, v1alpha1.SubscriptionBundleUnpacking)

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

// Remove resolutionfailed condition from subscriptions
o.removeSubsCond(subs, v1alpha1.SubscriptionResolutionFailed)

newSub := true
for _, updatedSub := range updatedSubs {
updatedSub.Status.RemoveConditions(v1alpha1.SubscriptionResolutionFailed)
Expand Down Expand Up @@ -1444,13 +1442,9 @@ func (o *Operator) setSubsCond(subs []*v1alpha1.Subscription, cond v1alpha1.Subs
return subList
}

// removeSubsCond will remove the condition to the subscription if it exists
// Only return the list of updated subscriptions
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) []*v1alpha1.Subscription {
var (
lastUpdated = o.now()
)
var subList []*v1alpha1.Subscription
// removeSubsCond removes the given condition from all of the subscriptions in the input
func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.SubscriptionConditionType) {
lastUpdated := o.now()
for _, sub := range subs {
cond := sub.Status.GetCondition(condType)
// if status is ConditionUnknown, the condition doesn't exist. Just skip
Expand All @@ -1459,9 +1453,7 @@ func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alph
}
sub.Status.LastUpdated = lastUpdated
sub.Status.RemoveConditions(condType)
subList = append(subList, sub)
}
return subList
}

func (o *Operator) updateSubscriptionStatuses(subs []*v1alpha1.Subscription) ([]*v1alpha1.Subscription, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1253,13 +1253,6 @@ func TestSyncResolvingNamespace(t *testing.T) {
Status: v1alpha1.SubscriptionStatus{
CurrentCSV: "",
State: "",
Conditions: []v1alpha1.SubscriptionCondition{
{
Type: v1alpha1.SubscriptionBundleUnpacking,
Status: corev1.ConditionFalse,
},
},
LastUpdated: now,
},
},
},
Expand Down Expand Up @@ -1391,6 +1384,62 @@ func TestSyncResolvingNamespace(t *testing.T) {
},
wantErr: fmt.Errorf("some error"),
},
{
name: "HadErrorShouldClearError",
fields: fields{
clientOptions: []clientfake.Option{clientfake.WithSelfLinks(t)},
existingOLMObjs: []runtime.Object{
&v1alpha1.Subscription{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.SubscriptionKind,
APIVersion: v1alpha1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "sub",
Namespace: testNamespace,
},
Spec: &v1alpha1.SubscriptionSpec{
CatalogSource: "src",
CatalogSourceNamespace: testNamespace,
},
Status: v1alpha1.SubscriptionStatus{
InstalledCSV: "sub-csv",
State: "AtLatestKnown",
Conditions: []v1alpha1.SubscriptionCondition{
{
Type: v1alpha1.SubscriptionResolutionFailed,
Reason: "ConstraintsNotSatisfiable",
Message: "constraints not satisfiable: no operators found from catalog src in namespace testNamespace referenced by subscrition sub, subscription sub exists",
Status: corev1.ConditionTrue,
},
},
},
},
},
resolveErr: nil,
},
wantSubscriptions: []*v1alpha1.Subscription{
{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.SubscriptionKind,
APIVersion: v1alpha1.SchemeGroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "sub",
Namespace: testNamespace,
},
Spec: &v1alpha1.SubscriptionSpec{
CatalogSource: "src",
CatalogSourceNamespace: testNamespace,
},
Status: v1alpha1.SubscriptionStatus{
InstalledCSV: "sub-csv",
State: "AtLatestKnown",
LastUpdated: now,
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,7 @@ var _ = Describe("Subscription", func() {
},
5*time.Minute,
interval,
).Should(Equal(corev1.ConditionFalse))
).Should(Equal(corev1.ConditionUnknown))

By("verifying that the subscription is not reporting unpacking errors")
Eventually(
Expand Down Expand Up @@ -2672,7 +2672,7 @@ properties:
if err != nil {
return err
}
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpacking); cond.Status != corev1.ConditionFalse {
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpacking); cond.Status != corev1.ConditionUnknown {
return fmt.Errorf("subscription condition %s has unexpected value %s, expected %s", v1alpha1.SubscriptionBundleUnpacking, cond.Status, corev1.ConditionFalse)
}
if cond := fetched.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed); cond.Status != corev1.ConditionUnknown {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.