Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1057 from aledbf/fix-ip-removal
Browse files Browse the repository at this point in the history
[nginx-ingress-controller]: Remove loadBalancer ip on shutdown
  • Loading branch information
bprashanth committed May 26, 2016
2 parents 1021eb6 + 40eeb7a commit e21c45c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ingress/controllers/nginx/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down Expand Up @@ -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")
}
1 change: 1 addition & 0 deletions ingress/controllers/nginx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit e21c45c

Please sign in to comment.