Skip to content

Commit 8432e24

Browse files
committed
Bugzilla 1744245: Subscription should not point to deleted ip
Delete and recreate of a subscription object without any delay causes operator install to fail. How to reproduce: 1. Create a CatalogSource object, wait for it to become healthy. 2. Create a Subscription that refers to the CatalogSource above. 3. Wait for the operator to install successfully. 4. Update the CatalogSource 5. Wait for the updated CatalogSource to become healthy. 6. Delete the Subscription object ( created above ). 7. Recreate the Subscription object ( no time delay between delete and create ). Delete and Create can be done one after another, there is no need to make them concurrent. Solution: - The InstallPlan object(s) are listed using a lister which may return a deleted InstallPlan object. Use a non-cached client to query list of InstallPlan object(s) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1744245
1 parent 0953728 commit 8432e24

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
extinf "k8s.io/apiextensions-apiserver/pkg/client/informers/externalversions"
2020
k8serrors "k8s.io/apimachinery/pkg/api/errors"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
"k8s.io/apimachinery/pkg/labels"
2322
"k8s.io/apimachinery/pkg/runtime/schema"
2423
utilclock "k8s.io/apimachinery/pkg/util/clock"
2524
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -915,7 +914,7 @@ func (o *Operator) ensureInstallPlan(logger *logrus.Entry, namespace string, sub
915914
}
916915

917916
// Check if any existing installplans are creating the same resources
918-
installPlans, err := o.lister.OperatorsV1alpha1().InstallPlanLister().InstallPlans(namespace).List(labels.Everything())
917+
installPlans, err := o.listInstallPlans(namespace)
919918
if err != nil {
920919
return nil, err
921920
}
@@ -1563,6 +1562,20 @@ func (o *Operator) listSubscriptions(namespace string) (subs []*v1alpha1.Subscri
15631562
return
15641563
}
15651564

1565+
func (o *Operator) listInstallPlans(namespace string) (ips []*v1alpha1.InstallPlan, err error) {
1566+
list, err := o.client.OperatorsV1alpha1().InstallPlans(namespace).List(metav1.ListOptions{})
1567+
if err != nil {
1568+
return
1569+
}
1570+
1571+
ips = make([]*v1alpha1.InstallPlan, 0)
1572+
for i := range list.Items {
1573+
ips = append(ips, &list.Items[i])
1574+
}
1575+
1576+
return
1577+
}
1578+
15661579
// competingCRDOwnersExist returns true if there exists a CSV that owns at least one of the given CSVs owned CRDs (that's not the given CSV)
15671580
func competingCRDOwnersExist(namespace string, csv *v1alpha1.ClusterServiceVersion, existingOwners map[string][]string) (bool, error) {
15681581
// Attempt to find a pre-existing owner in the namespace for any owned crd

0 commit comments

Comments
 (0)