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

'--infra-command' parameter in pod create not working as expected #7167

Closed
KKoukiou opened this issue Jul 31, 2020 · 9 comments
Closed

'--infra-command' parameter in pod create not working as expected #7167

KKoukiou opened this issue Jul 31, 2020 · 9 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue

Comments

@KKoukiou
Copy link
Contributor

/kind bug

Description

Running the following command podman pod create --infra-image alpine --infra-command 'sleep 1000' --name pod-1
will create pod-1 with and infra container whose command is /bin/bash and not sleep 1000 as specified in the arguments.

I would expect that the infra container created would now have an EntryPoint equal to sleep 1000`. Instead I get the following configuration.

Additional information you deem important (e.g. issue happens only occasionally):

[root@localhost ~]# podman ps --all
CONTAINER ID  IMAGE                            COMMAND  CREATED         STATUS                         PORTS   NAMES
...
a7b81b9a77e3  docker.io/library/alpine:latest  /bin/sh  3 minutes ago   Exited (0) About a minute ago          23a396950741-infra

[root@localhost ~]# podman pod inspect pod-1
{
    "Id": "23a3969507419bbe8a095d3313e79286e66a9ddd57bcb1ee125318d4ad4b02bd",
    "Name": "pod-1",
    "Created": "2020-07-31T07:53:18.994608342-04:00",
    "CreateCommand": [
        "podman",
        "pod",
        "create",
        "--infra-image",
        "alpine",
        "--infra-command",
        "sleep 1000",
        "--name",
        "pod-1"
    ],
    "State": "Stopped",
    "Hostname": "pod-1",
    "CreateCgroup": false,
    "CgroupParent": "machine.slice",
    "CgroupPath": "machine.slice/machine-libpod_pod_23a3969507419bbe8a095d3313e79286e66a9ddd57bcb1ee125318d4ad4b02bd.slice",
    "CreateInfra": false,
    "InfraContainerID": "a7b81b9a77e30c7c783dddf9af11b1f617b84eef12f36115053dd469270a4e80",
    "SharedNamespaces": [
        "ipc",
        "net",
        "uts"
    ],
    "NumContainers": 2,
    "Containers": [
        {
            "Id": "9db93de08b23d0fb2814cae0df653e75207e747638fe0d7a1cd00e3764640fc7",
            "Name": "test-pod-1-system",
            "State": "configured"
        },
        {
            "Id": "a7b81b9a77e30c7c783dddf9af11b1f617b84eef12f36115053dd469270a4e80",
            "Name": "23a396950741-infra",
            "State": "stopped"
        }
    ]
}

Output of podman version:

2.0.2

Package info (e.g. output of rpm -q podman or apt list podman):

podman-2.0.2-1.fc32.x86_64
@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 31, 2020
@vrothberg vrothberg self-assigned this Jul 31, 2020
@vrothberg
Copy link
Member

vrothberg commented Jul 31, 2020

In case another image is specified, we default to the image's entrypoint. I think that behaviour is sane.

However, if we specify a custom infra-command we should set it. It looks like we ignore it entirely (even without specifying a custom image).

@mheon, I'll hand this over to you as I won't be able to tackle it today. Feel free to reassign to me if you don't find time today.

s.InfraCommand = strings.Split(p.InfraCommand, " ") ... is dangerous in for string arguments such as --infra-command '/bin/tool "string argument with space". Instead we should use github.com/google/shlex.

I also noted that containers.conf doesn't account for arguments, so we could shlex the input from there as well.

It looks like there are a couple of things to unpack. We also need tests for infra-command.

@mheon
Copy link
Member

mheon commented Jul 31, 2020

I think what we should do if have InfraCommand and InfraArgs - InfraCommand can be the entrypoint and remains a string, and we gain the ability to set arguments for it with InfraArgs, a []string appended to the command. It's a little awkward but it keeps backwards compat.

@vrothberg
Copy link
Member

I (weakly) prefer shlex-ing over adding InfraArgs as the latter adds more complexity: command and args could both be set in the config and in the CLI and on top we have data from the image to consider if --infra-image is specified.

@Luap99
Copy link
Member

Luap99 commented Aug 4, 2020

Why not make it compatible with podman create and accept the image as first argument and the command as 1-n args?

@mheon
Copy link
Member

mheon commented Aug 4, 2020

Pods don't need to have infra containers - we actually have (loose) plans to replace them with pinned namespaces in the future - so I'm hesitant to make their arguments a required part of the pod command.

@github-actions
Copy link

github-actions bot commented Sep 4, 2020

A friendly reminder that this issue had no activity for 30 days.

@vrothberg vrothberg assigned mheon and unassigned vrothberg Sep 7, 2020
@vrothberg
Copy link
Member

I think what we should do if have InfraCommand and InfraArgs - InfraCommand can be the entrypoint and remains a string, and we gain the ability to set arguments for it with InfraArgs, a []string appended to the command. It's a little awkward but it keeps backwards compat.

@mheon, I assigned the issue to you. I simply forgot to unassign myself before.

@mheon mheon assigned ParkerVR and unassigned mheon Sep 8, 2020
@mheon
Copy link
Member

mheon commented Sep 8, 2020

@ParkerVR PTAL

edsantiago added a commit to edsantiago/libpod that referenced this issue Sep 19, 2020
- podman network create: new test

- podman pull by-sha + podman images -a (containers#7651)

- podman image mount: new test

- podman pod: --infra-image and --infra-command (containers#7167)

For convenience and robustness, build a new testimage
containing a custom file /home/podman/testimage-id
with contents YYYYMMDD (same as image tag). The
image-mount test checks that this file exists and
has the desired content. New testimage also includes
a dummy 'pause' executable, for testing pod infra.

Updates from testimage:20200902 to :20200917

Signed-off-by: Ed Santiago <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Oct 5, 2020

I believe this is now fixed, reopen if I am mistaken.

@rhatdan rhatdan closed this as completed Oct 5, 2020
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. stale-issue
Projects
None yet
Development

No branches or pull requests

7 participants