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

Fix directory mismatch for volume.SetVolumeOwnership() #117022

Conversation

mpatlasov
Copy link
Contributor

@mpatlasov mpatlasov commented Mar 30, 2023

In most cases dir arg of SetUpAt() method of volume.Mounter interface is the same as mounter.GetPath() because we usually call SetUpAt() from SetUp() like this:

func (ed *emptyDir) SetUp(mounterArgs volume.MounterArgs) error {
	return ed.SetUpAt(ed.GetPath(), mounterArgs)
}

(this example is from volume/emptydir/empty_dir.go, but there are plenty other examples like that in volume/*)

However, there is currently one exception. This is from volume/projected/projected.go:

	if err := wrapped.SetUpAt(dir, mounterArgs); err != nil {
		return err
	}

(see

if err := wrapped.SetUpAt(dir, mounterArgs); err != nil {
)

In this case dir is not equal to wrapped.GetPath() and volume.SetVolumeOwnership() fails when called from SetUpAt() of wrapped volume:

lstat /var/lib/kubelet/pods/a2f6e58f-7edf-4c48-a97c-ef1b8fd3caf6/volumes/kubernetes.io~empty-dir/wrapped_kube-api-access-knvkv: no such file or directory

To fix the issue let's pass dir arg to volume.SetVolumeOwnership() explicitly, and use it instead of mounter.GetPath().

What type of PR is this?

/kind bug
/sig storage

What this PR does / why we need it:

Numerous failed volume.SetVolumeOwnership() calls pollute metric storage_operation_duration_seconds_count for emptyDir volumes.

Which issue(s) this PR fixes:

Fixes #117021

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Number of errors reported to the metric `storage_operation_duration_seconds_count` for emptyDir decreased significantly because previously one error was reported for each projected volume created.

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


@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/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. sig/storage Categorizes an issue or PR as relevant to SIG Storage. labels Mar 30, 2023
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.27 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.27.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Thu Mar 30 16:31:51 UTC 2023.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 30, 2023
@k8s-ci-robot k8s-ci-robot requested a review from cofyc March 30, 2023 20:53
@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 requested a review from gnufied March 30, 2023 20:53
@k8s-ci-robot
Copy link
Contributor

Hi @mpatlasov. 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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 30, 2023
@mpatlasov
Copy link
Contributor Author

/assign @jsafrane

@jsafrane
Copy link
Member

jsafrane commented Apr 3, 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 Apr 3, 2023
@jsafrane
Copy link
Member

jsafrane commented Apr 3, 2023

@mpatlasov you need to update SetVolumeOwnership params for non-Linux platforms, https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/volume_unsupported.go

In most cases `dir` arg of `SetUpAt()` method of `volume.Mounter` interface is the same as `mounter.GetPath()` because we usually call `SetUpAt()` from `SetUp()` like this:"
```
func (ed *emptyDir) SetUp(mounterArgs volume.MounterArgs) error {
	return ed.SetUpAt(ed.GetPath(), mounterArgs)
}
```
(this example is from `volume/emptydir/empty_dir.go`, but there are plenty other examples like that in `volume/*`)

However, there is currently one exception. This is from `volume/projected/projected.go`:
```
	if err := wrapped.SetUpAt(dir, mounterArgs); err != nil {
		return err
	}
```
(see https://github.com/kubernetes/kubernetes/blob/96306f144a3c917a97fe27c9ad5dd89e4213f741/pkg/volume/projected/projected.go#L203)

In this case `dir` is not equal to `wrapped.GetPath()` and `volume.SetVolumeOwnership()` fails when called from `SetUpAt()` of wrapped volume:
```
lstat /var/lib/kubelet/pods/a2f6e58f-7edf-4c48-a97c-ef1b8fd3caf6/volumes/kubernetes.io~empty-dir/wrapped_kube-api-access-knvkv: no such file or directory
```

To fix the issue let's pass `dir` arg to `volume.SetVolumeOwnership()` explicitly, and use it instead of `mounter.GetPath()`.
@mpatlasov mpatlasov force-pushed the fix-dir-mismatch-for-SetVolumeOwnership branch from cba4aa6 to 0a37f09 Compare April 3, 2023 19:36
@gnufied
Copy link
Member

gnufied commented Apr 3, 2023

/lgtm

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

LGTM label has been added.

Git tree hash: 6c57e3b05a9f5a6378d1991de6bdc56b12033f20

@jsafrane
Copy link
Member

jsafrane commented Apr 4, 2023

/retest

@jsafrane
Copy link
Member

jsafrane commented Apr 4, 2023

/approve
/retest

The unit test failures are not related

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Apr 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 8722ab2 into kubernetes:master Apr 12, 2023
@humblec
Copy link
Contributor

humblec commented Apr 25, 2023

@mpatlasov can you also file 1.24 cherrypick PR as its the same code path and affected with this bug?

k8s-ci-robot added a commit that referenced this pull request May 3, 2023
…17022-upstream-release-1.25

Automated cherry pick of #117022: Fix directory mismatch for `volume.SetVolumeOwnership()`
k8s-ci-robot added a commit that referenced this pull request May 3, 2023
…17022-upstream-release-1.24

Automated cherry pick of #117022: Fix directory mismatch for `volume.SetVolumeOwnership()`
k8s-ci-robot added a commit that referenced this pull request May 3, 2023
…17022-upstream-release-1.26

Automated cherry pick of #117022: Fix directory mismatch for `volume.SetVolumeOwnership()`
k8s-ci-robot added a commit that referenced this pull request May 3, 2023
…17022-upstream-release-1.27

Automated cherry pick of #117022: Fix directory mismatch for `volume.SetVolumeOwnership()`
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 Denotes a PR that will be considered when it comes time to generate release notes. 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.

volume.SetVolumeOwnership() always fails when called for wrapped volume
5 participants