Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to skip the update of Ingress status on shutdown #882

Merged
merged 1 commit into from
Jun 20, 2017
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
18 changes: 10 additions & 8 deletions core/pkg/ingress/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ type Configuration struct {
// (for instance NGINX)
Backend ingress.Controller

UpdateStatus bool
ElectionID string
UpdateStatus bool
ElectionID string
UpdateStatusOnShutdown bool
}

// newIngressController creates an Ingress controller
Expand Down Expand Up @@ -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,
UpdateStatusOnShutdown: config.UpdateStatusOnShutdown,
})
} else {
glog.Warning("Update of ingress status is disabled (flag --update-status=false was specified)")
Expand Down
5 changes: 5 additions & 0 deletions core/pkg/ingress/controller/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.`)

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)
Expand Down Expand Up @@ -164,6 +168,7 @@ func NewIngressController(backend ingress.Controller) *GenericController {
PublishService: *publishSvc,
Backend: backend,
ForceNamespaceIsolation: *forceIsolation,
UpdateStatusOnShutdown: *UpdateStatusOnShutdown,
}

ic := newIngressController(config)
Expand Down
10 changes: 9 additions & 1 deletion core/pkg/ingress/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ type Config struct {
Client clientset.Interface
PublishService string
IngressLister store.IngressLister
ElectionID string

ElectionID string

UpdateStatusOnShutdown bool

DefaultIngressClass string
IngressClass string
Expand Down Expand Up @@ -98,6 +101,11 @@ func (s statusSync) Shutdown() {
return
}

if !s.UpdateStatusOnShutdown {
glog.Warningf("skipping update of status of Ingress rules")
return
}

glog.Infof("updating status of Ingress rules (remove)")

addrs, err := s.runningAddresess()
Expand Down
11 changes: 6 additions & 5 deletions core/pkg/ingress/status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,12 @@ func TestStatusActions(t *testing.T) {
os.Setenv("POD_NAME", "foo1")
os.Setenv("POD_NAMESPACE", api_v1.NamespaceDefault)
c := Config{
Client: buildSimpleClientSet(),
PublishService: "",
IngressLister: buildIngressListener(),
DefaultIngressClass: "nginx",
IngressClass: "",
Client: buildSimpleClientSet(),
PublishService: "",
IngressLister: buildIngressListener(),
DefaultIngressClass: "nginx",
IngressClass: "",
UpdateStatusOnShutdown: true,
}
// create object
fkSync := NewStatusSyncer(c)
Expand Down