Merge pull request #13540 from mheon/fix_11822
Deduplicate between Volumes and Mounts in compat API
This commit is contained in:
commit
3853ef9b59
11
.cirrus.yml
11
.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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue