mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
adjust base and max delay for appliedmanifestwork deletion (#1120)
Signed-off-by: Wei Liu <liuweixa@redhat.com>
This commit is contained in:
@@ -190,7 +190,7 @@ func DeleteAppliedResources(
|
||||
Namespace(resource.Namespace).
|
||||
Get(ctx, resource.Name, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
klog.V(2).Infof("Resource %v with key %s/%s is removed Successfully", gvr, resource.Namespace, resource.Name)
|
||||
klog.Infof("Resource %v with key %s/%s is removed Successfully", gvr, resource.Namespace, resource.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ type AppliedManifestWorkFinalizeController struct {
|
||||
patcher patcher.Patcher[*workapiv1.AppliedManifestWork, workapiv1.AppliedManifestWorkSpec, workapiv1.AppliedManifestWorkStatus]
|
||||
appliedManifestWorkLister worklister.AppliedManifestWorkLister
|
||||
spokeDynamicClient dynamic.Interface
|
||||
rateLimiter workqueue.RateLimiter
|
||||
rateLimiter workqueue.TypedRateLimiter[string]
|
||||
}
|
||||
|
||||
func NewAppliedManifestWorkFinalizeController(
|
||||
@@ -47,7 +47,8 @@ func NewAppliedManifestWorkFinalizeController(
|
||||
appliedManifestWorkClient),
|
||||
appliedManifestWorkLister: appliedManifestWorkInformer.Lister(),
|
||||
spokeDynamicClient: spokeDynamicClient,
|
||||
rateLimiter: workqueue.NewItemExponentialFailureRateLimiter(5*time.Millisecond, 1000*time.Second),
|
||||
// After 11 retries (approximately 1 mins), the delay reaches the maximum of 60 seconds.
|
||||
rateLimiter: workqueue.NewTypedItemExponentialFailureRateLimiter[string](50*time.Millisecond, 60*time.Second),
|
||||
}
|
||||
|
||||
return factory.New().
|
||||
@@ -110,7 +111,7 @@ func (m *AppliedManifestWorkFinalizeController) syncAppliedManifestWork(ctx cont
|
||||
|
||||
// requeue the work until all applied resources are deleted and finalized if the appliedmanifestwork itself is not updated
|
||||
if len(resourcesPendingFinalization) != 0 {
|
||||
klog.V(4).Infof("%d resources pending deletions", len(resourcesPendingFinalization))
|
||||
klog.V(4).Infof("%d resources pending deletions in %s", len(resourcesPendingFinalization), appliedManifestWork.Name)
|
||||
controllerContext.Queue().AddAfter(appliedManifestWork.Name, m.rateLimiter.When(appliedManifestWork.Name))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestFinalize(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "requeue work when deleting resources are still visiable",
|
||||
name: "requeue work when deleting resources are still visible",
|
||||
terminated: true,
|
||||
existingFinalizers: []string{workapiv1.AppliedManifestWorkFinalizer},
|
||||
existingResources: []runtime.Object{
|
||||
@@ -191,7 +191,7 @@ func TestFinalize(t *testing.T) {
|
||||
*workapiv1.AppliedManifestWork, workapiv1.AppliedManifestWorkSpec, workapiv1.AppliedManifestWorkStatus](
|
||||
fakeClient.WorkV1().AppliedManifestWorks()),
|
||||
spokeDynamicClient: fakeDynamicClient,
|
||||
rateLimiter: workqueue.NewItemExponentialFailureRateLimiter(0, 1*time.Second),
|
||||
rateLimiter: workqueue.NewTypedItemExponentialFailureRateLimiter[string](0, 1*time.Second),
|
||||
}
|
||||
|
||||
controllerContext := testingcommon.NewFakeSyncContext(t, testingWork.Name)
|
||||
|
||||
Reference in New Issue
Block a user