HIVE-3133: VWHC for ClusterDeploymentCustomization#2882
HIVE-3133: VWHC for ClusterDeploymentCustomization#2882openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
Conversation
|
@2uasimojo: This pull request references HIVE-3133 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
Deliberately left some stuff out to test the rabbit. |
📝 WalkthroughWalkthroughAdds a new ValidatingWebhookConfiguration for clusterdeploymentcustomizations, embeds its YAML as an operator asset and registers it, adjusts an existing webhook's operations, updates bindata, and augments CI review instructions enforcing manifest ↔ implementation consistency and bindata/registration requirements. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@2uasimojo: This pull request references HIVE-3133 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.coderabbit.yaml:
- Line 51: In the .coderabbit.yaml entry referencing "for
config/hivedamission/*-webhook.yaml, please validate that each has a
corresponding", correct the typo "hivedamission" to "hiveadmission" so the
pattern reads "config/hiveadmission/*-webhook.yaml"; update that string wherever
it appears to ensure the validation targets the intended directory/pattern.
In `@pkg/operator/hive/hiveadmission.go`:
- Line 53: You added
"config/hiveadmission/clusterdeploymentcustomization-webhook.yaml" to
webhookAssets but the embedded asset is missing, causing assets.MustAsset() in
hiveadmission.go to panic at runtime; regenerate the embed by running the
bindata update and commit the change: run make update-bindata (or the project's
equivalent) so pkg/operator/assets/bindata.go includes the new file, verify
assets.MustAsset("config/hiveadmission/clusterdeploymentcustomization-webhook.yaml")
resolves, and re-run tests to ensure no missing-asset panics.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fe11dd9f-f109-4fa9-8f1f-c2c1cc130b11
📒 Files selected for processing (3)
.coderabbit.yamlconfig/hiveadmission/clusterdeploymentcustomization-webhook.yamlpkg/operator/hive/hiveadmission.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2882 +/- ##
==========================================
- Coverage 50.29% 50.28% -0.02%
==========================================
Files 280 280
Lines 34323 34332 +9
==========================================
Hits 17264 17264
- Misses 15698 15707 +9
Partials 1361 1361
🚀 New features to boost your workflow:
|
539bbcc to
f633e20
Compare
|
@coderabbitai Fixed that one. Left another mistake for you. Are you paying attention to .coderabbit.yaml? |
|
@2uasimojo: This pull request references HIVE-3133 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainGood question — let me dig into the codebase to check! 🏁 Script executed: Length of output: 1195 🏁 Script executed: Length of output: 9291 🏁 Script executed: Length of output: 670
In clusterDeploymentCustomizationResource = "clusterdeploymentcustomization"Every other webhook in the same package uses the plural form (as Kubernetes always sends the plural resource name in admission requests):
Because clusterDeploymentCustomizationResource = "clusterdeploymentcustomizations" |
|
/hold We'll need to @coderabbitai Wow, nice find! But that's not the one I was talking about... |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainGood catch on me! Let me dig deeper into the other checklist items from 🏁 Script executed: Length of output: 6354 The operations match (CREATE/UPDATE in both YAML and 🏁 Script executed: Length of output: 932 Bindata is fine too. Let me check whether the webhook handler is actually registered with the admission API server — there's typically a separate place where the Go implementations are wired up to serve requests. 🏁 Script executed: Length of output: 21257 Let me read the full 🏁 Script executed: Length of output: 2985 Found it! Let me verify by checking the 🏁 Script executed: Length of output: 3873
All four checklist items from
But the thing that stands out clearly in the file listing is that Is that the one you were referring to? I should add a check for test file coverage to the (´• ω •`) 🐇💨 |
|
@coderabbitai I did notice that. And yeah, we probably want to address it -- though we can do that later/separately. However, what I was referring to is the fact that the clusterpool vwhc (added via #2879) currently violates the instruction in .coderabbit.yaml to make sure that the |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 4835
The operations:
- CREATE
- UPDATE
- DELETEBut the switch admissionSpec.Operation {
case admissionv1beta1.Create:
return a.validateCreate(admissionSpec)
case admissionv1beta1.Update:
return a.validateUpdate(admissionSpec)
default:
// ← DELETE silently falls here and is just Allowed: true
return &admissionv1beta1.AdmissionResponse{Allowed: true}
}
The fix is to drop rules:
- operations:
- CREATE
- UPDATE
# DELETE removed — no validateDelete implemented |
|
@coderabbitai Good, that's the one. Is there a way I could phrase my .coderabbit.yaml instructions such that you would have caught that right away? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3873
Two complementary fixes would close this gap: 1. Explicitly instruct cross-auditing of the whole directory When a new webhook YAML is being reviewed, ask CodeRabbit to audit all existing ones too, not just the one in the diff: - path: config/hiveadmission/*-webhook.yaml
instructions: |-
...existing checks...
- When any file in this directory is added or modified, also cross-check ALL other
existing *-webhook.yaml files in config/hiveadmission/ to verify their operations
are consistent with their implementations. Do not limit the audit to only the file(s)
in the diff.
- The `Operation`s in `.webhooks[].rules[].operations` must be a strict subset of the
operations handled by explicit `case` branches in the implementation's `Validate()`
switch. A `default: Allowed: true` branch does NOT count as handling an operation.
If an operation appears in the YAML but has no corresponding `case`, flag it.2. Make the "default fallthrough" anti-pattern explicit The original wording says "match" — but I interpreted
→ Replace with:
The combination of "audit the whole directory, not just the diff" + "no implicit default coverage" would have flagged the clusterpool mismatch in this PR even though that file wasn't modified. |
This was missed in openshift#1672. Side quest: Dropping `DELETE` from the ClusterPool VWHC added in openshift#2879. It didn't have functional impact, but would have been wastefully sending Delete requests to our hiveadmission service. Also adding some coderabbit config intended to catch this kind of miss in the future.
f633e20 to
cc7167b
Compare
|
@2uasimojo: This pull request references HIVE-3133 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
@2uasimojo: This pull request references HIVE-3133 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@pkg/validating-webhooks/hive/v1/clusterdeploymentcustomization_validating_admission_hook.go`:
- Line 22: Add a dedicated test file to cover the ClusterDeploymentCustomization
validating webhook: create
clusterdeploymentcustomization_validating_admission_hook_test.go and implement
unit tests that assert shouldValidate() matches the intended
group/version/resource for "clusterdeploymentcustomizations", test CREATE
validation by calling the webhook's Admit/Validate function with a new
ClusterDeploymentCustomization object (both valid and invalid cases), and test
UPDATE validation by invoking the webhook with old and new objects to verify
update-specific logic; reference the shouldValidate() function and the
ClusterDeploymentCustomization validating admission hook methods (e.g.,
Validate/Admit or AdmitFunc) in your tests and mirror patterns used for the
existing clusterdeployment/syncset/dnszone tests for setup, fake clients, and
expected error assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 41fca1fb-ea5e-47ae-a3ee-90ce2e1a6bc3
📒 Files selected for processing (6)
.coderabbit.yamlconfig/hiveadmission/clusterdeploymentcustomization-webhook.yamlconfig/hiveadmission/clusterpool-webhook.yamlpkg/operator/assets/bindata.gopkg/operator/hive/hiveadmission.gopkg/validating-webhooks/hive/v1/clusterdeploymentcustomization_validating_admission_hook.go
💤 Files with no reviewable changes (1)
- config/hiveadmission/clusterpool-webhook.yaml
✅ Files skipped from review due to trivial changes (2)
- pkg/operator/hive/hiveadmission.go
- config/hiveadmission/clusterdeploymentcustomization-webhook.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- .coderabbit.yaml
| clusterDeploymentCustomizationGroup = "hive.openshift.io" | ||
| clusterDeploymentCustomizationVersion = "v1" | ||
| clusterDeploymentCustomizationResource = "clusterdeploymentcustomization" | ||
| clusterDeploymentCustomizationResource = "clusterdeploymentcustomizations" |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "1) Find ClusterDeploymentCustomization validating hook tests"
fd 'clusterdeploymentcustomization.*_test\.go$' pkg || true
echo
echo "2) Find test coverage for this hook/resource/operations"
rg -nP --type=go '(ClusterDeploymentCustomizationValidatingAdmissionHook|clusterdeploymentcustomizations|admissionv1beta1\.(Create|Update))' pkg -g '*_test.go' || trueRepository: openshift/hive
Length of output: 31435
🏁 Script executed:
cat -n pkg/validating-webhooks/hive/v1/clusterdeploymentcustomization_validating_admission_hook.go | head -80Repository: openshift/hive
Length of output: 4442
🏁 Script executed:
find config -name '*clusterdeploymentcustomization*' -o -name '*webhook*' | grep -i customization || echo "No webhook config found for customization"Repository: openshift/hive
Length of output: 189
🏁 Script executed:
rg -l 'clusterdeploymentcustomizations|ClusterDeploymentCustomization' config/ || echo "No matches in config/"Repository: openshift/hive
Length of output: 358
🏁 Script executed:
cat -n pkg/validating-webhooks/hive/v1/clusterdeploymentcustomization_validating_admission_hook.go | tail -100Repository: openshift/hive
Length of output: 4476
🏁 Script executed:
cat -n config/hiveadmission/clusterdeploymentcustomization-webhook.yamlRepository: openshift/hive
Length of output: 982
🏁 Script executed:
rg -n 'ClusterDeploymentCustomization' pkg/ -g 'hiveadmission.go' -A 3 -B 3Repository: openshift/hive
Length of output: 40
🏁 Script executed:
find pkg -name 'hiveadmission.go' -type fRepository: openshift/hive
Length of output: 92
🏁 Script executed:
rg -n 'NewClusterDeploymentCustomization|clusterdeploymentcustomization' pkg/ --type go -i | grep -i admissionRepository: openshift/hive
Length of output: 8251
🏁 Script executed:
rg -A 10 -B 5 'clusterdeploymentcustomization-webhook.yaml' pkg/operator/hive/hiveadmission.goRepository: openshift/hive
Length of output: 835
Add dedicated test file for ClusterDeploymentCustomization validating webhook.
This hook lacks regression tests despite other similar hooks (clusterdeployment, syncset, dnszone, etc.) having comprehensive test coverage. Create a clusterdeploymentcustomization_validating_admission_hook_test.go to cover:
- Resource matching via
shouldValidate()(group, version, resource) - CREATE operation validation
- UPDATE operation validation with old/new object handling
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@pkg/validating-webhooks/hive/v1/clusterdeploymentcustomization_validating_admission_hook.go`
at line 22, Add a dedicated test file to cover the
ClusterDeploymentCustomization validating webhook: create
clusterdeploymentcustomization_validating_admission_hook_test.go and implement
unit tests that assert shouldValidate() matches the intended
group/version/resource for "clusterdeploymentcustomizations", test CREATE
validation by calling the webhook's Admit/Validate function with a new
ClusterDeploymentCustomization object (both valid and invalid cases), and test
UPDATE validation by invoking the webhook with old and new objects to verify
update-specific logic; reference the shouldValidate() function and the
ClusterDeploymentCustomization validating admission hook methods (e.g.,
Validate/Admit or AdmitFunc) in your tests and mirror patterns used for the
existing clusterdeployment/syncset/dnszone tests for setup, fake clients, and
expected error assertions.
|
/retest |
|
Caution There are some errors in your PipelineRun template.
|
|
@2uasimojo: This pull request references HIVE-3133 which is a valid jira issue. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 2uasimojo, dlom The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
|
@2uasimojo: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
This was missed in #1672.
Side quest: Dropping
DELETEfrom the ClusterPool VWHC added in #2879. It didn't have functional impact, but would have been wastefully sending Delete requests to our hiveadmission service.Also adding some coderabbit config intended to catch this kind of miss in the future.
Summary by CodeRabbit