summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-06-11 15:05:52 +0200
committerPaul Holzinger <pholzing@redhat.com>2021-06-11 16:00:12 +0200
commit44d9c453d36f18eee93b1dbaf3158f0215521301 (patch)
treeea8f64976febe6c5ddbc5db528c02f82f06534af
parentdffbf16b24ba971a96db753100b7f43f5d6df3f8 (diff)
downloadpodman-44d9c453d36f18eee93b1dbaf3158f0215521301.tar.gz
podman-44d9c453d36f18eee93b1dbaf3158f0215521301.tar.bz2
podman-44d9c453d36f18eee93b1dbaf3158f0215521301.zip
Fix network connect race with docker-compose
Network connect/disconnect has to call the cni plugins when the network namespace is already configured. This is the case for `ContainerStateRunning` and `ContainerStateCreated`. This is important otherwise the network is not attached to this network namespace and libpod will throw errors like `network inspection mismatch...` This problem happened when using `docker-compose up` in attached mode. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--libpod/networking_linux.go4
-rwxr-xr-xtest/compose/test-compose2
2 files changed, 4 insertions, 2 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index c928e02a6..5446841f6 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -1090,7 +1090,7 @@ func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) erro
}
c.newNetworkEvent(events.NetworkDisconnect, netName)
- if c.state.State != define.ContainerStateRunning {
+ if !c.ensureState(define.ContainerStateRunning, define.ContainerStateCreated) {
return nil
}
@@ -1145,7 +1145,7 @@ func (c *Container) NetworkConnect(nameOrID, netName string, aliases []string) e
return err
}
c.newNetworkEvent(events.NetworkConnect, netName)
- if c.state.State != define.ContainerStateRunning {
+ if !c.ensureState(define.ContainerStateRunning, define.ContainerStateCreated) {
return nil
}
if c.state.NetNS == nil {
diff --git a/test/compose/test-compose b/test/compose/test-compose
index 981f78a79..70db6dd55 100755
--- a/test/compose/test-compose
+++ b/test/compose/test-compose
@@ -183,6 +183,8 @@ function test_port() {
fi
echo "# cat $WORKDIR/server.log:"
cat $WORKDIR/server.log
+ echo "# cat $logfile:"
+ cat $logfile
return
fi