Skip to content

Commit

Permalink
Check if krunkit process is running with --all-providers
Browse files Browse the repository at this point in the history
Required for newer podman machine.

Signed-off-by: Eric Curtin <[email protected]>
  • Loading branch information
ericcurtin committed Feb 7, 2025
1 parent 9d02f7d commit b6cdd99
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions ramalama/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,31 @@ def container_manager():
return engine

if available("podman"):
if sys.platform != "darwin":
if sys.platform != "darwin" or is_podman_machine_running_with_krunkit():
return "podman"

podman_machine_list = ["podman", "machine", "list"]
conman_args = ["podman", "machine", "list", "--format", "{{ .VMType }}"]
try:
output = run_cmd(podman_machine_list).stdout.decode("utf-8").strip()
if "running" not in output:
return None

output = run_cmd(conman_args).stdout.decode("utf-8").strip()
if output == "krunkit" or output == "libkrun":
return "podman"
else:
return None

except subprocess.CalledProcessError:
pass

return "podman"
return None

if available("docker"):
return "docker"

return None


def is_podman_machine_running_with_krunkit():
podman_machine_list = ["podman", "machine", "list", "--all-providers"]
conman_args = ["podman", "machine", "list", "--all-providers", "--format", "{{ .VMType }}"]
try:
output = run_cmd(podman_machine_list, ignore_stderr=True).stdout.decode("utf-8").strip()
if "running" in output:
output = run_cmd(conman_args).stdout.decode("utf-8").strip()
return output in {"krunkit", "libkrun"}
except subprocess.CalledProcessError:
pass

return False


def perror(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)

Expand Down

0 comments on commit b6cdd99

Please sign in to comment.