From 078d3e691c10dc86968846e2b0416be92930c247 Mon Sep 17 00:00:00 2001 From: chaosi-zju Date: Sat, 28 Dec 2024 11:18:24 +0800 Subject: [PATCH] fix rebalancer auto deleted failed Signed-off-by: chaosi-zju --- .../workloadrebalancer/workloadrebalancer_controller.go | 2 +- test/e2e/workloadrebalancer_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/controllers/workloadrebalancer/workloadrebalancer_controller.go b/pkg/controllers/workloadrebalancer/workloadrebalancer_controller.go index 0c6653c3c27e..a8ef240e56db 100644 --- a/pkg/controllers/workloadrebalancer/workloadrebalancer_controller.go +++ b/pkg/controllers/workloadrebalancer/workloadrebalancer_controller.go @@ -90,7 +90,7 @@ func (c *RebalancerController) Reconcile(ctx context.Context, req controllerrunt return controllerruntime.Result{}, err } - if rebalancer.Status.FinishTime == nil { + if newStatus.FinishTime == nil { // should never reach here. klog.Errorf("finishTime shouldn't be nil, current status: %+v", rebalancer.Status) return controllerruntime.Result{}, nil diff --git a/test/e2e/workloadrebalancer_test.go b/test/e2e/workloadrebalancer_test.go index 4ddc322ae149..97fa94b9fc43 100644 --- a/test/e2e/workloadrebalancer_test.go +++ b/test/e2e/workloadrebalancer_test.go @@ -193,6 +193,12 @@ var _ = framework.SerialDescribe("workload rebalancer testing", func() { framework.WaitRebalancerDisappear(karmadaClient, rebalancerName) }) }) + + ginkgo.It("create rebalancer with ttl and verify it can auto clean", func() { + rebalancer.Spec.TTLSecondsAfterFinished = ptr.To[int32](5) + framework.CreateWorkloadRebalancer(karmadaClient, rebalancer) + framework.WaitRebalancerDisappear(karmadaClient, rebalancerName) + }) }) // 2. static weight scheduling