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

Add fake "podman network exists" command #613

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

paulmillar
Copy link

Motivation:

podman-compose uses the "podman network exists" command to avoid creating the same network twice. This command was added with podman v3.1.0.

Debian stable has an older version of podman (v3.0.1) that doesn't support the "podman network exists" command.

A symptom of this problem is podman-compose failing with lines like:

subprocess.CalledProcessError: Command '['podman', 'network', 'exists', 'scicatlive_default']' returned non-zero exit status 125.

During handling of the above exception, another exception occurred:

[...]
subprocess.CalledProcessError: Command '['podman', 'network', 'create', '--labelect=scicatlive', 'scicatlive_default']' returned non-zero exit status 125.

Modification:

Abstract the two places where podman-compose checks if a network already exists. This is now handled by a specific method.

Check the podman version. If the podman version is earlier than v3.1.0 then simulate the "podman network exists" command by parsing the output from "podman network ls", otherwise simply call the "podman network exists" command directly.

Result:

podman-compose is now able to create a network with versions of podman before v3.1.0.

Motivation:

podman-compose uses the "podman network exists" command to avoid
creating the same network twice.  This command was added with podman
v3.1.0.

Debian stable has an older version of podman (v3.0.1) that doesn't
support the "podman network exists" command.

A symptom of this problem is podman-compose failing with lines like:

    subprocess.CalledProcessError: Command '['podman', 'network', 'exists', 'scicatlive_default']' returned non-zero exit status 125.

    During handling of the above exception, another exception occurred:

    [...]
    subprocess.CalledProcessError: Command '['podman', 'network', 'create', '--labelect=scicatlive', 'scicatlive_default']' returned non-zero exit status 125.

Modification:

Abstract the two places where podman-compose checks if a network already
exists.  This is now handled by a specific method.

Check the podman version.  If the podman version is earlier than v3.1.0
then simulate the "podman network exists" command by parsing the output
from "podman network ls", otherwise simply call the "podman network
exists" command directly.

Result:

podman-compose is now able to create a network with versions of podman
before v3.1.0.

Signed-off-by: Paul Millar <[email protected]>
@maurerle
Copy link
Contributor

maurerle commented Aug 7, 2023

I think this is not needed anymore now as all recent systems have a more recent version (bookworm has 4.3.1 for example)

@paulmillar
Copy link
Author

I'm sure that Debian "bookworm" (v12) includes a newer version of podman, and so doesn't suffer from this problem. Therefore "simply" upgrading to bookworm should solve the problem this patch addresses.

Debian "bullseye" is now "oldstable", so it is still supported. Under Debian LTS, the lifetime of bullseye is currently undefined:

https://wiki.debian.org/LTS

However, the above page says "roughly July 2024 to June 2026", which would mean people may (somewhat reasonably) continue to use bullseye for another three years.

def assert_network_exists(compose, net_name):
podman_version = sv.Version(compose.podman_version)
if sv.SimpleSpec('<3.1.0').match(podman_version):
output = compose.podman.output([], "network", ["ls"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be indented by 4 spaces. Right now it's 6.

if sv.SimpleSpec('<3.1.0').match(podman_version):
output = compose.podman.output([], "network", ["ls"])
offset = None
for raw_line in output.splitlines():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output parsing should be moved to separate function and a unit tests added for it.

@p12tic
Copy link
Collaborator

p12tic commented Mar 8, 2024

@paulmillar Are you still using podman-compose on bullseye? I would be open to supporting bullseye version of podman if someone would be willing to setup testing in bullseye and fix other issues found.

Right now I'm aware that podman-compose requires python 3.11 due some usages of asyncio. Probably there are equivalents that can be used on older Python. We need to support 3.9 if bullseye is considered.

After this it's probably almost trivial to add some github actions matrix lines to enable support for bookworm too.

Copy link
Collaborator

@p12tic p12tic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests.

@paulmillar
Copy link
Author

Hi @p12tic ,

Are you still using podman-compose on bullseye?

No. I've subsequently updated and I'm now using bookworm.

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 this pull request may close these issues.

None yet

3 participants