-
Notifications
You must be signed in to change notification settings - Fork 326
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
[NET-6588] Remove abandoned virtual nodes from Consul Catalog #3307
Conversation
f4f5bff
to
08b9477
Compare
08b9477
to
109a3aa
Compare
033d4df
to
a67b607
Compare
// (wildcard) to determine if there any other services associated with the Node. We also only search for nodes that have | ||
// the correct kubernetes metadata (managed-by-endpoints-controller and synthetic-node). | ||
func (r *Controller) deregisterNode(apiClient *api.Client, k8sServiceName, k8sServiceNamespace, nodeName string) error { | ||
nodeServices, err := r.serviceInstancesForK8SServiceNameAndNamespace(apiClient, k8sServiceName, k8sServiceNamespace, nodeName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is the wrong function because it filters on the k8sServiceName
, but to clean the node we need to know if ANY service is associated with the node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are getting all the services associated with that node with:
If I am reading the filter correctly it is:
give me the node with:
name = "foo-virtual"
meta {
"k8s-service" = "static-server"
"k8s-namespace" = "default"
"managed-by" = "endpoints-controller"
}
filter := fmt.Sprintf(
Meta[%q] == %q and Meta[%q] == %q and Meta[%q] == %q, metaKeyKubeServiceName, k8sServiceName, constants.MetaKeyKubeNS, k8sServiceNamespace, metaKeyManagedBy, constants.ManagedByValue)
serviceList, _, err = apiClient.Catalog().NodeServiceList(nodeName, &api.QueryOptions{Filter: filter})
I think we do it with a filter like this instead of node because Consul would be slow to return without the filter.
Let me know if you want me to run this in a real cluster which can reproduce this problem many times per day :) |
@komapa Thank you! You can grab the image at: (I tagged you late on Friday but I found a bug that I had to fix. It should be better now) |
Remove virtual nodes that do not have services registered
d876589
to
c813068
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this. I have minor concerns about the performance of the endpoints controller given we have steadily increased what happens during the reconciles, but i think that requires a different, more thorough introspection into what we do in the endpoints controller. This is great work right here though.
@thisisnotashwin Zalimeni has a PR in draft to help with the endpoints controller performance. I do think that my PR might help with performance as we would have fewer abandoned nodes to scan through on each reconcile. |
yayyy!! that definitely helps. i think this multipronged approach is the way forward! |
Changes proposed in this PR:
How I've tested this PR:
How I expect reviewers to test this PR:
👀
Checklist: