@@ -19,6 +19,7 @@ import (
19
19
corev1 "k8s.io/api/core/v1"
20
20
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
21
21
apierrors "k8s.io/apimachinery/pkg/api/errors"
22
+ k8serrors "k8s.io/apimachinery/pkg/api/errors"
22
23
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23
24
"k8s.io/apimachinery/pkg/labels"
24
25
"k8s.io/apimachinery/pkg/util/wait"
@@ -644,9 +645,6 @@ var _ = Describe("Catalog", func() {
644
645
crc := newCRClient ()
645
646
source , err := crc .OperatorsV1alpha1 ().CatalogSources (source .GetNamespace ()).Create (context .TODO (), source , metav1.CreateOptions {})
646
647
require .NoError (GinkgoT (), err )
647
- defer func () {
648
- require .NoError (GinkgoT (), crc .OperatorsV1alpha1 ().CatalogSources (source .GetNamespace ()).Delete (context .TODO (), source .GetName (), metav1.DeleteOptions {}))
649
- }()
650
648
651
649
// Wait for a new registry pod to be created
652
650
c := newKubeClient ()
@@ -663,8 +661,7 @@ var _ = Describe("Catalog", func() {
663
661
664
662
// Create a Subscription for package
665
663
subscriptionName := genName ("sub-" )
666
- cleanupSubscription := createSubscriptionForCatalog (crc , source .GetNamespace (), subscriptionName , source .GetName (), packageName , channelName , "" , v1alpha1 .ApprovalAutomatic )
667
- defer cleanupSubscription ()
664
+ _ = createSubscriptionForCatalog (crc , source .GetNamespace (), subscriptionName , source .GetName (), packageName , channelName , "" , v1alpha1 .ApprovalAutomatic )
668
665
669
666
// Wait for the Subscription to succeed
670
667
subscription , err := fetchSubscription (crc , testNamespace , subscriptionName , subscriptionStateAtLatestChecker )
@@ -676,7 +673,25 @@ var _ = Describe("Catalog", func() {
676
673
require .NoError (GinkgoT (), err )
677
674
678
675
// Delete the registry pod
679
- require .NoError (GinkgoT (), c .KubernetesInterface ().CoreV1 ().Pods (testNamespace ).Delete (context .TODO (), name , metav1.DeleteOptions {}))
676
+ Eventually (func () error {
677
+ backgroundDeletion := metav1 .DeletePropagationBackground
678
+ err = c .KubernetesInterface ().CoreV1 ().Pods (testNamespace ).DeleteCollection (context .TODO (), metav1.DeleteOptions {PropagationPolicy : & backgroundDeletion }, metav1.ListOptions {LabelSelector : selector .String ()})
679
+ if err != nil {
680
+ if k8serrors .IsNotFound (err ) {
681
+ return nil
682
+ }
683
+ return err
684
+ }
685
+ return nil
686
+ }).Should (Succeed ())
687
+
688
+ Eventually (func () error {
689
+ _ , err := c .KubernetesInterface ().CoreV1 ().Pods (testNamespace ).Get (context .TODO (), name , metav1.GetOptions {})
690
+ if k8serrors .IsNotFound (err ) {
691
+ return nil
692
+ }
693
+ return err
694
+ }).Should (Succeed ())
680
695
681
696
// Wait for a new registry pod to be created
682
697
notUID := func (pods * corev1.PodList ) bool {
0 commit comments