mirror of
https://github.com/stakater/Reloader.git
synced 2026-05-06 00:36:39 +00:00
Shutdown on leader election loss
This commit is contained in:
@@ -30,7 +30,6 @@ type Controller struct {
|
||||
namespace string
|
||||
ignoredNamespaces util.List
|
||||
collectors metrics.Collectors
|
||||
isLeader bool
|
||||
}
|
||||
|
||||
// controllerInitialized flag determines whether controlled is being initialized
|
||||
@@ -58,7 +57,7 @@ func NewController(
|
||||
c.informer = informer
|
||||
c.queue = queue
|
||||
c.collectors = collectors
|
||||
c.isLeader = true
|
||||
logrus.Infof("created controller for: %s", resource)
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
@@ -143,7 +142,7 @@ func (c *Controller) processNextItem() bool {
|
||||
defer c.queue.Done(resourceHandler)
|
||||
|
||||
// Invoke the method containing the business logic
|
||||
err := resourceHandler.(handler.ResourceHandler).Handle(c.isLeader)
|
||||
err := resourceHandler.(handler.ResourceHandler).Handle()
|
||||
// Handle the error if something went wrong during the execution of the business logic
|
||||
c.handleErr(err, resourceHandler)
|
||||
return true
|
||||
@@ -174,8 +173,3 @@ func (c *Controller) handleErr(err error, key interface{}) {
|
||||
runtime.HandleError(err)
|
||||
logrus.Infof("Dropping the key %q out of the queue: %v", key, err)
|
||||
}
|
||||
|
||||
func (c *Controller) SetLeader(isLeader bool) {
|
||||
c.isLeader = isLeader
|
||||
logrus.Info("controller active")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user