-
Notifications
You must be signed in to change notification settings - Fork 499
OCPBUGS-87991: validate additionalNetworks name format in KubeVirt NodePools #8710
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
Open
chdeshpa-hue
wants to merge
1
commit into
openshift:main
Choose a base branch
from
chdeshpa-hue:OCPBUGS-87991-kubevirt-validate-additional-networks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
269 changes: 269 additions & 0 deletions
269
...operator/tests/nodepools.hypershift.openshift.io/stable.nodepools.kubevirt.testsuite.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,269 @@ | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| name: "NodePool KubeVirt additionalNetworks validation" | ||
| crdName: nodepools.hypershift.openshift.io | ||
| version: v1beta1 | ||
| tests: | ||
| onCreate: | ||
| # --- additionalNetworks name format validation --- | ||
| - name: when additionalNetworks name is valid namespace/name format it should pass | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "my-ns/my-nad" | ||
| type: KubeVirt | ||
|
|
||
| - name: when additionalNetworks has multiple valid networks it should pass | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "ns-a/nad-1" | ||
| - name: "ns-b/nad-2" | ||
| type: KubeVirt | ||
|
|
||
| - name: when additionalNetworks name has no slash it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "just-a-name" | ||
| type: KubeVirt | ||
| expectedError: "name must be in the format <namespace>/<name> to reference a multus network attachment definition" | ||
|
|
||
| - name: when additionalNetworks name has multiple slashes it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "ns/sub/name" | ||
| type: KubeVirt | ||
| expectedError: "name must be in the format <namespace>/<name> to reference a multus network attachment definition" | ||
|
|
||
| - name: when additionalNetworks name has empty namespace it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "/my-nad" | ||
| type: KubeVirt | ||
| expectedError: "name must be in the format <namespace>/<name> to reference a multus network attachment definition" | ||
|
|
||
| - name: when additionalNetworks name has empty name segment it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "my-ns/" | ||
| type: KubeVirt | ||
| expectedError: "name must be in the format <namespace>/<name> to reference a multus network attachment definition" | ||
|
|
||
| - name: when additionalNetworks name has whitespace in namespace it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: " /name" | ||
| type: KubeVirt | ||
| expectedError: "name must be in the format <namespace>/<name> to reference a multus network attachment definition" | ||
|
|
||
| - name: when additionalNetworks name has whitespace in name segment it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "my-ns/my nad" | ||
| type: KubeVirt | ||
| expectedError: "name must be in the format <namespace>/<name> to reference a multus network attachment definition" | ||
|
|
||
| - name: when additionalNetworks has duplicate names it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "ns/nad1" | ||
| - name: "ns/nad1" | ||
| type: KubeVirt | ||
| expectedError: "Duplicate value" | ||
|
|
||
| - name: when additionalNetworks name is at max length 55 it should pass | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "my-namespace-name-that-is-long/my-nad-name-also-long-ab" | ||
| type: KubeVirt | ||
|
|
||
| - name: when additionalNetworks name exceeds max length 55 it should fail | ||
| initial: | | ||
| apiVersion: hypershift.openshift.io/v1beta1 | ||
| kind: NodePool | ||
| spec: | ||
| arch: amd64 | ||
| clusterName: some-cluster | ||
| management: | ||
| autoRepair: false | ||
| upgradeType: Replace | ||
| release: | ||
| image: quay.io/openshift-release-dev/ocp-release:4.17.0-rc.0-x86_64 | ||
| replicas: 0 | ||
| platform: | ||
| kubevirt: | ||
| rootVolume: | ||
| type: Persistent | ||
| persistent: | ||
| size: 32Gi | ||
| additionalNetworks: | ||
| - name: "my-namespace-name-that-is-long/my-nad-name-also-long-abc" | ||
| type: KubeVirt | ||
| expectedError: "Too long" |
9 changes: 8 additions & 1 deletion
9
...ts/crds/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Add envtest coverage for the new CEL/list-map validation contract.
This introduces admission-time validation behavior (
XValidation) and schema semantics (listType=map/listMapKey=name), but no corresponding envtest evidence is present in the provided changes.As per coding guidelines, "All API CEL validations must be covered with envtests, see test/envtest/README.md for details."
🤖 Prompt for AI Agents
Source: Coding guidelines