Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pod: fix duplicate volumes from containers.conf #19902

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/podman/pods/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func init() {
flags := createCommand.Flags()
flags.SetInterspersed(false)
common.DefineCreateDefaults(&infraOptions)
// these settings are not applicable to pod create since they are per-container
// and they will end up being duplicated for each container in the pod.
infraOptions.Volume = nil
infraOptions.Mount = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Barely on the fence here. Should we add a debug statement just above this, showing the values we're wiping? I think not, but I don't know for sure if that might be useful at some far-flung point in time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, I can add that if you think it is useful

common.DefineCreateFlags(createCommand, &infraOptions, entities.InfraMode)
common.DefineNetFlags(createCommand)

Expand Down
18 changes: 18 additions & 0 deletions test/system/200-pod.bats
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ function teardown() {
}


@test "podman pod create - custom volumes" {
skip_if_remote "CONTAINERS_CONF_OVERRIDE only affects server side"
image="i.do/not/exist:image"
tmpdir=$PODMAN_TMPDIR/pod-test
mkdir -p $tmpdir
containersconf=$tmpdir/containers.conf
cat >$containersconf <<EOF
[containers]
volumes = ["/tmp:/foobar"]
EOF

CONTAINERS_CONF_OVERRIDE=$containersconf run_podman pod create
podid="$output"

CONTAINERS_CONF_OVERRIDE=$containersconf run_podman create --pod $podid $IMAGE grep foobar /proc/mounts
}


@test "podman pod create - custom infra image" {
skip_if_remote "CONTAINERS_CONF_OVERRIDE only affects server side"
image="i.do/not/exist:image"
Expand Down