Skip to content

Commit

Permalink
Merge pull request #68 from prashanth26/bugfix/drain-fix
Browse files Browse the repository at this point in the history
Bugfix: Draining issue and Azure error handling
  • Loading branch information
prashanth26 authored Apr 19, 2018
2 parents 9d97573 + a4e1c53 commit 21a059b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,9 @@ func (c *controller) updateMachineStatus(
if err != nil {
// Keep retrying until update goes through
glog.V(3).Infof("Warning: Updated failed, retrying, error: %q", err)
c.updateMachineStatus(machine, lastOperation, currentStatus)
return c.updateMachineStatus(machine, lastOperation, currentStatus)
}
return machine, nil
return clone, nil
}

func (c *controller) updateMachineConditions(machine *v1alpha1.Machine, conditions []v1.NodeCondition) *v1alpha1.Machine {
Expand Down
20 changes: 18 additions & 2 deletions pkg/driver/driver_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ func (d *AzureDriver) Create() (string, string, error) {
"",
)
err = onErrorFail(err, fmt.Sprintf("subnetClient.Get failed for subnet %q", subnet.Name))
if err != nil {
return "Error", "Error", err
}

enableIPForwarding := true
nicParameters := network.Interface{
Expand All @@ -94,11 +97,20 @@ func (d *AzureDriver) Create() (string, string, error) {
},
Tags: &tagList,
}
cancel := make(chan struct{})

var cancel chan struct{}

_, errChan := interfacesClient.CreateOrUpdate(resourceGroup, nicName, nicParameters, cancel)
err = onErrorFail(<-errChan, fmt.Sprintf("interfacesClient.CreateOrUpdate for NIC '%s' failed", nicName))
if err != nil {
return "Error", "Error", err
}

nicParameters, err = interfacesClient.Get(resourceGroup, nicName, "")
err = onErrorFail(err, fmt.Sprintf("interfaces.Get for NIC '%s' failed", nicName))
if err != nil {
return "Error", "Error", err
}

vm := compute.VirtualMachine{
Location: &location,
Expand Down Expand Up @@ -155,9 +167,13 @@ func (d *AzureDriver) Create() (string, string, error) {
},
Tags: &tagList,
}

cancel = nil
_, errChan = vmClient.CreateOrUpdate(resourceGroup, vmName, vm, cancel)
err = onErrorFail(<-errChan, "createVM failed")
//glog.Infof("Created machine '%s' successfully\n", vmName)
if err != nil {
return "Error", "Error", err
}

return d.encodeMachineID(location, vmName), vmName, err
}
Expand Down

0 comments on commit 21a059b

Please sign in to comment.