podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

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

Open akvadrako opened this issue 1 year ago • 5 comments

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:

  • OS: Fedora 38
  • podman version: 4.5.1
  • podman compose version: 1.0.6

akvadrako avatar Jul 23 '23 12:07 akvadrako

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).

nsmmrs avatar Aug 26 '23 22:08 nsmmrs

Hello

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

Regards

waewoo avatar Nov 26 '23 17:11 waewoo

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.

eandersons avatar Feb 01 '24 22:02 eandersons

Bumping this, ran into it today.

peter-facko avatar Mar 20 '24 09:03 peter-facko

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'

0xSG avatar Mar 31 '24 19:03 0xSG