fix: validate container env var names in PodCliqueSet webhook#470
Merged
shmuel-runai merged 1 commit intoMar 8, 2026
Merged
Conversation
85b39b7 to
2123b8e
Compare
Ronkahn21
reviewed
Mar 5, 2026
There was a problem hiding this comment.
Pull request overview
Extends the PodCliqueSet admission webhook validation to reject invalid and duplicate container environment variable names at admission time, and adjusts the shared uniqueness validator to report duplicates using Kubernetes’ ErrorTypeDuplicate.
Changes:
- Add env var name + duplicate checks for
spec.containers[].envandspec.initContainers[].envin PCS validation. - Update
sliceMustHaveUniqueElementsto returnfield.ErrorTypeDuplicate(viafield.Duplicate) and update call sites. - Add/adjust unit tests for env var validation and duplicate error typing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| operator/internal/webhook/admission/pcs/validation/util.go | Changes uniqueness helper to emit Duplicate errors. |
| operator/internal/webhook/admission/pcs/validation/util_test.go | Updates tests for new duplicate error type (but currently under-asserts). |
| operator/internal/webhook/admission/pcs/validation/podcliqueset.go | Adds container env var validation (invalid names + duplicates). |
| operator/internal/webhook/admission/pcs/validation/podcliqueset_test.go | Adds env var validation test coverage for containers/initContainers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2123b8e to
5fcdd28
Compare
Extend the PodCliqueSet admission webhook to catch invalid and duplicate environment variable names at admission time rather than at pod runtime. Also corrects sliceMustHaveUniqueElements to emit ErrorTypeDuplicate instead of ErrorTypeInvalid. Tested: * UT Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5fcdd28 to
6c7ff75
Compare
Ronkahn21
approved these changes
Mar 5, 2026
shayasoolin
approved these changes
Mar 8, 2026
shayasoolin
left a comment
Contributor
There was a problem hiding this comment.
These validations can be implemented on the CRD itself as CEL validations. I think we should consider switching to this validation type, it spares the need for implementing all this logic.
Ronkahn21
pushed a commit
to Ronkahn21/grove
that referenced
this pull request
Mar 10, 2026
…amo#470) Extend the PodCliqueSet admission webhook to catch invalid and duplicate environment variable names at admission time rather than at pod runtime. Also corrects sliceMustHaveUniqueElements to emit ErrorTypeDuplicate instead of ErrorTypeInvalid. Tested: * UT
enoodle
pushed a commit
to enoodle/grove
that referenced
this pull request
Mar 24, 2026
…amo#470) Extend the PodCliqueSet admission webhook to catch invalid and duplicate environment variable names at admission time rather than at pod runtime. Also corrects sliceMustHaveUniqueElements to emit ErrorTypeDuplicate instead of ErrorTypeInvalid. Tested: * UT Signed-off-by: Erez Freiberger <enoodle@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind bug
What this PR does / why we need it:
Extend the PodCliqueSet admission webhook to catch invalid and duplicate environment variable names at admission time rather than at pod runtime.
Also corrects sliceMustHaveUniqueElements to emit ErrorTypeDuplicate instead of ErrorTypeInvalid.
Tested:
Fixes #240