Add flag to skip the update of Ingress status on shutdown
This commit is contained in:
parent
ca5f402322
commit
05a976f9e5
4 changed files with 30 additions and 14 deletions
|
@ -138,8 +138,9 @@ type Configuration struct {
|
||||||
// (for instance NGINX)
|
// (for instance NGINX)
|
||||||
Backend ingress.Controller
|
Backend ingress.Controller
|
||||||
|
|
||||||
UpdateStatus bool
|
UpdateStatus bool
|
||||||
ElectionID string
|
ElectionID string
|
||||||
|
UpdateStatusOnShutdown bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// newIngressController creates an Ingress controller
|
// newIngressController creates an Ingress controller
|
||||||
|
@ -307,12 +308,13 @@ func newIngressController(config *Configuration) *GenericController {
|
||||||
|
|
||||||
if config.UpdateStatus {
|
if config.UpdateStatus {
|
||||||
ic.syncStatus = status.NewStatusSyncer(status.Config{
|
ic.syncStatus = status.NewStatusSyncer(status.Config{
|
||||||
Client: config.Client,
|
Client: config.Client,
|
||||||
PublishService: ic.cfg.PublishService,
|
PublishService: ic.cfg.PublishService,
|
||||||
IngressLister: ic.ingLister,
|
IngressLister: ic.ingLister,
|
||||||
ElectionID: config.ElectionID,
|
ElectionID: config.ElectionID,
|
||||||
IngressClass: config.IngressClass,
|
IngressClass: config.IngressClass,
|
||||||
DefaultIngressClass: config.DefaultIngressClass,
|
DefaultIngressClass: config.DefaultIngressClass,
|
||||||
|
UpdateStatusOnShutdown: config.UpdateStatusOnShutdown,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")
|
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")
|
||||||
|
|
|
@ -89,6 +89,10 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
forceIsolation = flags.Bool("force-namespace-isolation", false,
|
forceIsolation = flags.Bool("force-namespace-isolation", false,
|
||||||
`Force namespace isolation. This flag is required to avoid the reference of secrets or
|
`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.`)
|
configmaps located in a different namespace than the specified in the flag --watch-namespace.`)
|
||||||
|
|
||||||
|
UpdateStatusOnShutdown = flags.Bool("update-status-on-shutdown", true, `Indicates if the
|
||||||
|
ingress controller should update the Ingress status IP/hostname when the controller
|
||||||
|
is being stopped. Default is true`)
|
||||||
)
|
)
|
||||||
|
|
||||||
flags.AddGoFlagSet(flag.CommandLine)
|
flags.AddGoFlagSet(flag.CommandLine)
|
||||||
|
@ -164,6 +168,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
|
||||||
PublishService: *publishSvc,
|
PublishService: *publishSvc,
|
||||||
Backend: backend,
|
Backend: backend,
|
||||||
ForceNamespaceIsolation: *forceIsolation,
|
ForceNamespaceIsolation: *forceIsolation,
|
||||||
|
UpdateStatusOnShutdown: *UpdateStatusOnShutdown,
|
||||||
}
|
}
|
||||||
|
|
||||||
ic := newIngressController(config)
|
ic := newIngressController(config)
|
||||||
|
|
|
@ -55,7 +55,10 @@ type Config struct {
|
||||||
Client clientset.Interface
|
Client clientset.Interface
|
||||||
PublishService string
|
PublishService string
|
||||||
IngressLister store.IngressLister
|
IngressLister store.IngressLister
|
||||||
ElectionID string
|
|
||||||
|
ElectionID string
|
||||||
|
|
||||||
|
UpdateStatusOnShutdown bool
|
||||||
|
|
||||||
DefaultIngressClass string
|
DefaultIngressClass string
|
||||||
IngressClass string
|
IngressClass string
|
||||||
|
@ -98,6 +101,11 @@ func (s statusSync) Shutdown() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !s.UpdateStatusOnShutdown {
|
||||||
|
glog.Warningf("skipping update of status of Ingress rules")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
glog.Infof("updating status of Ingress rules (remove)")
|
glog.Infof("updating status of Ingress rules (remove)")
|
||||||
|
|
||||||
addrs, err := s.runningAddresess()
|
addrs, err := s.runningAddresess()
|
||||||
|
|
|
@ -260,11 +260,12 @@ func TestStatusActions(t *testing.T) {
|
||||||
os.Setenv("POD_NAME", "foo1")
|
os.Setenv("POD_NAME", "foo1")
|
||||||
os.Setenv("POD_NAMESPACE", api_v1.NamespaceDefault)
|
os.Setenv("POD_NAMESPACE", api_v1.NamespaceDefault)
|
||||||
c := Config{
|
c := Config{
|
||||||
Client: buildSimpleClientSet(),
|
Client: buildSimpleClientSet(),
|
||||||
PublishService: "",
|
PublishService: "",
|
||||||
IngressLister: buildIngressListener(),
|
IngressLister: buildIngressListener(),
|
||||||
DefaultIngressClass: "nginx",
|
DefaultIngressClass: "nginx",
|
||||||
IngressClass: "",
|
IngressClass: "",
|
||||||
|
UpdateStatusOnShutdown: true,
|
||||||
}
|
}
|
||||||
// create object
|
// create object
|
||||||
fkSync := NewStatusSyncer(c)
|
fkSync := NewStatusSyncer(c)
|
||||||
|
|
Loading…
Reference in a new issue