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

admission_test.go(TestAdmit): compare SecurityContexts instead of particular members #17296

Merged
merged 13 commits into from
Nov 21, 2017

Conversation

php-coder
Copy link
Contributor

This makes the test close to the upstream implementation.

Extracted from #16934 (comment)

PTAL @liggitt @pweil- @adelton @simo5

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 14, 2017
func podSC(fsGroup, supGroup int64) *kapi.PodSecurityContext {
return &kapi.PodSecurityContext{
SELinuxOptions: &kapi.SELinuxOptions{
Level: "s0:c1,c0",
Copy link

Choose a reason for hiding this comment

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

I see that this is the way it was in the previous tests but now I'm wondering why it's hard coded.

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 had a version where SELinux Level was passed to the function, but later I realized that we always passing the same value and I decided to inline it. With the current approach we need to pass only the values that differs between tests.

Do you think that I should step back and continue to passing a level as an argument?

Copy link

Choose a reason for hiding this comment

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

The value assumption is correct but we should be pulling it from the namespace. Guess that was missed in a refactor somewhere:

func CreateNamespaceForTest() *kapi.Namespace {
	return &kapi.Namespace{
		ObjectMeta: metav1.ObjectMeta{
			Name: "default",
			Annotations: map[string]string{
				allocator.UIDRangeAnnotation:           "1/3",
				allocator.MCSAnnotation:                "s0:c1,c0",
				allocator.SupplementalGroupsAnnotation: "2/3",
			},
		},
	}
}

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 updated the code and started to use a variable for that. PTAL.

@legionus
Copy link
Contributor

@php-coder Can you split the TestAdmit to separate tests ? Very difficult to read the test which spans few pages. For example, you can make a helper and call it for each element in testCases.

@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 14, 2017
@php-coder php-coder force-pushed the refactor_test_admit branch 2 times, most recently from 99ae8d5 to 41d05aa Compare November 14, 2017 18:55
@php-coder
Copy link
Contributor Author

Can you split the TestAdmit to separate tests ?

@legionus Ok, I split it to 2 functions :) Is it better now?

@php-coder
Copy link
Contributor Author

The old flake: #16878
/test extended_conformance_gce

Another old flake: #13046
/test end_to_end

@php-coder
Copy link
Contributor Author

PTAL @pweil-

Copy link

@pweil- pweil- left a comment

Choose a reason for hiding this comment

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

LGTM pending the comment

@@ -293,18 +223,111 @@ func TestAdmit(t *testing.T) {
Level: "s0:c1,c0",
}

// level matches a value from namespace (see CreateNamespaceForTest())
seLinuxLevelFromNamespace := "s0:c1,c0"
Copy link

Choose a reason for hiding this comment

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

We can't pull this from the namespace? I took a quick look but didn't see that it was available. I guess the whole point is that if the ns method changes all of these tests are broken. Easy to change since it's in one place. If that's how it has to be then I'm ok with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pweil- I added what you've asked: 268aea6 PTAL. I don't see a way of how to do it better than that.

Copy link

Choose a reason for hiding this comment

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

you could make the setupClientSet call return the namespace that was used. But yes, that's what I was looking to see so that if it is changed somewhere it won't break anything. Thanks for the update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need a namespace only in a single place, so I think it's better to keep this function as-is.

@php-coder
Copy link
Contributor Author

/test extended_conformance_gce

@pweil- Could you merge it?

@php-coder
Copy link
Contributor Author

/test extended_conformance_gce

@openshift-ci-robot
Copy link

@php-coder: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_gce 268aea6 link /test extended_conformance_gce

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@php-coder
Copy link
Contributor Author

extended_conformance_gce is failing with errors like Gave up after waiting 5m0s for pod or timed out waiting for the condition by unrelated reasons. This PR modifies only a single file with unit tests, so it's unlikely that it causes failure of the conformance tests. I suspect that they're failing because our nodes under pressure this time.

@php-coder
Copy link
Contributor Author

@openshift/sig-security As because @pweil- on PTO (and will be there next 2 days), please, merge this PR. This refactoring is required for the #16934 that fixes P1 issue.

@simo5
Copy link
Contributor

simo5 commented Nov 21, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 21, 2017
@eparis
Copy link
Member

eparis commented Nov 21, 2017

/approve

@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eparis, php-coder, simo5

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 21, 2017
@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 17369, 17296).

@openshift-merge-robot openshift-merge-robot merged commit 5eb8353 into openshift:master Nov 21, 2017
@php-coder php-coder deleted the refactor_test_admit branch November 21, 2017 16:50
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. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants