summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-03-18 12:48:41 +0100
committerGitHub <noreply@github.com>2022-03-18 12:48:41 +0100
commit3853ef9b598b82115c1609957169614b26320a26 (patch)
treea9ef29d6110b1f5d458a0f33a209c009133ca880
parente471bf532c751c4f775d8d9f5f8bba35104acbb5 (diff)
parent4b359e4598ec795b8eff3dfebae52b17c195c22b (diff)
downloadpodman-3853ef9b598b82115c1609957169614b26320a26.tar.gz
podman-3853ef9b598b82115c1609957169614b26320a26.tar.bz2
podman-3853ef9b598b82115c1609957169614b26320a26.zip
Merge pull request #13540 from mheon/fix_11822
Deduplicate between Volumes and Mounts in compat API
-rw-r--r--.cirrus.yml11
-rw-r--r--cmd/podman/common/create_opts.go13
-rwxr-xr-xcontrib/cirrus/runner.sh4
-rwxr-xr-xcontrib/cirrus/setup_environment.sh5
-rw-r--r--test/compose/ipam_set_ip/tests.sh6
-rw-r--r--test/compose/two_networks/tests.sh8
6 files changed, 40 insertions, 7 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index 7e523c4ae..0752901ab 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -429,7 +429,7 @@ apiv2_test_task:
compose_test_task:
- name: "compose test on $DISTRO_NV ($PRIV_NAME)"
+ name: "$TEST_FLAVOR test on $DISTRO_NV ($PRIV_NAME)"
alias: compose_test
only_if: *not_build
skip: *tags
@@ -438,11 +438,18 @@ compose_test_task:
gce_instance: *standardvm
env:
<<: *stdenvars
- TEST_FLAVOR: compose
matrix:
- env:
+ TEST_FLAVOR: compose
PRIV_NAME: root
- env:
+ TEST_FLAVOR: compose
+ PRIV_NAME: rootless
+ - env:
+ TEST_FLAVOR: compose_v2
+ PRIV_NAME: root
+ - env:
+ TEST_FLAVOR: compose_v2
PRIV_NAME: rootless
clone_script: *noop # Comes from cache
gopath_cache: *ro_gopath_cache
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index b110b3d85..e5a2a0da3 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -97,12 +97,21 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
}
// mounts type=tmpfs/bind,source=...,target=...=,opt=val
+ volSources := make(map[string]bool)
+ volDestinations := make(map[string]bool)
mounts := make([]string, 0, len(cc.HostConfig.Mounts))
var builder strings.Builder
for _, m := range cc.HostConfig.Mounts {
addField(&builder, "type", string(m.Type))
addField(&builder, "source", m.Source)
addField(&builder, "target", m.Target)
+
+ // Store source/dest so we don't add duplicates if a volume is
+ // also mentioned in cc.Volumes.
+ // Which Docker Compose v2.0 does, for unclear reasons...
+ volSources[m.Source] = true
+ volDestinations[m.Target] = true
+
if m.ReadOnly {
addField(&builder, "ro", "true")
}
@@ -328,8 +337,6 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
}
// volumes
- volSources := make(map[string]bool)
- volDestinations := make(map[string]bool)
for _, vol := range cc.HostConfig.Binds {
cliOpts.Volume = append(cliOpts.Volume, vol)
// Extract the destination so we don't add duplicate mounts in
@@ -348,6 +355,8 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
// format of `-v` so we can just append them in there.
// Unfortunately, these may be duplicates of existing mounts in Binds.
// So... We need to catch that.
+ // This also handles volumes duplicated between cc.HostConfig.Mounts and
+ // cc.Volumes, as seen in compose v2.0.
for vol := range cc.Volumes {
if _, ok := volDestinations[filepath.Clean(vol)]; ok {
continue
diff --git a/contrib/cirrus/runner.sh b/contrib/cirrus/runner.sh
index d1d87ad04..1bff07203 100755
--- a/contrib/cirrus/runner.sh
+++ b/contrib/cirrus/runner.sh
@@ -63,6 +63,10 @@ function _run_compose() {
./test/compose/test-compose |& logformatter
}
+function _run_compose_v2() {
+ ./test/compose/test-compose |& logformatter
+}
+
function _run_int() {
dotest integration
}
diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh
index 696560166..864c78484 100755
--- a/contrib/cirrus/setup_environment.sh
+++ b/contrib/cirrus/setup_environment.sh
@@ -272,6 +272,11 @@ case "$TEST_FLAVOR" in
;;
build) make clean ;;
unit) ;;
+ compose_v2)
+ dnf -y remove docker-compose
+ curl -SL https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
+ chmod +x /usr/local/bin/docker-compose
+ ;& # Continue with next item
apiv2)
msg "Installing previously downloaded/cached packages"
dnf install -y $PACKAGE_DOWNLOAD_DIR/python3*.rpm
diff --git a/test/compose/ipam_set_ip/tests.sh b/test/compose/ipam_set_ip/tests.sh
index ecaf3167e..b9e761ea2 100644
--- a/test/compose/ipam_set_ip/tests.sh
+++ b/test/compose/ipam_set_ip/tests.sh
@@ -1,4 +1,8 @@
# -*- bash -*-
-podman container inspect ipam_set_ip_test_1 --format '{{ .NetworkSettings.Networks.ipam_set_ip_net1.IPAddress }}'
+ctr_name="ipam_set_ip_test_1"
+if [ "$TEST_FLAVOR" = "compose_v2" ]; then
+ ctr_name="ipam_set_ip-test-1"
+fi
+podman container inspect "$ctr_name" --format '{{ .NetworkSettings.Networks.ipam_set_ip_net1.IPAddress }}'
like "$output" "10.123.0.253" "$testname : ip address is set"
diff --git a/test/compose/two_networks/tests.sh b/test/compose/two_networks/tests.sh
index 1cc88aa5f..af0d1fbe3 100644
--- a/test/compose/two_networks/tests.sh
+++ b/test/compose/two_networks/tests.sh
@@ -1,7 +1,11 @@
# -*- bash -*-
-podman container inspect two_networks_con1_1 --format '{{len .NetworkSettings.Networks}}'
+ctr_name="two_networks_con1_1"
+if [ "$TEST_FLAVOR" = "compose_v2" ]; then
+ ctr_name="two_networks-con1-1"
+fi
+podman container inspect "$ctr_name" --format '{{len .NetworkSettings.Networks}}'
is "$output" "2" "$testname : Container is connected to both networks"
-podman container inspect two_networks_con1_1 --format '{{.NetworkSettings.Networks}}'
+podman container inspect "$ctr_name" --format '{{.NetworkSettings.Networks}}'
like "$output" "two_networks_net1" "$testname : First network name exists"
like "$output" "two_networks_net2" "$testname : Second network name exists"