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

Replace stat syscall with statx #119968

Merged
merged 5 commits into from
Jan 8, 2024

Conversation

j4ckstraw
Copy link
Contributor

statx with AT_STATX_DONT_SYNC will not stuck kubelet syncLoop.

stat will stuck in syscall when nfs server not responding, replace stat with statx to fix it.

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #101622

Special notes for your reviewer:

Does this PR introduce a user-facing change?

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

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. 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. labels Aug 16, 2023
@k8s-ci-robot
Copy link
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.

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 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 Aug 16, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @j4ckstraw. 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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 16, 2023
@j4ckstraw j4ckstraw force-pushed the replace-stat-with-statx branch from 606ad88 to a8d03fe Compare August 16, 2023 09:14
var stat, rootStat unix.Statx_t
var err error

if stat, err = statx(file); err != nil {
Copy link
Member

@jsafrane jsafrane Aug 16, 2023

Choose a reason for hiding this comment

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

Would it be better to reuse MountFast that needs 5.6 ?

It falls back to stat(), but only in < 5.6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm afraid not, because normalizePath will call Stat again.

Copy link
Member

Choose a reason for hiding this comment

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

rather than falling back to IsMountPoint - should it fall back to a implementation of IsLikelyNotMountPoint which uses stat ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't understand what you mean.

The key point here is that stat syscall will trap in kernel, which make kubelet struck in main loop. So I replace stat with statx. AT_STATX_DONT_SYNC option make statx don't sync with remote nfs server, so will not trap in kernel.

English is not my native language. Please forgive me if there are any grammatical mistakes :)

Copy link
Member

Choose a reason for hiding this comment

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

Good catch. IMO it would make sense to use statx in moby's normalizePath then
@kolyshkin, WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

@j4ckstraw I was saying on kernels that don't support statx syscalls, rather than going to IsMountPoint which is slow and could be considered a regression in certain environments, we fall back to an implementation of IsLikelyNotMountPoint which still uses stat and yes, it will get kubelet stuck but it at least behave same as older version and will not be considered a regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gnufied OK, I see. I agree with you, regression is bad, I will try to file a new patch. thank you for your 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.

@gnufied Updated, it's fallback to origin IsLikelyNotMountPoint now.
As you can see, I change the comment of IsLikelyNotMountPoint, I change the semantic of the IsLikelyNotMountPointin the last patch, so it is reliable, but with risk of regression and slow if the kernel not support statx.

After updated, it may be free of regression, but still have risk of making kubelet struck in main loop.
WDYT?

@j4ckstraw j4ckstraw force-pushed the replace-stat-with-statx branch from ae92858 to e47a132 Compare August 17, 2023 02:17
@j4ckstraw j4ckstraw requested review from sftim and jsafrane August 21, 2023 02:47
@j4ckstraw
Copy link
Contributor Author

@jingxu97 Do you have time to take a look at this?

@gnufied
Copy link
Member

gnufied commented Aug 30, 2023

thanks, this is looking good. Can you also add some tests while we are are at it?

@j4ckstraw
Copy link
Contributor Author

thanks, this is looking good. Can you also add some tests while we are are at it?
let me try

@j4ckstraw
Copy link
Contributor Author

thanks, this is looking good. Can you also add some tests while we are are at it?

I've been busy with other things, sorry for the late reply.
I failed to add test for IsLikelyNotMountPoint, because I can't make stat syscall trap in kernel in a test.

@gnufied
Copy link
Member

gnufied commented Oct 9, 2023

/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 Oct 9, 2023
@j4ckstraw
Copy link
Contributor Author

/retest

statx with AT_STATX_DONT_SYNC will not stuck kubelet syncLoop.

Signed-off-by: j4ckstraw <j4ckstraw@foxmail.com>

fix remove useless comment

Signed-off-by: j4ckstraw <j4ckstraw@foxmail.com>
@j4ckstraw
Copy link
Contributor Author

Unmount

I agree with you.

@249043822
Copy link
Member

@j4ckstraw I cherry-picked your commit to our branch, on Linux 4.18, we found that the IsLikelyNotMountPoint works not well, the emptydir mounts netested continuously
2023-12-28_155942

@j4ckstraw
Copy link
Contributor Author

@j4ckstraw I cherry-picked your commit to our branch, on Linux 4.18, we found that the IsLikelyNotMountPoint works not well, the emptydir mounts netested continuously 2023-12-28_155942

@249043822 If no cherry-pick, whether there is a nested mount

@249043822
Copy link
Member

@j4ckstraw I cherry-picked your commit to our branch, on Linux 4.18, we found that the IsLikelyNotMountPoint works not well, the emptydir mounts netested continuously 2023-12-28_155942

@249043822 If no cherry-pick, whether there is a nested mount

No, it's normal

Signed-off-by: j4ckstraw <j4ckstraw@foxmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 1, 2024
staging/src/k8s.io/mount-utils/mount_linux.go Outdated Show resolved Hide resolved
staging/src/k8s.io/mount-utils/mount_linux.go Outdated Show resolved Hide resolved
staging/src/k8s.io/mount-utils/mount_linux.go Outdated Show resolved Hide resolved
Signed-off-by: j4ckstraw <j4ckstraw@foxmail.com>
@j4ckstraw
Copy link
Contributor Author

/test pull-kubernetes-node-e2e-containerd

@jsafrane
Copy link
Member

jsafrane commented Jan 8, 2024

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 8, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 9d7a7289f31ee79dc8014877ab3efcfb62fe19e2

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: j4ckstraw, jsafrane

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 /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 Jan 8, 2024
@k8s-ci-robot k8s-ci-robot merged commit 9e0ecca into kubernetes:master Jan 8, 2024
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Jan 8, 2024
@j4ckstraw j4ckstraw deleted the replace-stat-with-statx branch January 9, 2024 01:25
tydra-wang added a commit to tydra-wang/alibaba-cloud-csi-driver that referenced this pull request Jun 12, 2024
Fix: IsLikelyNotMountPoint hangs forever if nfs server unreachable.
See kubernetes/kubernetes#119968
tydra-wang added a commit to tydra-wang/alibaba-cloud-csi-driver that referenced this pull request Jun 12, 2024
Fix: IsLikelyNotMountPoint hangs forever if nfs server unreachable.
See kubernetes/kubernetes#119968
tydra-wang added a commit to tydra-wang/alibaba-cloud-csi-driver that referenced this pull request Jun 12, 2024
Fix: IsLikelyNotMountPoint hangs forever if nfs server unreachable.
See kubernetes/kubernetes#119968
tydra-wang added a commit to tydra-wang/alibaba-cloud-csi-driver that referenced this pull request Jun 12, 2024
Fix: IsLikelyNotMountPoint hangs forever if nfs server unreachable.
See kubernetes/kubernetes#119968
tydra-wang added a commit to tydra-wang/alibaba-cloud-csi-driver that referenced this pull request Jun 12, 2024
Fix: IsLikelyNotMountPoint hangs forever if nfs server unreachable.
See kubernetes/kubernetes#119968
tydra-wang added a commit to tydra-wang/alibaba-cloud-csi-driver that referenced this pull request Jun 12, 2024
Fix: IsLikelyNotMountPoint hangs forever if nfs server unreachable.
See kubernetes/kubernetes#119968
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. 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. 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/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubelet SyncLoop hangs on "os.Stat" forever if there is an unresponsive NFS volume
10 participants