containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.79k stars 2.42k forks source link

Flag parsing error in non-quoted-field #2574

Closed EmilienM closed 5 years ago

EmilienM commented 5 years ago

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description Flag parsing error in non-quoted-field, regression found in 1.1.2.

Steps to reproduce the issue:

Command used to deploy:

Error running ['podman', 'run', '--name', 'rabbitmq_bootstrap', '--label', 'config_id=tripleo_step1', '--label', 'container_name=rabbitmq_bootstrap', '--label', 'managed_by=paunch', '--label', 'config_data={\"environment\": [\"KOLLA_CONFIG_STRATEGY=COPY_ALWAYS\", \"KOLLA_BOOTSTRAP=True\", \"RABBITMQ_CLUSTER_COOKIE=5v7Ts6vv0FhsGqEYPllP\", \"TRIPLEO_CONFIG_HASH=c641a28ce2c7aa149f10ffc3c12bb5d2\"], \"start_order\": 1, \"volumes\": [\"/etc/hosts:/etc/hosts:ro\", \"/etc/localtime:/etc/localtime:ro\", \"/etc/pki/ca-trust/extracted:/etc/pki/ca-trust/extracted:ro\", \"/etc/pki/ca-trust/source/anchors:/etc/pki/ca-trust/source/anchors:ro\", \"/etc/pki/tls/certs/ca-bundle.crt:/etc/pki/tls/certs/ca-bundle.crt:ro\", \"/etc/pki/tls/certs/ca-bundle.trust.crt:/etc/pki/tls/certs/ca-bundle.trust.crt:ro\", \"/etc/pki/tls/cert.pem:/etc/pki/tls/cert.pem:ro\", \"/dev/log:/dev/log\", \"/etc/ssh/ssh_known_hosts:/etc/ssh/ssh_known_hosts:ro\", \"/etc/puppet:/etc/puppet:ro\", \"/var/lib/kolla/config_files/rabbitmq.json:/var/lib/kolla/config_files/config.json:ro\", \"/var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro\", \"/var/lib/rabbitmq:/var/lib/rabbitmq:z\", \"/var/log/containers/rabbitmq:/var/log/rabbitmq:z\"], \"image\": \"docker.io/tripleomaster/centos-binary-rabbitmq:56eedaf13617f1880ce5b1b268db53a774f453c1_a77b7752\", \"detach\": false, \"net\": \"host\", \"privileged\": false}', '--env=KOLLA_CONFIG_STRATEGY=COPY_ALWAYS', '--env=KOLLA_BOOTSTRAP=True', '--env=RABBITMQ_CLUSTER_COOKIE=5v7Ts6vv0FhsGqEYPllP', '--env=TRIPLEO_CONFIG_HASH=c641a28ce2c7aa149f10ffc3c12bb5d2', '--net=host', '--privileged=false', '--volume=/etc/hosts:/etc/hosts:ro', '--volume=/etc/localtime:/etc/localtime:ro', '--volume=/etc/pki/ca-trust/extracted:/etc/pki/ca-trust/extracted:ro', '--volume=/etc/pki/ca-trust/source/anchors:/etc/pki/ca-trust/source/anchors:ro', '--volume=/etc/pki/tls/certs/ca-bundle.crt:/etc/pki/tls/certs/ca-bundle.crt:ro', '--volume=/etc/pki/tls/certs/ca-bundle.trust.crt:/etc/pki/tls/certs/ca-bundle.trust.crt:ro', '--volume=/etc/pki/tls/cert.pem:/etc/pki/tls/cert.pem:ro', '--volume=/dev/log:/dev/log', '--volume=/etc/ssh/ssh_known_hosts:/etc/ssh/ssh_known_hosts:ro', '--volume=/etc/puppet:/etc/puppet:ro', '--volume=/var/lib/kolla/config_files/rabbitmq.json:/var/lib/kolla/config_files/config.json:ro', '--volume=/var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro', '--volume=/var/lib/rabbitmq:/var/lib/rabbitmq:z', '--volume=/var/log/containers/rabbitmq:/var/log/rabbitmq:z', 'docker.io/tripleomaster/centos-binary-rabbitmq:56eedaf13617f1880ce5b1b268db53a774f453c1_a77b7752']. [125]",

Describe the results you received:

