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

[nginx-ingress-controller]: Remove loadBalancer ip on shutdown #1057

Merged
merged 1 commit into from
May 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}