1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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 <raskintech@gmail.com>
This commit is contained in:
Siarhei Rasiukevich 2018-06-26 13:26:00 +03:00
parent d9b5aa4c86
commit fe9a5a225d

View file

@ -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
}