From 40eeb7ac6715a8493bb7aba055e8664d65a4f51d Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Tue, 24 May 2016 14:27:37 -0300 Subject: [PATCH] Remove loadBalancer ip on shutdown --- ingress/controllers/nginx/controller.go | 15 ++++++++------- ingress/controllers/nginx/main.go | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ingress/controllers/nginx/controller.go b/ingress/controllers/nginx/controller.go index 4e4293060d..943dde1bf9 100644 --- a/ingress/controllers/nginx/controller.go +++ b/ingress/controllers/nginx/controller.go @@ -881,13 +881,16 @@ func (lbc *loadBalancerController) Stop() error { // Only try draining the workqueue if we haven't already. if !lbc.shutdown { + lbc.shutdown = true + close(lbc.stopCh) - lbc.removeFromIngress() + ings := lbc.ingLister.Store.List() + glog.Infof("removing IP address %v from ingress rules", lbc.podInfo.NodeIP) + lbc.removeFromIngress(ings) - close(lbc.stopCh) - glog.Infof("shutting down controller queues") - lbc.shutdown = true + glog.Infof("Shutting down controller queues.") lbc.syncQueue.shutdown() + lbc.ingQueue.shutdown() return nil } @@ -898,8 +901,7 @@ func (lbc *loadBalancerController) Stop() error { // removeFromIngress removes the IP address of the node where the Ingres // controller is running before shutdown to avoid incorrect status // information in Ingress rules -func (lbc *loadBalancerController) removeFromIngress() { - ings := lbc.ingLister.Store.List() +func (lbc *loadBalancerController) removeFromIngress(ings []interface{}) { glog.Infof("updating %v Ingress rule/s", len(ings)) for _, cur := range ings { ing := cur.(*extensions.Ingress) @@ -946,5 +948,4 @@ func (lbc *loadBalancerController) Run() { go lbc.ingQueue.run(time.Second, lbc.stopCh) <-lbc.stopCh - glog.Infof("shutting down NGINX loadbalancer controller") } diff --git a/ingress/controllers/nginx/main.go b/ingress/controllers/nginx/main.go index 75b6f07a8e..8188e88143 100644 --- a/ingress/controllers/nginx/main.go +++ b/ingress/controllers/nginx/main.go @@ -190,6 +190,7 @@ func handleSigterm(lbc *loadBalancerController) { glog.Infof("Error during shutdown %v", err) exitCode = 1 } + glog.Infof("Exiting with %v", exitCode) os.Exit(exitCode) }