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:
commit
03d1bc23d7
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue