Skip to content

Commit 56ad941

Browse files
committed
Fix possible overlapping IPs when ingressNA == nil
Logic was added to the Swarm executor in commit 0d9b0ed to clean up managed networks whenever the node's load-balancer IP address is removed or changed in order to free up the address in the case where the container fails to start entirely. Unfortunately, due to an oversight the function returns early if the Swarm is lacking an ingress network. Remove the early return so that load-balancer IP addresses for all the other networks are freed as appropriate, irrespective of whether an ingress network exists in the Swarm. Signed-off-by: Cory Snider <[email protected]>
1 parent 6f47785 commit 56ad941

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

daemon/cluster/executor/container/executor.go

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -213,36 +213,35 @@ func (e *executor) Configure(ctx context.Context, node *api.Node) error {
213213

214214
if ingressNA == nil {
215215
e.backend.ReleaseIngress()
216-
return e.backend.GetAttachmentStore().ResetAttachments(attachments)
217-
}
218-
219-
options := network.CreateOptions{
220-
Driver: ingressNA.Network.DriverState.Name,
221-
IPAM: &network.IPAM{
222-
Driver: ingressNA.Network.IPAM.Driver.Name,
223-
},
224-
Options: ingressNA.Network.DriverState.Options,
225-
Ingress: true,
226-
}
216+
} else {
217+
options := network.CreateOptions{
218+
Driver: ingressNA.Network.DriverState.Name,
219+
IPAM: &network.IPAM{
220+
Driver: ingressNA.Network.IPAM.Driver.Name,
221+
},
222+
Options: ingressNA.Network.DriverState.Options,
223+
Ingress: true,
224+
}
227225

228-
for _, ic := range ingressNA.Network.IPAM.Configs {
229-
c := network.IPAMConfig{
230-
Subnet: ic.Subnet,
231-
IPRange: ic.Range,
232-
Gateway: ic.Gateway,
226+
for _, ic := range ingressNA.Network.IPAM.Configs {
227+
c := network.IPAMConfig{
228+
Subnet: ic.Subnet,
229+
IPRange: ic.Range,
230+
Gateway: ic.Gateway,
231+
}
232+
options.IPAM.Config = append(options.IPAM.Config, c)
233233
}
234-
options.IPAM.Config = append(options.IPAM.Config, c)
235-
}
236234

237-
_, err := e.backend.SetupIngress(clustertypes.NetworkCreateRequest{
238-
ID: ingressNA.Network.ID,
239-
CreateRequest: network.CreateRequest{
240-
Name: ingressNA.Network.Spec.Annotations.Name,
241-
CreateOptions: options,
242-
},
243-
}, ingressNA.Addresses[0])
244-
if err != nil {
245-
return err
235+
_, err := e.backend.SetupIngress(clustertypes.NetworkCreateRequest{
236+
ID: ingressNA.Network.ID,
237+
CreateRequest: network.CreateRequest{
238+
Name: ingressNA.Network.Spec.Annotations.Name,
239+
CreateOptions: options,
240+
},
241+
}, ingressNA.Addresses[0])
242+
if err != nil {
243+
return err
244+
}
246245
}
247246

248247
var (

0 commit comments

Comments
 (0)