Skip to content

Commit 4543e14

Browse files
committed
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 <[email protected]>
1 parent a285f50 commit 4543e14

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

network.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,7 @@ func (n *network) lbEndpointName() string {
21102110
}
21112111

21122112
func (n *network) createLoadBalancerSandbox() error {
2113+
var err error
21132114
sandboxName := n.lbSandboxName()
21142115
sbOptions := []SandboxOption{}
21152116
if n.ingress {
@@ -2144,10 +2145,13 @@ func (n *network) createLoadBalancerSandbox() error {
21442145
}
21452146
}()
21462147

2147-
if err := ep.Join(sb, nil); err != nil {
2148+
err = ep.Join(sb, nil)
2149+
if err != nil {
21482150
return err
21492151
}
2150-
return sb.EnableService()
2152+
2153+
err = sb.EnableService()
2154+
return err
21512155
}
21522156

21532157
func (n *network) deleteLoadBalancerSandbox() error {

0 commit comments

Comments
 (0)