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
pass instanceMetadata to updateNodeAddress to reduce api calls #93284
Conversation
/retest |
/assign @andrewsykim @wojtek-t |
LGTM, but unfortunately we are in code-freeze now and this needs to wait until we start accepting 1.20 PRs. I would also like @andrewsykim to take a look. |
/uncc |
71b43dd
to
6d2052e
Compare
/retest |
staging/src/k8s.io/cloud-provider/controllers/node/node_controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/cloud-provider/controllers/node/node_controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/cloud-provider/controllers/node/node_controller.go
Outdated
Show resolved
Hide resolved
/retest |
a862791
to
8ed2f64
Compare
Sorry for the delay @gongguan -- I'll review this soon |
No sorry, there is something wrong I'll fix it now, you can review after ci passed. |
28c7f7e
to
53aba78
Compare
/retest |
@andrewsykim ready for review now :) |
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.
LGTM, minor comment about error logging
staging/src/k8s.io/cloud-provider/controllers/node/node_controller.go
Outdated
Show resolved
Hide resolved
53aba78
to
ad8297e
Compare
/test pull-kubernetes-e2e-kind-ipv6 |
@andrewsykim addressed and rebased, PTAL. |
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.
Sorry, had one more comment
if err != nil { | ||
return nil, err | ||
var nodeModifiers []nodeModifier | ||
if node.Spec.ProviderID != providerID { |
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 think this check needs to be updated to
if node.Spec.ProviderID == "" && providerID != "" {
otherwise we might try to set an existing node.Spec.ProviderID
to "". What do you think?
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.
Done as your suggestion, it is more legible.
otherwise we might try to set an existing
node.Spec.ProviderID
to "". What do you think?
No, in line 454(getProviderID
function), providerID
will be set as node.Spec.ProviderID
if node.Spec.ProviderID
not nil. That means node.Spec.ProviderID
not equal to providerID
only occurs when node.Spec.ProviderID
not set.
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.
No, in line 454(getProviderID function), providerID will be set as node.Spec.ProviderID if node.Spec.ProviderID not nil. That means node.Spec.ProviderID not equal to providerID only occurs when node.Spec.ProviderID not set.
Good point
ad8297e
to
e0b2dce
Compare
/retest |
/test pull-kubernetes-e2e-kind-ipv6 |
instanceMetadata, err := cnc.getInstanceNodeAddresses(ctx, &nodes.Items[i]) | ||
if err != nil { | ||
klog.Errorf("Error getting instance metadata for node addresses: %v", err) | ||
return |
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.
this should probably be continue
?
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.
You're right, fixed.
nodeModifiers, err := cnc.getNodeModifiersFromCloudProvider(ctx, curNode) | ||
providerID, err := cnc.getProviderID(ctx, curNode) | ||
if err != nil { | ||
utilruntime.HandleError(fmt.Errorf("failed to initialize node %s at cloudprovider: %v", node.Name, err)) |
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.
This error message should probably be specific to getting the providerID:
utilruntime.HandleError(fmt.Errorf("failed to get provider ID for node %s: %v", node.Name, err))
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.
done
|
||
instanceMetadata, err := cnc.getInstanceMetadata(ctx, providerID, curNode) | ||
if err != nil { | ||
utilruntime.HandleError(err) |
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.
Wrap this error similar to other calls to HandleError here
utilruntime.HandleError(fmt.Errorf("failed to get instance metadata for node %s: %v", node.Name, err))
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.
done
…tadata to updateNodeAddress
e0b2dce
to
9678d4f
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.
/approve
/lgtm
Thanks @gongguan
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewsykim, gongguan 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 feature
What this PR does / why we need it:
Pass instanceMetadata to updateNodeAddress to reduce api calls.
Which issue(s) this PR fixes:
Ref #90652
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: