Skip to content

Add random interval to nodeStatusReport interval every time after an actual node status change#128640

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
mengqiy:spreadkubeletlaod
Nov 7, 2024
Merged

Add random interval to nodeStatusReport interval every time after an actual node status change#128640
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
mengqiy:spreadkubeletlaod

Conversation

@mengqiy

@mengqiy mengqiy commented Nov 7, 2024

Copy link
Copy Markdown
Member

Adding one time [-50% , +50%] randomness to nodeStatusReportFrequency after initial node status update.
It helps spread the load from kubelet evenly

This is the 2nd attempt of #128394. Previous PR was rolled back due to it caused flakiness to TestUpdateNodeStatusWithLease unit.

This PR contains everything in #128394 + one line code change to TestUpdateNodeStatusWithLease.

TestUpdateNodeStatusWithLease is not new test that were introduced by #128394.
TestUpdateNodeStatusWithLease was failing after we merge #128394 because in TestUpdateNodeStatusWithLease nodeStatusReportFrequency is set to 1m and the test expect an node status update to happen after 1m. But after #128394, this chance becomes 50%.
How I fix it in this PR is to nodeStatusReportFrequency to 30s so that we can always expect an node status update to happen due to time passage.

What type of PR is this?

/kind feature

What this PR does / why we need it:

The node status update traffic from kubelet can be almost synchronized in some scenarios and caused high CPU spikes. e.g. #124202

Which issue(s) this PR fixes:

Fixes #124202

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Add a one-time random duration of up to 50% of kubelet's nodeStatusReportFrequency to help spread the node status update load evenly over time.

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


…actual node status change

update TestUpdateNodeStatusWithLease this time to avoid flakiness
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. 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. labels Nov 7, 2024
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

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.

Details

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Nov 7, 2024
@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 Nov 7, 2024
@mengqiy

mengqiy commented Nov 7, 2024

Copy link
Copy Markdown
Member Author

/assign @SergeyKanzhelev

// You will add up to 50% of nodeStatusReportFrequency of additional random latency for
// kubelet to determine if update node status is needed due to time passage. We need to
// take that into consideration to ensure this test pass all time.
kubelet.nodeStatusReportFrequency = 30 * time.Second

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the change to defalke TestUpdateNodeStatusWithLease .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

did you run this test like 100 times in a loop locally?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this change makes sense to me. Once you run it many times in a row, please ping

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@mengqiy @SergeyKanzhelev for flake proof we ask people to use the stress tool, for reference https://pkg.go.dev/golang.org/x/tools/cmd/stress

go test -c -race ./pkg/kubelet/
stress ./kubelet.test -test.run=TestUpdateNodeStatusWithLease
5s: 145 runs so far, 0 failures
10s: 337 runs so far, 0 failures
15s: 536 runs so far, 0 failures
20s: 738 runs so far, 0 failures
25s: 938 runs so far, 0 failures
30s: 1160 runs so far, 0 failures
35s: 1365 runs so far, 0 failures
40s: 1562 runs so far, 0 failures
45s: 1766 runs so far, 0 failures

This /lgtm

@mengqiy mengqiy Nov 7, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

for flake proof we ask people to use the stress tool, for reference https://pkg.go.dev/golang.org/x/tools/cmd/stress

TIL
Thank you!

I run go test -v -count=1 ./pkg/kubelet/... 100 times locally in a loop. All are passing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is not the same, we should require proof with stress for flakes,

@aojea

aojea commented Nov 7, 2024

Copy link
Copy Markdown
Member

/lgtm
seems it does not flake now #128640 (comment)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 7, 2024
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: c2ed62560b9aadd016479b28db8c0d99748e971c

@dims

dims commented Nov 7, 2024

Copy link
Copy Markdown
Member

seems it does not flake now #128640 (comment)

/approve
/lgtm

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, mengqiy

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 7, 2024
@k8s-ci-robot k8s-ci-robot merged commit c9024e7 into kubernetes:master Nov 7, 2024
@k8s-ci-robot k8s-ci-robot added this to the v1.32 milestone Nov 7, 2024
@mengqiy mengqiy deleted the spreadkubeletlaod branch November 7, 2024 16:42
Comment on lines +606 to +608
if kl.lastStatusReportTime.IsZero() {
return false
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This added a change behavior that regressed the kubelet #130305 @mengqiy @SergeyKanzhelev

The devil is in the details , before

shouldPatchNodeStatus := changed || kl.clock.Since(kl.lastStatusReportTime) >= kl.nodeStatusReportFrequency

but kl.clock.Since(kl.lastStatusReportTime) >= kl.nodeStatusReportFrequency if kl.lastStatusReportTime is time.Time{} or time.Zero is always true time.Since(time.Time{})

and in this patch we changed this meaning , so before it always updated the status after start but now , if there are no changes, it will never update the status

@liggitt is recommending to revert , and backport the revert so we can rework it in the current branch

#130305 (comment)

and I agree with him, after seeing the issue in #130001 and all the indirect dependencies associated to the status update we can not be sure that fix forwarding we don't find a new weird bug, this took @lentzi90 a lot of work to figure it out, who could imagine that the certificate creation was dependong on the node status update. cc: @dims

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 to revert @aojea

cc @mengqiy

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree that let's revert it and rework it in 1.33.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Development

Successfully merging this pull request may close these issues.

kubelet periodic node status update should not be aligned

5 participants