diff --git a/pkg/driver/driver_azure.go b/pkg/driver/driver_azure.go index ea73893bf..9e49a5ebb 100644 --- a/pkg/driver/driver_azure.go +++ b/pkg/driver/driver_azure.go @@ -89,7 +89,7 @@ func (d *AzureDriver) Create() (string, string, error) { Name: &nicName, InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{ PrivateIPAllocationMethod: network.Dynamic, - Subnet: &subnet, + Subnet: &subnet, }, }, }, @@ -218,13 +218,24 @@ func (d *AzureDriver) Delete() error { listOfResources := make(map[string]string) d.getvms(d.MachineID, listOfResources) if len(listOfResources) != 0 { - _, errChan := vmClient.Delete(resourceGroup, vmName, cancel) + + _, errChan := vmClient.PowerOff(resourceGroup, vmName, cancel) + err = onErrorFail(<-errChan, fmt.Sprintf("vmClient.PowerOff failed for '%s'", vmName)) + if err != nil { + return err + } + glog.V(2).Infof("VM poweroff was successful for %s", vmName) + + _, errChan = vmClient.Delete(resourceGroup, vmName, cancel) err = onErrorFail(<-errChan, fmt.Sprintf("vmClient.Delete failed for '%s'", vmName)) if err != nil { return err } + glog.V(2).Infof("VM deletion was successful for %s", vmName) + + } else { + glog.Warningf("VM was not found for %s", vmName) } - glog.V(3).Infof("Deleted VM %s", vmName) listOfResources = make(map[string]string) d.getnics(d.MachineID, listOfResources) @@ -234,8 +245,10 @@ func (d *AzureDriver) Delete() error { if err != nil { return err } + glog.V(2).Infof("NIC deletion was successful for %s", vmName) + } else { + glog.Warningf("NIC was not found for %s", vmName) } - glog.V(3).Infof("Deleted NIC %s", nicName) listOfResources = make(map[string]string) d.getdisks(d.MachineID, listOfResources) @@ -245,8 +258,10 @@ func (d *AzureDriver) Delete() error { if err != nil { return err } + glog.V(2).Infof("OS-Disk deletion was successful for %s", vmName) + } else { + glog.Warningf("OS-Disk was not found for %s", vmName) } - glog.V(3).Infof("Deleted OS-Disk %s", nicName) return err }