Add flag to skip the update of Ingress status on shutdown

This commit is contained in:
Manuel de Brito Fontes 2017-06-19 21:22:08 -04:00
parent ca5f402322
commit bf9be4cbaa
3 changed files with 24 additions and 9 deletions

View file

@ -138,8 +138,9 @@ type Configuration struct {
// (for instance NGINX)
Backend ingress.Controller
UpdateStatus bool
ElectionID string
UpdateStatus bool
ElectionID string
StatusUpdateOnShutdown bool
}
// newIngressController creates an Ingress controller
@ -307,12 +308,13 @@ func newIngressController(config *Configuration) *GenericController {
if config.UpdateStatus {
ic.syncStatus = status.NewStatusSyncer(status.Config{
Client: config.Client,
PublishService: ic.cfg.PublishService,
IngressLister: ic.ingLister,
ElectionID: config.ElectionID,
IngressClass: config.IngressClass,
DefaultIngressClass: config.DefaultIngressClass,
Client: config.Client,
PublishService: ic.cfg.PublishService,
IngressLister: ic.ingLister,
ElectionID: config.ElectionID,
IngressClass: config.IngressClass,
DefaultIngressClass: config.DefaultIngressClass,
StatusUpdateOnShutdown: config.StatusUpdateOnShutdown,
})
} else {
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")

View file

@ -89,6 +89,10 @@ func NewIngressController(backend ingress.Controller) *GenericController {
forceIsolation = flags.Bool("force-namespace-isolation", false,
`Force namespace isolation. This flag is required to avoid the reference of secrets or
configmaps located in a different namespace than the specified in the flag --watch-namespace.`)
statusUpdateOnShutdown = flags.Bool("update-status-on-shutdown", true, `Indicates if the
ingress controller should NOT update the Ingress status IP/hostname when the controller
is being stopped. Default is true`)
)
flags.AddGoFlagSet(flag.CommandLine)
@ -164,6 +168,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
PublishService: *publishSvc,
Backend: backend,
ForceNamespaceIsolation: *forceIsolation,
StatusUpdateOnShutdown: *statusUpdateOnShutdown,
}
ic := newIngressController(config)

View file

@ -55,7 +55,10 @@ type Config struct {
Client clientset.Interface
PublishService string
IngressLister store.IngressLister
ElectionID string
ElectionID string
StatusUpdateOnShutdown bool
DefaultIngressClass string
IngressClass string
@ -98,6 +101,11 @@ func (s statusSync) Shutdown() {
return
}
if !s.StatusUpdateOnShutdown {
glog.Warningf("skipping update of status of Ingress rules")
return
}
glog.Infof("updating status of Ingress rules (remove)")
addrs, err := s.runningAddresess()