Skip to content

Commit

Permalink
Remove failed provisioning VM deletion logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalle committed Nov 23, 2020
1 parent 8e70ad6 commit 8f3dd96
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 17 deletions.
6 changes: 0 additions & 6 deletions controllers/azuremachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,6 @@ func (r *AzureMachineReconciler) reconcileNormal(ctx context.Context, machineSco
machineScope.SetFailureMessage(errors.Errorf("Azure VM state is %s", machineScope.VMState()))
conditions.MarkFalse(machineScope.AzureMachine, infrav1.VMRunningCondition, infrav1.VMProvisionFailedReason, clusterv1.ConditionSeverityWarning, "")
machineScope.SetNotReady()
// If VM failed provisioning, delete it so it can be recreated
err := ams.DeleteVM(ctx)
if err != nil {
return reconcile.Result{}, errors.Wrapf(err, "failed to delete VM in a failed state")
}
return reconcile.Result{}, errors.Wrapf(err, "VM deleted, retry creating in next reconcile")
default:
machineScope.V(2).Info("VM state is undefined", "id", machineScope.GetVMID())
conditions.MarkUnknown(machineScope.AzureMachine, infrav1.VMRunningCondition, "", "")
Expand Down
12 changes: 1 addition & 11 deletions controllers/azuremachine_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"

"sigs.k8s.io/cluster-api-provider-azure/cloud/services/tags"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"

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

return nil
}

// Delete deletes the VM and its disk so it can be replaced.
func (s *azureMachineService) DeleteVM(ctx context.Context) error {
if err := s.virtualMachinesSvc.Delete(ctx); err != nil {
return errors.Wrapf(err, "failed to delete machine")
}
if err := s.disksSvc.Delete(ctx); err != nil {
return errors.Wrap(err, "failed to delete OS disk")
}
return nil
}

0 comments on commit 8f3dd96

Please sign in to comment.