Skip to content

Commit 8f3dd96

Browse files
committed
Remove failed provisioning VM deletion logic
1 parent 8e70ad6 commit 8f3dd96

2 files changed

Lines changed: 1 addition & 17 deletions

File tree

controllers/azuremachine_controller.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,6 @@ func (r *AzureMachineReconciler) reconcileNormal(ctx context.Context, machineSco
309309
machineScope.SetFailureMessage(errors.Errorf("Azure VM state is %s", machineScope.VMState()))
310310
conditions.MarkFalse(machineScope.AzureMachine, infrav1.VMRunningCondition, infrav1.VMProvisionFailedReason, clusterv1.ConditionSeverityWarning, "")
311311
machineScope.SetNotReady()
312-
// If VM failed provisioning, delete it so it can be recreated
313-
err := ams.DeleteVM(ctx)
314-
if err != nil {
315-
return reconcile.Result{}, errors.Wrapf(err, "failed to delete VM in a failed state")
316-
}
317-
return reconcile.Result{}, errors.Wrapf(err, "VM deleted, retry creating in next reconcile")
318312
default:
319313
machineScope.V(2).Info("VM state is undefined", "id", machineScope.GetVMID())
320314
conditions.MarkUnknown(machineScope.AzureMachine, infrav1.VMRunningCondition, "", "")

controllers/azuremachine_reconciler.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
2122
"sigs.k8s.io/cluster-api-provider-azure/cloud/services/tags"
2223
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
2324

@@ -121,14 +122,3 @@ func (s *azureMachineService) Delete(ctx context.Context) error {
121122

122123
return nil
123124
}
124-
125-
// Delete deletes the VM and its disk so it can be replaced.
126-
func (s *azureMachineService) DeleteVM(ctx context.Context) error {
127-
if err := s.virtualMachinesSvc.Delete(ctx); err != nil {
128-
return errors.Wrapf(err, "failed to delete machine")
129-
}
130-
if err := s.disksSvc.Delete(ctx); err != nil {
131-
return errors.Wrap(err, "failed to delete OS disk")
132-
}
133-
return nil
134-
}

0 commit comments

Comments
 (0)