Do not attempt releasing network when not attached to any network

Sometimes container.cleanup() can be called from multiple paths
for the same container during error conditions from monitor and
regular startup path. So if the container network has been already
released do not try to release it again.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Upstream-commit: 6cdf8623d52e7e4c5b5265deb5f5b1d33f2e6e95
Component: engine
This commit is contained in:
Jana Radhakrishnan
2015-05-21 18:57:17 +00:00
parent 8e905a0abb
commit 34120dcd16

View File

@ -917,6 +917,12 @@ func (container *Container) ReleaseNetwork() {
return
}
// If the container is not attached to any network do not try
// to release network and generate spurious error messages.
if container.NetworkSettings.NetworkID == "" {
return
}
n, err := container.daemon.netController.NetworkByID(container.NetworkSettings.NetworkID)
if err != nil {
logrus.Errorf("error locating network id %s: %v", container.NetworkSettings.NetworkID, err)