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

Add multi-pod tests with SELinux mounts #113789

Merged
merged 5 commits into from Jan 18, 2023

Conversation

jsafrane
Copy link
Member

@jsafrane jsafrane commented Nov 9, 2022

What type of PR is this?

/kind feature
(?)

What this PR does / why we need it:

Add test to check that a volume is fully unmounted (NodeUnstaged) before kubelet starts a pod with the same volume, but with a different SELinux context.

Does this PR introduce a user-facing change?

NONE

kubernetes/enhancements#3548

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1710-selinux-relabeling

@k8s-ci-robot k8s-ci-robot added 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. 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 Nov 9, 2022
@k8s-ci-robot
Copy link
Contributor

@jsafrane: 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-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 9, 2022
@jsafrane
Copy link
Member Author

jsafrane commented Nov 9, 2022

/sig storage
/priority important-soon

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 9, 2022
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Nov 9, 2022
@jsafrane
Copy link
Member Author

jsafrane commented Nov 9, 2022

cc @gnufied

@gnufied
Copy link
Member

gnufied commented Nov 11, 2022

The verify failure looks legit:

test/e2e/storage/csi_mock_volume.go:2165:5: ineffectual assignment to err (ineffassign)
				err = e2eevents.WaitTimeoutForEvent(m.cs, pod2.Namespace, eventSelector, msg, f.Timeouts.PodStart)
			

@dims
Copy link
Member

dims commented Nov 14, 2022

@jsafrane if you need this to land in 1.26, please fix the problem in the verify log and get approval/lgtm!

@jsafrane jsafrane changed the title Add multi-pod tests with SELinux mounts WIP: Add multi-pod tests with SELinux mounts Nov 24, 2022
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 24, 2022
@jsafrane
Copy link
Member Author

marked as WIP, it does not need to catch 1.26

@jsafrane
Copy link
Member Author

jsafrane commented Dec 9, 2022

Rebased & updated & removed WIP

@jsafrane jsafrane changed the title WIP: Add multi-pod tests with SELinux mounts Add multi-pod tests with SELinux mounts Dec 9, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 9, 2022
@dims
Copy link
Member

dims commented Dec 12, 2022

If you still need this PR then please rebase, if not, please close the PR

@jsafrane
Copy link
Member Author

If you still need this PR then please rebase, if not, please close the PR

There is nothing to rebase. I updated the PR 4 days ago and I still want it in 1.27.

/retest

"ResourceQuota with cross namespace pod affinity scope using scope-selectors" flaked

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 14, 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 Jan 4, 2023
@jsafrane
Copy link
Member Author

jsafrane commented Jan 4, 2023

I did non-trivial rebase +

  • renamed "first pod" to "the initial pod".
  • added a few comments + rephrased some ExpectNoError contexts.

Check that a volume is fully unmounted (Unstaged) before kubelet starts a
pod with the same volume, but with a different SELinux context.
Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

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

Error strings look good to me, just some minor comments.

mountVolume := nodePublishRequest.GetVolumeCapability().GetMount()
if mountVolume != nil {
*nodePublishMountOpts = mountVolume.MountFlags
}
}
_, ok = request.(*csipbv1.NodeUnstageVolumeRequest)
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing error handling?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the code is correct, still, I rewrote it to switch request.(type) to be more obvious.

if ok {
unstageCalls.Add(1)
}
_, ok = request.(*csipbv1.NodeUnpublishVolumeRequest)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here?

})
ginkgo.DeferCleanup(m.cleanup)
defer m.cleanup(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you reverting to using defer here?

It will not be able to clean up when the test gets interrupted because then ctx will be canceled.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, using DeferCleaup now


// Skip scheduler, it would block scheduling the second pod with ReadWriteOncePod PV.
pod, err = m.cs.CoreV1().Pods(pod.Namespace).Get(ctx, pod.Name, metav1.GetOptions{})
framework.ExpectNoError(err, fmt.Sprintf("getting the initial pod"))
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for fmt.Sprintf: there's nothing to format, and even if there was, ExpectNoError could be passed a format string plus parameters.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@jsafrane
Copy link
Member Author

All three failed this test: [It] [sig-cli] Kubectl logs default container logs the second container is the default-container by annotation should log default container if not specified

/retest

Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@gnufied
Copy link
Member

gnufied commented Jan 18, 2023

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

LGTM label has been added.

Git tree hash: 87da4005167590625f91f021f39fae471f56191c

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gnufied, 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 merged commit dfbe1c0 into kubernetes:master Jan 18, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Jan 18, 2023
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/test 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-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants