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

[BUG] podman_image throws JSONDecodeError #676

Closed
shunkica opened this issue Nov 29, 2023 · 2 comments · Fixed by #680
Closed

[BUG] podman_image throws JSONDecodeError #676

shunkica opened this issue Nov 29, 2023 · 2 comments · Fixed by #680

Comments

@shunkica
Copy link

shunkica commented Nov 29, 2023

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

/kind bug

Description

podman_image fails to build image from Dockerfile

Steps to reproduce the issue:

play:

- name: Deploy locker
  gather_facts: no
  hosts: all
  remote_user: locker
  tasks:
    - name: Build Container Image with Podman
      containers.podman.podman_image:
        path: ./app
        name: locker
        tag: latest

./app/Dockerfile

FROM node:21.2.0-alpine3.17
WORKDIR /src
RUN npm i express async-mutex --save
COPY . .
EXPOSE 3000
CMD ["node", "locker.js"]

Describe the results you received:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
fatal: [devel8.clab]: FAILED! => {"changed": false, "module_stderr": "Connection to 10.10.10.8 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/opt/locker/.ansible/tmp/ansible-tmp-1701255959.2748022-1926672-71302693664402/AnsiballZ_podman_image.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/opt/locker/.ansible/tmp/ansible-tmp-1701255959.2748022-1926672-71302693664402/AnsiballZ_podman_image.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/opt/locker/.ansible/tmp/ansible-tmp-1701255959.2748022-1926672-71302693664402/AnsiballZ_podman_image.py\", line 48, in invoke_module\r\n    run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_0i860cm0/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 879, in <module>\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_0i860cm0/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 874, in main\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_0i860cm0/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 449, in __init__\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_0i860cm0/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 480, in present\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_0i860cm0/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 545, in find_image\r\n  File \"/usr/lib64/python3.6/json/__init__.py\", line 354, in loads\r\n    return _default_decoder.decode(s)\r\n  File \"/usr/lib64/python3.6/json/decoder.py\", line 339, in decode\r\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n  File \"/usr/lib64/python3.6/json/decoder.py\", line 357, in raw_decode\r\n    raise JSONDecodeError(\"Expecting value\", s, err.value) from None\r\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Describe the results you expected:

# podman build -t locker:latest ./app
STEP 1/6: FROM node:21.2.0-alpine3.17
STEP 2/6: WORKDIR /src
--> Using cache 5e38c943f190d6b50a7d45ecfef70eab794b05933e2af3651bb7e08289fa43ec
--> 5e38c943f190
STEP 3/6: RUN npm i express async-mutex --save
--> Using cache af6e05bf4e4dab92247697ed3e8dff1594ab7f8bf3124ac9fd5d2319b86c7419
--> af6e05bf4e4d
STEP 4/6: COPY . .
--> Using cache f232aeb88aa9eae282a68846fa6004c148af17bac3c1f15e4943956f80bc26c7
--> f232aeb88aa9
STEP 5/6: EXPOSE 3000
--> Using cache 750a363265fcc5eb14453b645e91154f17a28289d33185d1dbc1000f9ea3382e
--> 750a363265fc
STEP 6/6: CMD ["node", "locker.js"]
--> Using cache c8dca5e97481630dda022918ca30880ffa122cbfb5ef3bffeddd08cb76893f56
COMMIT locker:latest
--> c8dca5e97481
Successfully tagged localhost/locker:latest
c8dca5e97481630dda022918ca30880ffa122cbfb5ef3bffeddd08cb76893f56

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

Version of the containers.podman collection:
Either git commit if installed from git: git show --summary
Or version from ansible-galaxy if installed from galaxy: ansible-galaxy collection list | grep containers.podman

containers.podman             1.11.0 
containers.podman             1.11.0 

Output of ansible --version:

ansible [core 2.15.6]
  config file = /home/deploy/ansible_playbooks/ansible.cfg
  configured module search path = ['/home/deploy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/deploy/.local/pipx/venvs/ansible/lib64/python3.9/site-packages/ansible
  ansible collection location = /home/deploy/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/deploy/.local/bin/ansible
  python version = 3.9.18 (main, Sep  7 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/home/deploy/.local/pipx/venvs/ansible/bin/python)
  jinja version = 3.1.2
  libyaml = True

Output of podman version:

Client:       Podman Engine
Version:      4.6.1
API Version:  4.6.1
Go Version:   go1.20.10
Built:        Sat Nov 18 01:48:31 2023
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.31.3
  cgroupControllers: []
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.1.8-1.module+el8.9.0+1444+82dcc378.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.8, commit: 246941175a1d1247a5942b682c19b22ddc93020d'
  cpuUtilization:
    idlePercent: 99.4
    systemPercent: 0.35
    userPercent: 0.25
  cpus: 2
  databaseBackend: boltdb
  distribution:
    distribution: '"rocky"'
    version: "8.9"
  eventLogger: file
  freeLocks: 2048
  hostname: devel8.clab
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 3004
      size: 1
    - container_id: 1
      host_id: 296608
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 3003
      size: 1
    - container_id: 1
      host_id: 296608
      size: 65536
  kernel: 4.18.0-425.13.1.el8_7.x86_64
  linkmode: dynamic
  logDriver: k8s-file
  memFree: 162136064
  memTotal: 842899456
  networkBackend: cni
  networkBackendInfo:
    backend: cni
    dns:
      package: podman-plugins-4.6.1-4.module+el8.9.0+1580+e76741f0.x86_64
      path: /usr/libexec/cni/dnsname
      version: |-
        CNI dnsname plugin
        version: 1.3.1
        commit: unknown
    package: containernetworking-plugins-1.3.0-4.module+el8.9.0+1580+e76741f0.x86_64
    path: /usr/libexec/cni
  ociRuntime:
    name: runc
    package: runc-1.1.9-1.module+el8.9.0+1420+91577025.x86_64
    path: /usr/bin/runc
    version: |-
      runc version 1.1.9
      spec: 1.0.2-dev
      go: go1.20.6
      libseccomp: 2.5.2
  os: linux
  pasta:
    executable: ""
    package: ""
    version: ""
  remoteSocket:
    path: /run/user/3003/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_NET_RAW,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.1-1.module+el8.9.0+1580+e76741f0.x86_64
    version: |-
      slirp4netns version 1.2.1
      commit: 09e31e92fa3d2a1d3ca261adaeb012c8d75a8194
      libslirp: 4.4.0
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.2
  swapFree: 4062908416
  swapTotal: 4265603072
  uptime: 1595h 24m 50.00s (Approximately 66.46 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /opt/locker/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /opt/locker/.local/share/containers/storage
  graphRootAllocated: 53660876800
  graphRootUsed: 11056443392
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 6
  runRoot: /run/user/3003/containers
  transientStore: false
  volumePath: /opt/locker/.local/share/containers/storage/volumes
version:
  APIVersion: 4.6.1
  Built: 1700268511
  BuiltTime: Sat Nov 18 01:48:31 2023
  GitCommit: ""
  GoVersion: go1.20.10
  Os: linux
  OsArch: linux/amd64
  Version: 4.6.1

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

podman-4.6.1-4.module+el8.9.0+1580+e76741f0.x86_64

Playbok you run with ansible (e.g. content of playbook.yaml):

- name: Deploy locker
  gather_facts: no
  hosts: all
  remote_user: locker
  tasks:
    - name: Build Container Image with Podman
      containers.podman.podman_image:
        path: ./app
        name: locker
        tag: latest

Command line and output of ansible run with high verbosity

Please NOTE: if you submit a bug about idempotency, run the playbook with --diff option, like:

ansible-playbook -i inventory --diff -vv playbook.yml

The full traceback is:
Traceback (most recent call last):
  File "/opt/locker/.ansible/tmp/ansible-tmp-1701257092.2023714-1926975-37784262535125/AnsiballZ_podman_image.py", line 107, in <module>
    _ansiballz_main()
  File "/opt/locker/.ansible/tmp/ansible-tmp-1701257092.2023714-1926975-37784262535125/AnsiballZ_podman_image.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/opt/locker/.ansible/tmp/ansible-tmp-1701257092.2023714-1926975-37784262535125/AnsiballZ_podman_image.py", line 48, in invoke_module
    run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py", line 879, in <module>
  File "/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py", line 874, in main
  File "/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py", line 449, in __init__
  File "/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py", line 480, in present
  File "/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py", line 545, in find_image
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
fatal: [devel8.clab]: FAILED! => {
    "changed": false,
    "module_stderr": "Connection to 10.10.10.8 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/opt/locker/.ansible/tmp/ansible-tmp-1701257092.2023714-1926975-37784262535125/AnsiballZ_podman_image.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/opt/locker/.ansible/tmp/ansible-tmp-1701257092.2023714-1926975-37784262535125/AnsiballZ_podman_image.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/opt/locker/.ansible/tmp/ansible-tmp-1701257092.2023714-1926975-37784262535125/AnsiballZ_podman_image.py\", line 48, in invoke_module\r\n    run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 879, in <module>\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 874, in main\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 449, in __init__\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 480, in present\r\n  File \"/tmp/ansible_containers.podman.podman_image_payload_ttowh9v2/ansible_containers.podman.podman_image_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_image.py\", line 545, in find_image\r\n  File \"/usr/lib64/python3.6/json/__init__.py\", line 354, in loads\r\n    return _default_decoder.decode(s)\r\n  File \"/usr/lib64/python3.6/json/decoder.py\", line 339, in decode\r\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\r\n  File \"/usr/lib64/python3.6/json/decoder.py\", line 357, in raw_decode\r\n    raise JSONDecodeError(\"Expecting value\", s, err.value) from None\r\njson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Additional environment details (AWS, VirtualBox, physical, etc.):
Rocky Linux 8 VM

@shunkica
Copy link
Author

shunkica commented Nov 29, 2023

I have resolved the issue.
There was a line in .bashrc to set XDG_RUNTIME_DIR to /run/user/$(id -u -n) but that was supposed to be /run/user/$(id -u)
In any case maybe this is a error condition which should be handled by the module.

@sshnaidm
Copy link
Member

I'll add a json check maybe, not sure what we can do here.

sshnaidm added a commit to sshnaidm/ansible-podman-collections that referenced this issue Nov 30, 2023
Fix containers#676
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
sshnaidm added a commit that referenced this issue Nov 30, 2023
Fix #676
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants