Skip to content

Commit c5d3901

Browse files
timcCarpenter, Timaarnphm
authored
fix(container): podman virtual machine healthcheck (bentoml#3575) (bentoml#3576)
Only check for state machine on Windows and MacOS. Co-authored-by: Carpenter, Tim <[email protected]> Co-authored-by: Aaron Pham <[email protected]>
1 parent a61379a commit c5d3901

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/bentoml/_internal/container/podman.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import subprocess
77
from typing import TYPE_CHECKING
88

9+
import psutil
10+
911
from .base import Arguments
1012
from .buildah import ENV
1113

@@ -32,16 +34,20 @@ def health() -> bool:
3234
"Podman not found. Make sure it is installed and in your PATH. See https://podman.io/getting-started/installation"
3335
)
3436
return False
35-
# check if podman machine is running.
36-
output = (
37-
subprocess.check_output(
38-
[client, "machine", "info", "--format", "{{json .Host.MachineState}}"]
37+
38+
if psutil.MACOS or psutil.WINDOWS:
39+
# check if podman machine is running.
40+
output = (
41+
subprocess.check_output(
42+
[client, "machine", "info", "--format", "{{json .Host.MachineState}}"]
43+
)
44+
.decode("utf-8")
45+
.strip("\n&#34;") # strip quotation marks from JSON format.
46+
.lower()
3947
)
40-
.decode("utf-8")
41-
.strip("\n&#34;") # strip quotation marks from JSON format.
42-
.lower()
43-
)
44-
return output == '"running"'
48+
return output == '"running"'
49+
else:
50+
return True
4551

4652

4753
def parse_dict_opt(d: dict[str, str]) -> str:

0 commit comments

Comments
 (0)