You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
message: "Cannot modify a Cluster API controlled label except to match the Cluster API mirrored machine. This is because status.authoritativeAPI is set to Cluster API."
280
+
message: "Cannot modify a Cluster API controlled label except to match the Cluster API mirrored MachineSet. This is because status.authoritativeAPI is set to Cluster API."
281
281
---
282
282
apiVersion: admissionregistration.k8s.io/v1
283
283
kind: ValidatingAdmissionPolicyBinding
@@ -391,6 +391,113 @@ data:
391
391
message: "Setting the 'machine-template-hash' label is forbidden.'"
message: "Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label. This is because status.authoritativeAPI is set to Machine API."
476
+
477
+
# Guard machine.openshift.io/* and cluster.x-k8s.io/* and clusters.x-k8s.io/* annotations
message: "Cannot add, modify or delete any machine.openshift.io/* or cluster.x-k8s.io or clusters.x-k8s.io annotation. This is because status.authoritativeAPI is set to Machine API."
490
+
491
+
# Param-controlled labels (labels on the MAPI machine) may change only to match the value on the MAPI Machine
message: "Cannot modify a Machine API controlled label except to match the Machine API mirrored MachineSet. This is because status.authoritativeAPI is set to Machine API."
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label")))
736
+
})
737
+
738
+
It("rejects deletion of the protected machine.openshift.io label", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label")))
742
+
})
743
+
744
+
It("rejects setting of the protected machine.openshift.io label to the empty string ''", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label")))
748
+
})
749
+
750
+
It("rejects adding a new machine.openshift.io label", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label")))
754
+
})
755
+
756
+
It("rejects adding a new machine.openshift.io label with an empty string value", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label")))
760
+
})
761
+
762
+
It("rejects modification of the protected cluster.x-k8s.io label", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label")))
766
+
})
767
+
768
+
It("rejects deletion of the protected cluster.x-k8s.io label", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/*, kubernetes.io/* or cluster.x-k8s.io/* label")))
772
+
})
773
+
774
+
It("allows modification of a non-protected label", func() {
775
+
Eventually(k.Update(capiMachineSet, func() {
776
+
capiMachineSet.Labels["test"] ="val"
777
+
}), timeout).Should(Succeed(), "expected success when modifying unrelated labels")
778
+
})
779
+
})
780
+
781
+
Context("when trying to update metadata.Annotations", func() {
782
+
It("rejects modification of a protected machine.openshift.io annotation", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/* or cluster.x-k8s.io or clusters.x-k8s.io annotation")))
786
+
})
787
+
788
+
It("rejects deletion of a protected machine.openshift.io annotation", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/* or cluster.x-k8s.io or clusters.x-k8s.io annotation")))
792
+
})
793
+
794
+
It("rejects modification of a protected machine.openshift.io annotation to the empty string ''", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/* or cluster.x-k8s.io or clusters.x-k8s.io annotation")))
798
+
})
799
+
800
+
It("rejects adding a new protected machine.openshift.io annotation", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/* or cluster.x-k8s.io or clusters.x-k8s.io annotation")))
804
+
})
805
+
806
+
It("rejects adding a new protected machine.openshift.io annotation with an empty string value", func() {
}), timeout).Should(MatchError(ContainSubstring("Cannot add, modify or delete any machine.openshift.io/* or cluster.x-k8s.io or clusters.x-k8s.io annotation")))
810
+
})
811
+
812
+
It("allows modification of a non-protected annotation", func() {
813
+
Eventually(k.Update(capiMachineSet, func() {
814
+
capiMachineSet.Annotations["bar"] ="baz"
815
+
}), timeout).Should(Succeed(), "expected success when modifying unrelated annotations")
816
+
})
817
+
})
818
+
819
+
Context("when trying to update Machine API owned metadata.labels", func() {
820
+
It("allows changing a metadata label to match the param MachineSet", func() {
0 commit comments