-
Notifications
You must be signed in to change notification settings - Fork 485
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
base: main
Are you sure you want to change the base?
Conversation
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]>
44e294d
to
1d1bae9
Compare
I think this is not needed anymore now as all recent systems have a more recent version (bookworm has 4.3.1 for example) |
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: 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"]) |
There was a problem hiding this comment.
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(): |
There was a problem hiding this comment.
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.
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs tests.
Hi @p12tic ,
No. I've subsequently updated and I'm now using bookworm. |
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:
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.