Skip to content

Commit

Permalink
Merge pull request #5993 from deefreak/automated-cherry-pick-of-#5989…
Browse files Browse the repository at this point in the history
…-upstream-release-1.10

Automated cherry pick of #5989: fix rebalancer auto deleted failed
  • Loading branch information
karmada-bot authored Dec 30, 2024
2 parents 8fc0191 + 062313d commit 151d882
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,12 @@ func (c *RebalancerController) Reconcile(ctx context.Context, req controllerrunt
return controllerruntime.Result{}, err
}

if rebalancer.Status.FinishTime == nil {
// should never reach here.
klog.Errorf("finishTime shouldn't be nil, current status: %+v", rebalancer.Status)
return controllerruntime.Result{}, nil
}

// 3. when all workloads finished, judge whether the rebalancer needs cleanup.
rebalancer.Status = *newStatus
if rebalancer.Spec.TTLSecondsAfterFinished != nil {
if rebalancer.Status.FinishTime == nil {
return controllerruntime.Result{}, fmt.Errorf("finish time should not be nil")
}
remainingTTL := timeLeft(rebalancer)
if remainingTTL > 0 {
return controllerruntime.Result{RequeueAfter: remainingTTL}, nil
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/workloadrebalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 151d882

Please sign in to comment.