Merge pull request #5989 from chaosi-zju/daily

fix rebalancer auto deleted failed
This commit is contained in:
karmada-bot 2024-12-30 09:32:30 +08:00 committed by GitHub
commit cf5def1e3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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