-
Notifications
You must be signed in to change notification settings - Fork 4.8k
OCPBUGS-86044: Use generated names in oc adm policy SCC test #31221
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,38 +212,42 @@ var _ = g.Describe("[sig-cli] oc adm", func() { | |
| o.Expect(err).To(o.HaveOccurred()) | ||
| o.Expect(out).To(o.ContainSubstring("error: rolebinding custom found for role view, not other")) | ||
|
|
||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", "fake-user").Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", "-z", "fake-sa").Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-group").Args("privileged", "fake-group").Execute()).To(o.Succeed()) | ||
| fakeUser := gen.GenerateName("fake-user-") | ||
| fakeSA := gen.GenerateName("fake-sa-") | ||
| fakeGroup := gen.GenerateName("fake-group-") | ||
|
|
||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", fakeUser).Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", "-z", fakeSA).Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-group").Args("privileged", fakeGroup).Execute()).To(o.Succeed()) | ||
|
Comment on lines
+219
to
+221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Batch SCC subject mutations into single The user and serviceaccount updates are still split across separate invocations; that leaves a cache-propagation window between writes and weakens the race fix intent. Suggested change- o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", fakeUser).Execute()).To(o.Succeed())
- o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", "-z", fakeSA).Execute()).To(o.Succeed())
+ o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", fakeUser, "-z", fakeSA).Execute()).To(o.Succeed())
o.Expect(oc.Run("adm", "policy", "add-scc-to-group").Args("privileged", fakeGroup).Execute()).To(o.Succeed())
- o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", fakeUser).Execute()).To(o.Succeed())
- o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", "-z", fakeSA).Execute()).To(o.Succeed())
+ o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", fakeUser, "-z", fakeSA).Execute()).To(o.Succeed())
o.Expect(oc.Run("adm", "policy", "remove-scc-from-group").Args("privileged", fakeGroup).Execute()).To(o.Succeed())Also applies to: 228-230 🤖 Prompt for AI Agents |
||
| out, err = oc.Run("get").Args("clusterrolebinding/system:openshift:scc:privileged", "-o", "yaml").Output() | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| o.Expect(out).To(o.ContainSubstring("fake-user")) | ||
| o.Expect(out).To(o.ContainSubstring("fake-sa")) | ||
| o.Expect(out).To(o.ContainSubstring("fake-group")) | ||
| o.Expect(out).To(o.ContainSubstring(fakeUser)) | ||
| o.Expect(out).To(o.ContainSubstring(fakeSA)) | ||
| o.Expect(out).To(o.ContainSubstring(fakeGroup)) | ||
|
|
||
| o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", "fake-user").Execute()).To(o.Succeed()) | ||
|
tchap marked this conversation as resolved.
|
||
| o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", "-z", "fake-sa").Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "remove-scc-from-group").Args("privileged", "fake-group").Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", fakeUser).Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "remove-scc-from-user").Args("privileged", "-z", fakeSA).Execute()).To(o.Succeed()) | ||
| o.Expect(oc.Run("adm", "policy", "remove-scc-from-group").Args("privileged", fakeGroup).Execute()).To(o.Succeed()) | ||
| out, err = oc.Run("get").Args("clusterrolebinding/system:openshift:scc:privileged", "-o", "yaml").Output() | ||
| // there are two possible outcomes here: | ||
| if err == nil { | ||
| // 1. the binding exists, but it should not contain the removed entities | ||
| o.Expect(out).NotTo(o.ContainSubstring("fake-user")) | ||
| o.Expect(out).NotTo(o.ContainSubstring("fake-sa")) | ||
| o.Expect(out).NotTo(o.ContainSubstring("fake-group")) | ||
| o.Expect(out).NotTo(o.ContainSubstring(fakeUser)) | ||
| o.Expect(out).NotTo(o.ContainSubstring(fakeSA)) | ||
| o.Expect(out).NotTo(o.ContainSubstring(fakeGroup)) | ||
| } else { | ||
| // 2. the binding does not exists, if we removed all entities from the binding | ||
| o.Expect(out).To(o.ContainSubstring(`clusterrolebindings.rbac.authorization.k8s.io "system:openshift:scc:privileged" not found`)) | ||
| } | ||
|
Comment on lines
222
to
241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use These checks read CRB state immediately after add/remove/prune mutations. In multi-master clusters this is eventually consistent and can transiently fail. Suggested change- out, err = oc.Run("get").Args("clusterrolebinding/system:openshift:scc:privileged", "-o", "yaml").Output()
- o.Expect(err).NotTo(o.HaveOccurred())
- o.Expect(out).To(o.ContainSubstring(fakeUser))
- o.Expect(out).To(o.ContainSubstring(fakeSA))
- o.Expect(out).To(o.ContainSubstring(fakeGroup))
+ o.Eventually(func() (string, error) {
+ return oc.Run("get").Args("clusterrolebinding/system:openshift:scc:privileged", "-o", "yaml").Output()
+ }, 30*time.Second, 1*time.Second).Should(o.And(
+ o.ContainSubstring(fakeUser),
+ o.ContainSubstring(fakeSA),
+ o.ContainSubstring(fakeGroup),
+ ))
- out, err = oc.Run("get").Args("clusterrolebinding/system:openshift:scc:privileged", "-o", "yaml").Output()
- // there are two possible outcomes here:
- if err == nil {
- // 1. the binding exists, but it should not contain the removed entities
- o.Expect(out).NotTo(o.ContainSubstring(fakeUser))
- o.Expect(out).NotTo(o.ContainSubstring(fakeSA))
- o.Expect(out).NotTo(o.ContainSubstring(fakeGroup))
- } else {
- // 2. the binding does not exists, if we removed all entities from the binding
- o.Expect(out).To(o.ContainSubstring(`clusterrolebindings.rbac.authorization.k8s.io "system:openshift:scc:privileged" not found`))
- }
+ o.Eventually(func() (string, error) {
+ return oc.Run("get").Args("clusterrolebinding/system:openshift:scc:privileged", "-o", "yaml").Output()
+ }, 30*time.Second, 1*time.Second).Should(o.Or(
+ o.And(
+ o.Not(o.ContainSubstring(fakeUser)),
+ o.Not(o.ContainSubstring(fakeSA)),
+ o.Not(o.ContainSubstring(fakeGroup)),
+ ),
+ o.ContainSubstring(`clusterrolebindings.rbac.authorization.k8s.io "system:openshift:scc:privileged" not found`),
+ ))Also applies to: 244-252 🤖 Prompt for AI Agents |
||
|
|
||
| // check pruning | ||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", "fake-user").Execute()).To(o.Succeed()) | ||
| out, err = oc.Run("adm", "prune", "auth").Args("users/fake-user").Output() | ||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-user").Args("privileged", fakeUser).Execute()).To(o.Succeed()) | ||
| out, err = oc.Run("adm", "prune", "auth").Args(fmt.Sprintf("users/%s", fakeUser)).Output() | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| o.Expect(out).To(o.ContainSubstring("clusterrolebinding.rbac.authorization.k8s.io/system:openshift:scc:privileged updated")) | ||
|
|
||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-group").Args("privileged", "fake-group").Execute()).To(o.Succeed()) | ||
| out, err = oc.Run("adm", "prune", "auth").Args("group/fake-group").Output() | ||
| o.Expect(oc.Run("adm", "policy", "add-scc-to-group").Args("privileged", fakeGroup).Execute()).To(o.Succeed()) | ||
| out, err = oc.Run("adm", "prune", "auth").Args(fmt.Sprintf("group/%s", fakeGroup)).Output() | ||
| o.Expect(err).NotTo(o.HaveOccurred()) | ||
| o.Expect(out).To(o.ContainSubstring("clusterrolebinding.rbac.authorization.k8s.io/system:openshift:scc:privileged updated")) | ||
| }) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to keep the tests we have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it does causes the race, I think, that's why it's being changed. The point of this change is to execute this change in a single
occommand so that it's sent together.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably right to push back on this, because it's not clear why the test is failing very rarely. There is not enough data in the failing job regarding why this happens. It seems the data is written into etcd even though it should return 409, but I don't manage to find information detailed enough in CI jobs to be able to troubleshoot this 😐 So I ended up just trying to improve the test, which is not particularly clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the issue is that the test is not using randomly generated names and there are some leftovers from the previous test run, causing 409 not to happen because the change is actually already there, but I am gonna continue tomorrow. Thanks for pushing back.