From fe9a5a225d3dba9482f2712ab54efb2dc26efdf1 Mon Sep 17 00:00:00 2001 From: Siarhei Rasiukevich Date: Tue, 26 Jun 2018 13:26:00 +0300 Subject: [PATCH] Fix net driver response loss on createEndpoint Fix related to bug: https://github.com/docker/for-linux/issues/348 We should perform updateToStore(ep) after n.addEndpoint or do update twice, otherwise response from network plugin will not be written to KV storage. This results in container creation with broken network config. Signed-off-by: Siarhei Rasiukevich --- libnetwork/network.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/libnetwork/network.go b/libnetwork/network.go index e283d65815..70d6b1cc69 100644 --- a/libnetwork/network.go +++ b/libnetwork/network.go @@ -1156,18 +1156,6 @@ func (n *network) createEndpoint(name string, options ...EndpointOption) (Endpoi ep.releaseAddress() } }() - // Moving updateToSTore before calling addEndpoint so that we shall clean up VETH interfaces in case - // DockerD get killed between addEndpoint and updateSTore call - if err = n.getController().updateToStore(ep); err != nil { - return nil, err - } - defer func() { - if err != nil { - if e := n.getController().deleteFromStore(ep); e != nil { - logrus.Warnf("error rolling back endpoint %s from store: %v", name, e) - } - } - }() if err = n.addEndpoint(ep); err != nil { return nil, err @@ -1180,6 +1168,19 @@ func (n *network) createEndpoint(name string, options ...EndpointOption) (Endpoi } }() + // We should perform updateToStore call right after addEndpoint + // in order to have iface properly configured + if err = n.getController().updateToStore(ep); err != nil { + return nil, err + } + defer func() { + if err != nil { + if e := n.getController().deleteFromStore(ep); e != nil { + logrus.Warnf("error rolling back endpoint %s from store: %v", name, e) + } + } + }() + if err = ep.assignAddress(ipam, false, n.enableIPv6 && n.postIPv6); err != nil { return nil, err }