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

kubelet: Refactor tryUpdateNodeStatus() into smaller functions #113466

Conversation

jingyuanliang
Copy link
Contributor

@jingyuanliang jingyuanliang commented Oct 31, 2022

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?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 31, 2022
@k8s-ci-robot
Copy link
Contributor

@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 triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Oct 31, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jingyuanliang
Once this PR has been reviewed and has the lgtm label, please assign derekwaynecarr for approval by writing /assign @derekwaynecarr in a comment. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 31, 2022
@jingyuanliang
Copy link
Contributor Author

/cc @aojea
/cc @mborsz
/cc @MrHohn

@jingyuanliang jingyuanliang changed the title kubelet: Refactor tryUpdateNodeStatus() kubelet: Refactor tryUpdateNodeStatus() into smaller functions Oct 31, 2022
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 {
Copy link
Member

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?

Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

oh, thanks, sorry


// 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) {
Copy link
Member

Choose a reason for hiding this comment

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

it should be patchNodeStatus

@aojea
Copy link
Member

aojea commented Oct 31, 2022

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

@jingyuanliang
Copy link
Contributor Author

jingyuanliang commented Oct 31, 2022

Is the current tryUpdateNodeStatus() already covered by sufficient amount of tests?

@aojea
Copy link
Member

aojea commented Nov 2, 2022

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?

@aojea
Copy link
Member

aojea commented Nov 2, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 2, 2022
@jingyuanliang jingyuanliang force-pushed the tryUpdateNodeStatusRefactor branch 2 times, most recently from 18312cb to 4e1145e Compare November 2, 2022 03:38
@jingyuanliang
Copy link
Contributor Author

#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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 4, 2022
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 7, 2022
@aojea
Copy link
Member

aojea commented Nov 10, 2022

/close

superseded by #112618

@k8s-ci-robot
Copy link
Contributor

@aojea: Closed this PR.

In response to this:

/close

superseded by #112618

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.

SIG Node PR Triage automation moved this from Triage to Done Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants