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

kube play: complete container spec #17107

Merged
merged 1 commit into from
Jan 14, 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
10 changes: 10 additions & 0 deletions pkg/domain/infra/abi/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,16 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY
if err != nil {
return nil, nil, err
}

// Make sure to complete the spec (#17016)
warn, err := generate.CompleteSpec(ctx, ic.Libpod, specGen)
if err != nil {
return nil, nil, err
}
for _, w := range warn {
fmt.Fprintf(os.Stderr, "%s\n", w)
}
Comment on lines +741 to +743
Copy link
Member

Choose a reason for hiding this comment

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

I see the other callers do the same but shouldn't we use logrus.Warn() for this? It feels very ugly to just print somewhere in the backend where the callers have no control over it. I would argue that podman --log-level=error should not show such messages if they are just warnings.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also don't like printing to stderr. But as you mentioned, it's consistent with other call sites, so I didn't change it.

I am supportive of changing those to logrus.Warn*. There's probably more such cases across the code base.


specGen.RawImageName = container.Image
rtSpec, spec, opts, err := generate.MakeContainer(ctx, ic.Libpod, specGen, false, nil)
if err != nil {
Expand Down
18 changes: 10 additions & 8 deletions test/system/700-play.bats
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ EOF
cat <<EOF >>$outfile
- command:
- $command
env:
- name: PATH
value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- name: TERM
value: xterm
- name: container
value: podman
image: $image
name: $ctrname
resources: {}
Expand Down Expand Up @@ -341,10 +334,19 @@ from $IMAGE
USER bin
_EOF

run_podman build -t userimage $PODMAN_TMPDIR
# Unset the PATH during build and make sure that all default env variables
# are correctly set for the created container.
run_podman build --unsetenv PATH -t userimage $PODMAN_TMPDIR
run_podman image inspect userimage --format "{{.Config.Env}}"
is "$output" "\[\]" "image does not set PATH - env is empty"

run_podman play kube --start=false $PODMAN_TMPDIR/test.yaml
run_podman inspect --format "{{ .Config.User }}" test_pod-test
is "$output" bin "expect container within pod to run as the bin user"
run_podman inspect --format "{{ .Config.Env }}" test_pod-test
is "$output" ".*PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.*" "expect PATH to be set"
is "$output" ".*TERM=xterm.*" "expect TERM to be set"
is "$output" ".*container=podman.*" "expect container to be set"

run_podman stop -a -t 0
run_podman pod rm -t 0 -f test_pod
Expand Down