Merge pull request #3475 from chaunceyjiang/graceful

fix: graceful-eviction still works after an unexpected restart of karmada-controller-manager
This commit is contained in:
karmada-bot 2023-05-04 10:31:19 +08:00 committed by GitHub
commit 03d1bc23d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -84,7 +84,15 @@ func (c *CRBGracefulEvictionController) syncBinding(binding *workv1alpha2.Cluste
// SetupWithManager creates a controller and register to controller manager.
func (c *CRBGracefulEvictionController) SetupWithManager(mgr controllerruntime.Manager) error {
clusterResourceBindingPredicateFn := predicate.Funcs{
CreateFunc: func(createEvent event.CreateEvent) bool { return false },
CreateFunc: func(createEvent event.CreateEvent) bool {
newObj := createEvent.Object.(*workv1alpha2.ClusterResourceBinding)
if len(newObj.Spec.GracefulEvictionTasks) == 0 {
return false
}
// When the current component is restarted and there are still tasks in the
// GracefulEvictionTasks queue, we need to continue the procession.
return newObj.Status.SchedulerObservedGeneration == newObj.Generation
},
UpdateFunc: func(updateEvent event.UpdateEvent) bool {
newObj := updateEvent.ObjectNew.(*workv1alpha2.ClusterResourceBinding)

View File

@ -84,7 +84,15 @@ func (c *RBGracefulEvictionController) syncBinding(binding *workv1alpha2.Resourc
// SetupWithManager creates a controller and register to controller manager.
func (c *RBGracefulEvictionController) SetupWithManager(mgr controllerruntime.Manager) error {
resourceBindingPredicateFn := predicate.Funcs{
CreateFunc: func(createEvent event.CreateEvent) bool { return false },
CreateFunc: func(createEvent event.CreateEvent) bool {
newObj := createEvent.Object.(*workv1alpha2.ResourceBinding)
if len(newObj.Spec.GracefulEvictionTasks) == 0 {
return false
}
// When the current component is restarted and there are still tasks in the
// GracefulEvictionTasks queue, we need to continue the procession.
return newObj.Status.SchedulerObservedGeneration == newObj.Generation
},
UpdateFunc: func(updateEvent event.UpdateEvent) bool {
newObj := updateEvent.ObjectNew.(*workv1alpha2.ResourceBinding)