containers / podman-compose

a script to run docker-compose.yml using podman
GNU General Public License v2.0
4.95k stars 474 forks source link

AttributeError: 'Namespace' object has no attribute 'remove_orphans' #732

Open akvadrako opened 1 year ago

akvadrako commented 1 year ago

Describe the bug

It looks like compose_down refers to args.remove_orphans which is not defined if compose_run is called. I'm using the latest podman-compose on Fedora.

To Reproduce Steps to reproduce the behavior:

  1. A simple compose file:
services:
  dep:
    image: alpine
    command: false

  abc:
    image: alpine
    command: echo hi
    depends_on: ['dep']
  1. podman-compose run abc

Expected behavior Not to crash.

Actual behavior When I use podman-compose run I get a stack trace.

Output

Traceback (most recent call last):
  File "/usr/bin/podman-compose", line 33, in <module>
    sys.exit(load_entry_point('podman-compose==1.0.6', 'console_scripts', 'podman-compose')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 2940, in main
    podman_compose.run()
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 1422, in run
    cmd(self, args)
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 1753, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 2254, in compose_run
    compose.commands["up"](compose, up_args)
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 1753, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 2055, in compose_up
    compose.commands["down"](compose, down_args)
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 1753, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/podman_compose.py", line 2168, in compose_down
    if args.remove_orphans:
       ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'remove_orphans'

Environment:

nsmmrs commented 1 year ago

I ran into this today, but rebuilding my images seems to have gotten around it (the last time they were built was several months ago).

waewoo commented 9 months ago

Hello

For information, i got the same error even after rebuilding.

Regards

eandersons commented 7 months ago

A quick workaround is to replace the 2356th line in /usr/lib/python3.11/site-packages/podman_compose.py

    if args.remove_orphans:

with

    if hasattr(args, 'remove_orphans') and args.remove_orphans:

For now it worked, but will have to see how this workaround behaves in a longer period.

papundekel commented 5 months ago

Bumping this, ran into it today.

0xSG commented 5 months ago

Same here.

podman-compose run --rm common-listmonk-app ./listmonk --install
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.2
** excluding:  {'common-listmonk-app'}
['podman', 'ps', '--filter', 'label=io.podman.compose.project=listmonk-demo', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
recreating: ...
** excluding:  {'common-listmonk-app'}
podman stop -t 10 common-listmonk-db
Error: no container with name or ID "common-listmonk-db" found: no such container
exit code: 125
podman rm common-listmonk-db
Error: no container with ID or name "common-listmonk-db" found: no such container
exit code: 1
Traceback (most recent call last):
  File "/usr/local/bin/podman-compose", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 2941, in main
    podman_compose.run()
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 1423, in run
    cmd(self, args)
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 1754, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 2255, in compose_run
    compose.commands["up"](compose, up_args)
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 1754, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 2056, in compose_up
    compose.commands["down"](compose, down_args)
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 1754, in wrapped
    return func(*args, **kw)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/podman_compose.py", line 2169, in compose_down
    if args.remove_orphans:
       ^^^^^^^^^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'remove_orphans'