-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Scope ValidatingAdmissionPolicy in DRA e2e tests more narrowly #129514
base: master
Are you sure you want to change the base?
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nojnhuh The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
objectSelector: | ||
matchExpressions: | ||
- key: vap-enforced | ||
operator: Exists |
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.
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.
So the idea is that this VAP only applies to claims and claim templates which opt into using it. I can see how this works for E2E testing.
But it's not something that admins should do for real, so this would need more comments along the lines of "don't do this when setting up admin access in your cluster".
Given that we probably will have a different enforcement mechanism for admin access (kubernetes/enhancements#5018), let's perhaps put this PR on hold for now?
validations: | ||
- expression: '! object.spec.devices.requests.exists(e, has(e.adminAccess) && e.adminAccess)' | ||
reason: Forbidden | ||
messageExpression: '"admin access to devices not enabled"' # in namespace " + object.metadata.namespace' - need to use __namespace__, but somehow that also doesn't work. | ||
messageExpression: '"admin access to devices not enabled in namespace " + namespaceObject.metadata.name' |
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.
This isn't related to the flake fix, but this seemed like a TODO
that I happened to figure out along the way.
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.
Might be worth a separate PR, but I'm also okay with a drive-by change here.
Have you figured out why object.metadata.namespace
or (because of the reserved name?) object.metadata.__namespace__
didn't work?
I didn't know that namespaceObject
exists. It's not described in https://kubernetes.io/docs/reference/using-api/cel/. Where did you learn about it? Should it be in the reference docs?
/cc @jpbetz
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 found namespaceObject
in the reference docs for this particular field, though the website renders the list unfortunately: https://kubernetes.io/docs/reference/kubernetes-api/policy-resources/validating-admission-policy-v1/#:~:text=%2D%20%27namespaceObject%27%20%2D%20The%20namespace%20object%20that%20the%20incoming%20object%20belongs%20to.%20The%20value%20is%20null%20for%20cluster%2Dscoped%20resources. It's easier to read the code comment itself:
// - 'namespaceObject' - The namespace object that the incoming object belongs to. The value is null for cluster-scoped resources. |
Elsewhere in that comment it explains why object.metadata.namespace
doesn't work I think:
kubernetes/staging/src/k8s.io/api/admissionregistration/v1/types.go
Lines 326 to 327 in d944121
// The `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the | |
// object. No other metadata properties are accessible. |
And the way I'm reading it, object.__namespace__
is a hypothetical example not related to an object's metadata.namespace
. Still not exactly sure what a "property" means in this context though:
// - Expression accessing a property named "namespace": {"Expression": "object.__namespace__ > 0"} |
I'll split this out into a separate PR since we might be holding out on the rest of these changes for a bit while we iterate on the admin access KEP.
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 opened #129530 for these changes and removed them from this PR.
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.
So it is part of the VAP API. I had not looked there before.
kubernetes/staging/src/k8s.io/api/admissionregistration/v1/types.go
Lines 326 to 327 in d944121
// The `apiVersion`, `kind`, `metadata.name` and `metadata.generateName` are always accessible from the root of the | |
// object. No other metadata properties are accessible. |
looks like the right explanation: there is an explicit allow list for fields in
ObjectMeta
, and namespace
is not included - for whatever reason.
/cc @bart0sh |
What type of PR is this?
/kind bug
/kind flake
What this PR does / why we need it:
This PR fixes a flake in the DRA e2e tests where a ValidatingAdmissionPolicy used for one test is interfering with the creation of a ResourceClaimTemplate in an unrelated test when both happen to run in parallel at about the same time.
Which issue(s) this PR fixes:
Fixes #128493
Special notes for your reviewer:
Before this PR, I got the test to fail reliably with the following changes:
and running the e2e tests with the following command, where the only interesting part is
-ginkgo.focus='admin access'
:Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: