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
kubelet: Refactor tryUpdateNodeStatus() into smaller functions #113466
kubelet: Refactor tryUpdateNodeStatus() into smaller functions #113466
Conversation
@jingyuanliang: This issue is currently awaiting triage. If a SIG or subproject determines 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. |
Hi @jingyuanliang. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jingyuanliang The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
704a6a4
to
add5312
Compare
add5312
to
692ba91
Compare
pkg/kubelet/kubelet_node_status.go
Outdated
if originalNode == nil { | ||
return fmt.Errorf("nil %q node object", kl.nodeName) | ||
} | ||
|
||
node, changed := kl.updateNode(originalNode) | ||
|
||
if kl.clock.Since(kl.lastStatusReportTime) < kl.nodeStatusReportFrequency && !changed { |
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.
ok, this !changed is an optimization, right?
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.
ah, no, it is !podCIDRChanged && !nodeStatusHasChanged(&originalNode.Status, &node.Status) && !areRequiredLabelsNotPresent
|
||
updatedNode, err := kl.patchNode(originalNode, node) | ||
if err == nil { | ||
kl.markVolumesFromNode(updatedNode) |
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.
kl.markVolumesFromNode(updatedNode) | |
// If update finishes successfully, mark the volumeInUse as reportedInUse to indicate | |
// those volumes are already updated in the node's status | |
kl.markVolumesFromNode(updatedNode) |
I suggest to keep the comments
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 comment was moved to the top of markVolumesFromNode.
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.
oh, thanks, sorry
pkg/kubelet/kubelet_node_status.go
Outdated
|
||
// patchNode patches node on the API server based on originalNode. | ||
// It returns any potential error, or an updatedNode and refreshes the state of kubelet when successful. | ||
func (kl *Kubelet) patchNode(originalNode, node *v1.Node) (*v1.Node, error) { |
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.
it should be patchNodeStatus
so, right now it seems that the update node process is undocumented, if we break it down and we start to use independent fragments I'm not sure we'll respect the kubelet update node process now or in the future unless we create a test that defines this process |
Is the current tryUpdateNodeStatus() already covered by sufficient amount of tests? |
I don't think we have good tests in this area, I remember one regression that increased the time to start kubelet #99336 and went undetected I really think we should do this, but I'm scared of regressions ... What is your intent with this patch, I assume that this is part of a larger change, can you add subsequent commits so we can review the whole solution proposed? |
/ok-to-test |
18312cb
to
4e1145e
Compare
#112618 was updated to show the use with this refactor. Let's keep this PR open so we can run tests on the refactor alone. |
4e1145e
to
983ac5d
Compare
983ac5d
to
3729fe9
Compare
3729fe9
to
34ac70a
Compare
34ac70a
to
3dc172a
Compare
/close superseded by #112618 |
@aojea: Closed this PR. In response to this:
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. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Support #112618. This replaces #113188.
Which issue(s) this PR fixes:
This breaks down tryUpdateNodeStatus into multiple functions.
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: