Skip to content

Commit c087cfe

Browse files
authored
Merge pull request #5994 from deefreak/automated-cherry-pick-of-#5989-upstream-release-1.11
Automated cherry pick of #5989: fix rebalancer auto deleted failed
2 parents 0d4da5d + 26b5735 commit c087cfe

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: pkg/controllers/workloadrebalancer/workloadrebalancer_controller.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,12 @@ func (c *RebalancerController) Reconcile(ctx context.Context, req controllerrunt
9090
return controllerruntime.Result{}, err
9191
}
9292

93-
if rebalancer.Status.FinishTime == nil {
94-
// should never reach here.
95-
klog.Errorf("finishTime shouldn't be nil, current status: %+v", rebalancer.Status)
96-
return controllerruntime.Result{}, nil
97-
}
98-
9993
// 3. when all workloads finished, judge whether the rebalancer needs cleanup.
10094
rebalancer.Status = *newStatus
10195
if rebalancer.Spec.TTLSecondsAfterFinished != nil {
96+
if rebalancer.Status.FinishTime == nil {
97+
return controllerruntime.Result{}, fmt.Errorf("finish time should not be nil")
98+
}
10299
remainingTTL := timeLeft(rebalancer)
103100
if remainingTTL > 0 {
104101
return controllerruntime.Result{RequeueAfter: remainingTTL}, nil

Diff for: test/e2e/workloadrebalancer_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ var _ = framework.SerialDescribe("workload rebalancer testing", func() {
193193
framework.WaitRebalancerDisappear(karmadaClient, rebalancerName)
194194
})
195195
})
196+
197+
ginkgo.It("create rebalancer with ttl and verify it can auto clean", func() {
198+
rebalancer.Spec.TTLSecondsAfterFinished = ptr.To[int32](5)
199+
framework.CreateWorkloadRebalancer(karmadaClient, rebalancer)
200+
framework.WaitRebalancerDisappear(karmadaClient, rebalancerName)
201+
})
196202
})
197203

198204
// 2. static weight scheduling

0 commit comments

Comments
 (0)