diff --git a/hack/tools/vendor/sigs.k8s.io/cluster-api-provider-openstack/pkg/webhooks/openstackmachine_webhook.go b/hack/tools/vendor/sigs.k8s.io/cluster-api-provider-openstack/pkg/webhooks/openstackmachine_webhook.go index 601fef6473..cef0e24eb7 100644 --- a/hack/tools/vendor/sigs.k8s.io/cluster-api-provider-openstack/pkg/webhooks/openstackmachine_webhook.go +++ b/hack/tools/vendor/sigs.k8s.io/cluster-api-provider-openstack/pkg/webhooks/openstackmachine_webhook.go @@ -97,17 +97,13 @@ func (*openStackMachineWebhook) ValidateUpdate(_ context.Context, oldObjRaw, new newOpenStackMachineSpec := newOpenStackMachine["spec"].(map[string]interface{}) oldOpenStackMachineSpec := oldOpenStackMachine["spec"].(map[string]interface{}) - // allow changes to providerID once - if oldOpenStackMachineSpec["providerID"] == nil { - delete(oldOpenStackMachineSpec, "providerID") - delete(newOpenStackMachineSpec, "providerID") - } + // allow changes to providerID (matches AWS, GCP, VSphere providers) + delete(oldOpenStackMachineSpec, "providerID") + delete(newOpenStackMachineSpec, "providerID") - // allow changes to instanceID once - if oldOpenStackMachineSpec["instanceID"] == nil { - delete(oldOpenStackMachineSpec, "instanceID") - delete(newOpenStackMachineSpec, "instanceID") - } + // allow changes to instanceID (matches AWS, GCP, VSphere providers) + delete(oldOpenStackMachineSpec, "instanceID") + delete(newOpenStackMachineSpec, "instanceID") // allow changes to identifyRef delete(oldOpenStackMachineSpec, "identityRef") diff --git a/pkg/webhooks/openstackmachine_webhook.go b/pkg/webhooks/openstackmachine_webhook.go index 601fef6473..cef0e24eb7 100644 --- a/pkg/webhooks/openstackmachine_webhook.go +++ b/pkg/webhooks/openstackmachine_webhook.go @@ -97,17 +97,13 @@ func (*openStackMachineWebhook) ValidateUpdate(_ context.Context, oldObjRaw, new newOpenStackMachineSpec := newOpenStackMachine["spec"].(map[string]interface{}) oldOpenStackMachineSpec := oldOpenStackMachine["spec"].(map[string]interface{}) - // allow changes to providerID once - if oldOpenStackMachineSpec["providerID"] == nil { - delete(oldOpenStackMachineSpec, "providerID") - delete(newOpenStackMachineSpec, "providerID") - } + // allow changes to providerID (matches AWS, GCP, VSphere providers) + delete(oldOpenStackMachineSpec, "providerID") + delete(newOpenStackMachineSpec, "providerID") - // allow changes to instanceID once - if oldOpenStackMachineSpec["instanceID"] == nil { - delete(oldOpenStackMachineSpec, "instanceID") - delete(newOpenStackMachineSpec, "instanceID") - } + // allow changes to instanceID (matches AWS, GCP, VSphere providers) + delete(oldOpenStackMachineSpec, "instanceID") + delete(newOpenStackMachineSpec, "instanceID") // allow changes to identifyRef delete(oldOpenStackMachineSpec, "identityRef") diff --git a/test/e2e/suites/apivalidations/openstackmachine_test.go b/test/e2e/suites/apivalidations/openstackmachine_test.go index 28af1cf80f..d2db5dab4a 100644 --- a/test/e2e/suites/apivalidations/openstackmachine_test.go +++ b/test/e2e/suites/apivalidations/openstackmachine_test.go @@ -60,7 +60,7 @@ var _ = Describe("OpenStackMachine API validations", func() { Expect(k8sClient.Create(ctx, machine)).To(Succeed(), "OpenStackMachine creation with spec.identityRef should succeed") }) - It("should only allow the providerID to be set once", func() { + It("should allow the providerID to be updated", func() { machine := defaultMachine() By("Creating a bare machine") @@ -72,7 +72,7 @@ var _ = Describe("OpenStackMachine API validations", func() { By("Modifying the providerID") machine.Spec.ProviderID = ptr.To("bar") - Expect(k8sClient.Update(ctx, machine)).NotTo(Succeed(), "Updating providerID should fail") + Expect(k8sClient.Update(ctx, machine)).To(Succeed(), "Updating providerID should succeed") }) It("should allow the identityRef to be set several times", func() {