Skip to content

Commit 21a059b

Browse files
authored
Merge pull request #68 from prashanth26/bugfix/drain-fix
Bugfix: Draining issue and Azure error handling
2 parents 9d97573 + a4e1c53 commit 21a059b

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

pkg/controller/machine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ func (c *controller) updateMachineStatus(
518518
if err != nil {
519519
// Keep retrying until update goes through
520520
glog.V(3).Infof("Warning: Updated failed, retrying, error: %q", err)
521-
c.updateMachineStatus(machine, lastOperation, currentStatus)
521+
return c.updateMachineStatus(machine, lastOperation, currentStatus)
522522
}
523-
return machine, nil
523+
return clone, nil
524524
}
525525

526526
func (c *controller) updateMachineConditions(machine *v1alpha1.Machine, conditions []v1.NodeCondition) *v1alpha1.Machine {

pkg/driver/driver_azure.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ func (d *AzureDriver) Create() (string, string, error) {
7676
"",
7777
)
7878
err = onErrorFail(err, fmt.Sprintf("subnetClient.Get failed for subnet %q", subnet.Name))
79+
if err != nil {
80+
return "Error", "Error", err
81+
}
7982

8083
enableIPForwarding := true
8184
nicParameters := network.Interface{
@@ -94,11 +97,20 @@ func (d *AzureDriver) Create() (string, string, error) {
9497
},
9598
Tags: &tagList,
9699
}
97-
cancel := make(chan struct{})
100+
101+
var cancel chan struct{}
102+
98103
_, errChan := interfacesClient.CreateOrUpdate(resourceGroup, nicName, nicParameters, cancel)
99104
err = onErrorFail(<-errChan, fmt.Sprintf("interfacesClient.CreateOrUpdate for NIC '%s' failed", nicName))
105+
if err != nil {
106+
return "Error", "Error", err
107+
}
108+
100109
nicParameters, err = interfacesClient.Get(resourceGroup, nicName, "")
101110
err = onErrorFail(err, fmt.Sprintf("interfaces.Get for NIC '%s' failed", nicName))
111+
if err != nil {
112+
return "Error", "Error", err
113+
}
102114

103115
vm := compute.VirtualMachine{
104116
Location: &location,
@@ -155,9 +167,13 @@ func (d *AzureDriver) Create() (string, string, error) {
155167
},
156168
Tags: &tagList,
157169
}
170+
171+
cancel = nil
158172
_, errChan = vmClient.CreateOrUpdate(resourceGroup, vmName, vm, cancel)
159173
err = onErrorFail(<-errChan, "createVM failed")
160-
//glog.Infof("Created machine '%s' successfully\n", vmName)
174+
if err != nil {
175+
return "Error", "Error", err
176+
}
161177

162178
return d.encodeMachineID(location, vmName), vmName, err
163179
}

0 commit comments

Comments
 (0)