Files
open-cluster-management/test/framework/manifestwork.go
bot69dude 7447b1d0bd 🐛 fix flaky e2e cleanup and addon conversion test (#1573)
* 🐛 fix flaky e2e cleanup and addon conversion test

Pre-delete ManagedClusterAddOns and wait for ManifestWorks before
ManagedCluster deletion in CleanKlusterletRelatedResources.

Merge CMA status update and v1beta1 conversion verify into one
Eventually loop to avoid race with cmaInstallProgressionController.

Fixes #1402

Signed-off-by: bot69dude <nrithvik19@gmail.com>

* Wait for ManagedClusterAddOn deletion in cleanup helper

DeleteAllManagedClusterAddOnsInCluster now waits until all addons
are removed before proceeding, so ManifestWork drain is not racing
with still-active addon controllers.

Addresses CodeRabbit review on #1573

Signed-off-by: bot69dude <nrithvik19@gmail.com>

* Address review: use single MCA API version and drop nested RetryOnConflict

Eventually already retries; listing both converted API versions is redundant.

Signed-off-by: bot69dude <nrithvik19@gmail.com>

---------

Signed-off-by: bot69dude <nrithvik19@gmail.com>
2026-08-04 01:17:52 +00:00

45 lines
1.2 KiB
Go

package framework
import (
"context"
"fmt"
. "github.com/onsi/gomega"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func (hub *Hub) CleanManifestWorks(clusterName, workName string) error {
err := hub.WorkClient.WorkV1().ManifestWorks(clusterName).Delete(context.Background(), workName, metav1.DeleteOptions{})
if apierrors.IsNotFound(err) {
return nil
}
if err != nil {
return err
}
Eventually(func() bool {
_, err := hub.WorkClient.WorkV1().ManifestWorks(clusterName).Get(context.Background(), workName, metav1.GetOptions{})
return apierrors.IsNotFound(err)
}).Should(BeTrue())
return nil
}
// WaitUntilNoManifestWorks waits until all ManifestWorks are removed from the managed cluster namespace.
func (hub *Hub) WaitUntilNoManifestWorks(clusterName string) {
Eventually(func() error {
works, err := hub.WorkClient.WorkV1().ManifestWorks(clusterName).List(context.Background(), metav1.ListOptions{})
if err != nil {
if apierrors.IsNotFound(err) {
return nil
}
return err
}
if len(works.Items) != 0 {
return fmt.Errorf("expected no manifest works, but got %d", len(works.Items))
}
return nil
}).Should(Succeed())
}