-
Notifications
You must be signed in to change notification settings - Fork 313
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 route controller create/delete spam: use instanceIDToNodeName in case node name != private DNS #319
Conversation
@wongma7: This issue is currently awaiting triage. If cloud-provider-aws contributors determine this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/cc @olemarkus |
This looks good to me. Like the indexer approach. |
return types.NodeName(instanceID), nil | ||
} | ||
|
||
nodes, err := c.nodeInformer.Informer().GetIndexer().IndexKeys("instanceID", string(instanceID)) |
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.
Can you remind me why the .Lister() is tried first, and error ignored and the .Informer() is tried second? I guess my question is when does it error? And why doesn't the Indexer work for all cases?
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.
indexer should work for all cases, the Lister Get is redundant and I was thinking of it as a fast path but in practice I don't think it's any faster than Informer().GetIndexer().IndexKeys, so we an remove.
The Lister Get would error if the node name is NOT equal to instance ID e.g. if the node name is still set to private dns.
@@ -112,9 +112,13 @@ func (c *Cloud) ListRoutes(ctx context.Context, clusterName string) ([]*cloudpro | |||
// Capture instance routes | |||
instanceID := aws.StringValue(r.InstanceId) | |||
if instanceID != "" { | |||
instance, found := instances[instanceID] | |||
_, found := instances[instanceID] |
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.
Do we need this check or can we remove the instances, err := c.getInstancesByIDs(instanceIDs)
entirely?
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 don't know, I didn't think too much of it bc I think it's out of scope of this PR.
But I think the check is wrong because ListRoutes should return all routes in the cluster's table and let the route controller decide whether it should be deleted. Because right now if there is a zombie route (say a node gets terminated while route controller is down) and then you hit the warning, the zombie will never get cleaned up?
but again I think it's out of scope so I'd rather fix this later
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.
the zombie will never get cleaned up?
This is what I was wondering about, and I agree I'm pretty sure that check was only there due to necessity and we can remove it now. The route controller can remove routes if the nodes don't exist: https://github.com/kubernetes/cloud-provider/blob/master/controllers/route/route_controller.go#L236-L257
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nckturner, wongma7 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The function
mapInstanceToNodeName
assumes that node names are always equal to private dns names. This assumption does not always hold, specifically in 1.23 kops clusters with CCM enabled where node names are overridden to be instance IDs.I added
instanceIDToNodeName
as a replacement. It relies on an indexer in the node informer to find nodeName by instance ID. This solution might be heavy-handed, I don't know how expensive exactly it is to have this indexer. If we assume that node names are going to be limited to either private dns or instance ids (or fargate?) then the solution could be simpler: it could check if a node with name equal to instance id exists, as suggested here kubernetes/kops#13376 (comment), and if not then fall back to assuming that node names are private dns names. Open to suggestions of course...I tested this in my own cluster, I'll need to work on unit tests. And am considering how we can test this end to end or if such a test is necessary. We only caught this issue in the first place because AWS alerted us that we were making an unusual # of calls.
Test:
Which issue(s) this PR fixes:
Fixes #318
Special notes for your reviewer:
Does this PR introduce a user-facing change?: