diff --git a/pkg/admission/machinedeployments.go b/pkg/admission/machinedeployments.go index ec3d9f5cb..62da6cc00 100644 --- a/pkg/admission/machinedeployments.go +++ b/pkg/admission/machinedeployments.go @@ -55,6 +55,10 @@ func (ad *admissionData) mutateMachineDeployments(ctx context.Context, ar admiss if err := json.Unmarshal(ar.OldObject.Raw, &oldMachineDeployment); err != nil { return nil, fmt.Errorf("failed to unmarshal OldObject: %w", err) } + if oldMachineDeployment.ResourceVersion != machineDeployment.ResourceVersion { + // resource version conflict. Return success to fall back to the API server's default handler, which will respond with a proper 409 + return createAdmissionResponse(log, machineDeploymentOriginal, &machineDeployment) + } if equal := apiequality.Semantic.DeepEqual(oldMachineDeployment.Spec.Template.Spec, machineDeployment.Spec.Template.Spec); equal { machineSpecNeedsValidation = false } diff --git a/pkg/admission/machines.go b/pkg/admission/machines.go index 50f81dd4c..6b9a2076c 100644 --- a/pkg/admission/machines.go +++ b/pkg/admission/machines.go @@ -62,6 +62,10 @@ func (ad *admissionData) mutateMachines(ctx context.Context, ar admissionv1.Admi if err := json.Unmarshal(ar.OldObject.Raw, &oldMachine); err != nil { return nil, fmt.Errorf("failed to unmarshal OldObject: %w", err) } + if oldMachine.ResourceVersion != machine.ResourceVersion { + // resource version conflict. Return success to fall back to the API server's default handler, which will respond with a proper 409 + return createAdmissionResponse(log, machineOriginal, &machine) + } if oldMachine.Spec.Name != machine.Spec.Name && machine.Spec.Name == machine.Name { oldMachine.Spec.Name = machine.Spec.Name }