Skip to content

Commit 7d38b32

Browse files
Merge pull request #1139 from sosy-lab/improve-errors-for-podman
log errors to the user with more clarity
2 parents f3dcc40 + 03ba8aa commit 7d38b32

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed

contrib/vcloud/podman_containerized_tool.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,50 @@ def _init_container(
7676
"Command to start container: %s",
7777
shlex.join(map(str, command)),
7878
)
79-
res = subprocess.run(
80-
command,
81-
stdout=subprocess.PIPE,
82-
stderr=subprocess.DEVNULL,
83-
stdin=subprocess.DEVNULL,
84-
check=True,
85-
)
86-
container_id = res.stdout.decode().strip()
79+
try:
80+
res = subprocess.run(
81+
command,
82+
stdout=subprocess.PIPE,
83+
stderr=subprocess.PIPE,
84+
stdin=subprocess.DEVNULL,
85+
check=True,
86+
)
87+
except subprocess.CalledProcessError as e:
88+
raise BenchExecException(
89+
"Creating of the podman container failed:\n" + e.stderr.decode()
90+
)
8791

88-
subprocess.run(
89-
["podman", "init", container_id],
90-
stdout=subprocess.DEVNULL,
91-
stderr=subprocess.DEVNULL,
92-
stdin=subprocess.DEVNULL,
93-
check=True,
94-
)
92+
container_id = res.stdout.decode().strip()
9593

96-
container_pid = (
94+
try:
9795
subprocess.run(
98-
["podman", "inspect", "--format", "{{.State.Pid}}", container_id],
99-
stdout=subprocess.PIPE,
100-
stderr=subprocess.DEVNULL,
96+
["podman", "init", container_id],
97+
stdout=subprocess.DEVNULL,
98+
stderr=subprocess.PIPE,
10199
stdin=subprocess.DEVNULL,
102100
check=True,
103101
)
104-
.stdout.decode()
105-
.strip()
106-
)
102+
except subprocess.CalledProcessError as e:
103+
raise BenchExecException(
104+
"Initializing the podman container failed:\n" + e.stderr.decode()
105+
)
106+
107+
try:
108+
container_pid = (
109+
subprocess.run(
110+
["podman", "inspect", "--format", "{{.State.Pid}}", container_id],
111+
stdout=subprocess.PIPE,
112+
stderr=subprocess.PIPE,
113+
stdin=subprocess.DEVNULL,
114+
check=True,
115+
)
116+
.stdout.decode()
117+
.strip()
118+
)
119+
except subprocess.CalledProcessError as e:
120+
raise BenchExecException(
121+
"Inspecting the podman container failed:\n" + e.stderr.decode()
122+
)
107123

108124
def join_ns(namespace):
109125
namespace = f"/proc/{container_pid}/ns/{namespace}"

0 commit comments

Comments
 (0)