Error: invalid argument \"config_data={\\\"environment\\\": [\\\"KOLLA_CONFIG_STRATEGY=COPY_ALWAYS\\\", \\\"KOLLA_BOOTSTRAP=True\\\", \\\"RABBITMQ_CLUSTER_COOKIE=5v7Ts6vv0FhsGqEYPllP\\\", \\\"TRIPLEO_CONFIG_HASH=c641a28ce2c7aa149f10ffc3c12bb5d2\\\"], \\\"start_order\\\": 1, \\\"volumes\\\": [\\\"/etc/hosts:/etc/hosts:ro\\\", \\\"/etc/localtime:/etc/localtime:ro\\\", \\\"/etc/pki/ca-trust/extracted:/etc/pki/ca-trust/extracted:ro\\\", \\\"/etc/pki/ca-trust/source/anchors:/etc/pki/ca-trust/source/anchors:ro\\\", \\\"/etc/pki/tls/certs/ca-bundle.crt:/etc/pki/tls/certs/ca-bundle.crt:ro\\\", \\\"/etc/pki/tls/certs/ca-bundle.trust.crt:/etc/pki/tls/certs/ca-bundle.trust.crt:ro\\\", \\\"/etc/pki/tls/cert.pem:/etc/pki/tls/cert.pem:ro\\\", \\\"/dev/log:/dev/log\\\", \\\"/etc/ssh/ssh_known_hosts:/etc/ssh/ssh_known_hosts:ro\\\", \\\"/etc/puppet:/etc/puppet:ro\\\", \\\"/var/lib/kolla/config_files/rabbitmq.json:/var/lib/kolla/config_files/config.json:ro\\\", \\\"/var/lib/config-data/puppet-generated/rabbitmq/:/var/lib/kolla/config_files/src:ro\\\", \\\"/var/lib/rabbitmq:/var/lib/rabbitmq:z\\\", \\\"/var/log/containers/rabbitmq:/var/log/rabbitmq:z\\\"], \\\"image\\\": \\\"docker.io/tripleomaster/centos-binary-rabbitmq:56eedaf13617f1880ce5b1b268db53a774f453c1_a77b7752\\\", \\\"detach\\\": false, \\\"net\\\": \\\"host\\\", \\\"privileged\\\": false}\" for \"-l, --label\" flag: parse error on line 1, column 13: bare \" in non-quoted-field"

Describe the results you expected: Deployment worked in podman 1.0.0.

Output of podman version:

Version:            1.1.2
RemoteAPI Version:  1
Go Version:         go1.10.2
OS/Arch:            linux/amd64

Output of podman info --debug:

host:
  BuildahVersion: 1.7.1
  Conmon:
    package: podman-1.1.2-2.git0ad9b6b.el7.x86_64
    path: /usr/libexec/podman/conmon
    version: 'conmon version 1.14.0-dev, commit: 6e07c13bf86885ba6d71fdbdff90f436e18abe39-dirty'
  Distribution:
    distribution: '"centos"'
    version: "7"
  MemFree: 966000640
  MemTotal: 8369278976
  OCIRuntime:
    package: runc-1.0.0-60.dev.git2abd837.el7.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.0'
  SwapFree: 8564355072
  SwapTotal: 8589930496
  arch: amd64
  cpus: 8
  hostname: standalone.localdomain
  kernel: 3.10.0-957.5.1.el7.x86_64
  os: linux
  rootless: false
  uptime: 59m 14.39s
insecure registries:
  registries:
  - 192.168.24.1:8787
registries:
  registries:
  - registry.access.redhat.com
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.centos.org
store:
  ConfigFile: /etc/containers/storage.conf
  ContainerStore:
    number: 0
  GraphDriverName: overlay
  GraphOptions: null
  GraphRoot: /var/lib/containers/storage
  GraphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  ImageStore:
    number: 23
  RunRoot: /var/run/containers/storage
  VolumePath: /var/lib/containers/storage/volumes
rhatdan commented 5 years ago

@baude PTAL

edsantiago commented 5 years ago

Less complicated reproducer, courtesy of @mheon on IRC:

$ podman run --rm --label 'true="false"' alpine true
Error: invalid argument "true=\"false\"" for "-l, --label" flag: parse error on line 1, column 5: bare " in non-quoted-field
eparis commented 5 years ago

do you need to specify --label multiple times, or do you expect people to use it as a CSV. If 'as a CSV' that's what you have and 'true="false"' isn't a valid CSV. If you want people to have to use it multiple times I'm guessing you want a StringArray, instead of a StringSlice.

EmilienM commented 5 years ago

do you need to specify --label multiple times, or do you expect people to use it as a CSV. If 'as a CSV' that's what you have and 'true="false"' isn't a valid CSV. If you want people to have to use it multiple times I'm guessing you want a StringArray, instead of a StringSlice.

We use --label multiple times.

rhatdan commented 5 years ago

Fixed in master.

wwilson commented 5 years ago

Does this fix also need to be applied to --env? Slight modification of your reproduction above:

$ podman run --rm --env var='true=\"false\"' alpine true
Error: invalid argument "var=true=\\\"false\\\"" for "-e, --env" flag: parse error on line 1, column 10: bare " in non-quoted-field
mheon commented 5 years ago

2717 fixed --env as well