aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-06-11 15:05:52 +0200
committerMatthew Heon <mheon@redhat.com>2021-06-14 10:35:09 -0400
commit4f56f7f13335bfe3795526d7ba00e70dbdbdf380 (patch)
treebef7217303050fbf149334a8e6f109080a6f4b16
parente42d727a97e4a5486d8a972a0e526e2e6afc83a9 (diff)
downloadpodman-4f56f7f13335bfe3795526d7ba00e70dbdbdf380.tar.gz
podman-4f56f7f13335bfe3795526d7ba00e70dbdbdf380.tar.bz2
podman-4f56f7f13335bfe3795526d7ba00e70dbdbdf380.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 0e8a4f768..eb515c000 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -1068,7 +1068,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
}
@@ -1123,7 +1123,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 46ca80321..a36eae942 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