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
Remove the CEL validation on VSphereMachineTemplate.spec.network
When the Cluster API topology controller does a dry-run patch on
the VSphereMachineTemplate to figure out if there are changes to
apply, it fails with below error:
server side apply dry-run failed for modified object:
VSphereMachineTemplate.vmware.infrastructure.cluster.x-k8s.io
"guestcluster1-rhhvs" is invalid: spec.template.spec: Invalid value:
"object": field ''network'' cannot be added or removed after
creation
Move diff validation on VSphereMachineTemplate spec to Webhook and
Skip validation if it 's triggerd by server side dry-run.
Copy file name to clipboardExpand all lines: apis/vmware/v1beta1/vspheremachine_types.go
-3Lines changed: 0 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,6 @@ type VSphereMachineVolume struct {
38
38
}
39
39
40
40
// VSphereMachineSpec defines the desired state of VSphereMachine.
41
-
// +kubebuilder:validation:XValidation:rule="has(self.network) == has(oldSelf.network)",message="field 'network' cannot be added or removed after creation"
42
41
typeVSphereMachineSpecstruct {
43
42
// ProviderID is the virtual machine's BIOS UUID formatted as
@@ -102,7 +101,6 @@ type VSphereMachineSpec struct {
102
101
}
103
102
104
103
// VSphereMachineNetworkSpec defines the network configuration of a VSphereMachine.
105
-
// +kubebuilder:validation:XValidation:rule="has(self.interfaces) == has(oldSelf.interfaces)",message="field 'interfaces' cannot be added or removed after creation"
106
104
// +kubebuilder:validation:MinProperties=1
107
105
typeVSphereMachineNetworkSpecstruct {
108
106
// interfaces is the list of network interfaces attached to this VSphereMachine.
// InterfacesSpec defines all the network interfaces of a VSphereMachine from Kubernetes perspective.
120
-
// +kubebuilder:validation:XValidation:rule="has(self.primary) == has(oldSelf.primary)",message="field 'primary' cannot be added or removed after creation"
returnnil, apierrors.NewBadRequest(fmt.Sprintf("failed to compare old and new VSphereMachineTemplate: %v", err))
83
+
}
84
+
if!equal {
85
+
returnnil, field.Invalid(field.NewPath("spec", "template", "spec"), newObj, fmt.Sprintf("VSphereMachineTemplate spec.template.spec field is immutable. Please create a new resource instead. Diff: %s", diff))
wantError: `error diffing objects: cannot handle unexported field at root.a:
73
+
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/util".(struct { a int; b int; c int })
74
+
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported`,
0 commit comments