Fix error handling in createLoadBalncerSandbox()
Error unwinding only works if the error variable is used consistently and isn't hidden in the scope of other if statements. Signed-off-by: Chris Telfer <ctelfer@docker.com>
This commit is contained in:
parent
1449e88f7a
commit
31d3de0994
1 changed files with 6 additions and 5 deletions
|
@ -2122,7 +2122,7 @@ func (n *network) lbEndpointName() string {
|
|||
return n.name + "-endpoint"
|
||||
}
|
||||
|
||||
func (n *network) createLoadBalancerSandbox() error {
|
||||
func (n *network) createLoadBalancerSandbox() (retErr error) {
|
||||
sandboxName := n.lbSandboxName()
|
||||
sbOptions := []SandboxOption{}
|
||||
if n.ingress {
|
||||
|
@ -2133,9 +2133,9 @@ func (n *network) createLoadBalancerSandbox() error {
|
|||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if retErr != nil {
|
||||
if e := n.ctrlr.SandboxDestroy(sandboxName); e != nil {
|
||||
logrus.Warnf("could not delete sandbox %s on failure on failure (%v): %v", sandboxName, err, e)
|
||||
logrus.Warnf("could not delete sandbox %s on failure on failure (%v): %v", sandboxName, retErr, e)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
@ -2150,9 +2150,9 @@ func (n *network) createLoadBalancerSandbox() error {
|
|||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if retErr != nil {
|
||||
if e := ep.Delete(true); e != nil {
|
||||
logrus.Warnf("could not delete endpoint %s on failure on failure (%v): %v", endpointName, err, e)
|
||||
logrus.Warnf("could not delete endpoint %s on failure on failure (%v): %v", endpointName, retErr, e)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
@ -2160,6 +2160,7 @@ func (n *network) createLoadBalancerSandbox() error {
|
|||
if err := ep.Join(sb, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return sb.EnableService()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue