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

Fix issue where routes are not cleaned up when a namespace label is deleted or updated. #20579

Merged
merged 1 commit into from
Aug 13, 2018
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
6 changes: 5 additions & 1 deletion pkg/router/controller/router_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ func (c *RouterController) processNamespace(eventType watch.EventType, ns *kapi.
}

func (c *RouterController) UpdateNamespaces() {
namespaces := c.FilteredNamespaceNames
// Note: Need to clone the filtered namespace names or else any updates
// we make locally in processNamespace() will be immediately
// reflected to plugins in the chain beneath us. This creates
// cleanup issues as old == new in Plugin.HandleNamespaces().
namespaces := sets.NewString(c.FilteredNamespaceNames.List()...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, good catch

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, processNamespace() is synchronous but Host admitter and Unique status plugins are holding reference to the FilteredNamespaceNames and any subsequent changes in processNamespace() are immediately reflected in those plugin.


glog.V(4).Infof("Updating watched namespaces: %v", namespaces)
if err := c.Plugin.HandleNamespaces(namespaces); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/router/template/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ func (r *templateRouter) commitAndReload() error {
}

r.stateChanged = false
r.dynamicallyConfigured = true
if r.dynamicConfigManager != nil {
r.dynamicallyConfigured = true
r.dynamicConfigManager.Notify(RouterEventReloadStart)
}

Expand Down Expand Up @@ -510,6 +510,10 @@ func (r *templateRouter) FilterNamespaces(namespaces sets.String) {
delete(r.state, k)
r.stateChanged = true
}

if r.stateChanged {
r.dynamicallyConfigured = false
}
}

// CreateServiceUnit creates a new service named with the given id.
Expand Down