Skip to content

Commit

Permalink
refactor(core): add replace expressions for validating admission poli…
Browse files Browse the repository at this point in the history
…cy patch (#489)

add replace expressions for validating admission policy patch

Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat authored Nov 2, 2024
1 parent a8be806 commit 41c916f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/pkg/virt-operator/resource/generate/components/validatingadmissionpolicy.go b/pkg/virt-operator/resource/generate/components/validatingadmissionpolicy.go
index 5fefec2304..20914e8bf6 100644
--- a/pkg/virt-operator/resource/generate/components/validatingadmissionpolicy.go
+++ b/pkg/virt-operator/resource/generate/components/validatingadmissionpolicy.go
@@ -117,7 +117,7 @@ func NewHandlerV1ValidatingAdmissionPolicy(virtHandlerServiceAccount string) *ad
Variables: []admissionregistrationv1.Variable{
{
Name: "oldNonKubevirtLabels",
- Expression: `oldObject.metadata.labels.filter(k, !k.contains("kubevirt.io") && k != "cpumanager")`,
+ Expression: `oldObject.metadata.labels.filter(k, !k.contains("kubevirt") && k != "cpumanager")`,
},
{
Name: "oldLabels",
@@ -125,7 +125,7 @@ func NewHandlerV1ValidatingAdmissionPolicy(virtHandlerServiceAccount string) *ad
},
{
Name: "newNonKubevirtLabels",
- Expression: `object.metadata.labels.filter(k, !k.contains("kubevirt.io") && k != "cpumanager")`,
+ Expression: `object.metadata.labels.filter(k, !k.contains("kubevirt") && k != "cpumanager")`,
},
{
Name: "newLabels",
@@ -133,11 +133,11 @@ func NewHandlerV1ValidatingAdmissionPolicy(virtHandlerServiceAccount string) *ad
},
{
Name: "oldNonKubevirtAnnotations",
- Expression: `oldObject.metadata.annotations.filter(k, !k.contains("kubevirt.io"))`,
+ Expression: `oldObject.metadata.annotations.filter(k, !k.contains("kubevirt"))`,
},
{
Name: "newNonKubevirtAnnotations",
- Expression: `object.metadata.annotations.filter(k, !k.contains("kubevirt.io"))`,
+ Expression: `object.metadata.annotations.filter(k, !k.contains("kubevirt"))`,
},
{
Name: "oldAnnotations",
5 changes: 5 additions & 0 deletions images/virt-artifact/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ Cleanup stale Pods owned by the VMI, keep only last 3 in the Failed phase.
Why we need it?

Unsuccessful migrations may leave a lot of Pods. These huge lists reduce performance on virtualization-controller and cdi-deployment restarts.

#### `023-replace-expressions-for-validating-admission-policy.patch`

Replace the expressions for the ValidatingAdmissionPolicy kubevirt-node-restriction-policy.
This is necessary because of the kube-api-rewriter that changes the labels.

0 comments on commit 41c916f

Please sign in to comment.