Skip to content

Commit

Permalink
Merge pull request #1139 from sosy-lab/improve-errors-for-podman
Browse files Browse the repository at this point in the history
log errors to the user with more clarity
  • Loading branch information
PhilippWendler authored Dec 18, 2024
2 parents f3dcc40 + 03ba8aa commit 7d38b32
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions contrib/vcloud/podman_containerized_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,50 @@ def _init_container(
"Command to start container: %s",
shlex.join(map(str, command)),
)
res = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
check=True,
)
container_id = res.stdout.decode().strip()
try:
res = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
check=True,
)
except subprocess.CalledProcessError as e:
raise BenchExecException(
"Creating of the podman container failed:\n" + e.stderr.decode()
)

subprocess.run(
["podman", "init", container_id],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
stdin=subprocess.DEVNULL,
check=True,
)
container_id = res.stdout.decode().strip()

container_pid = (
try:
subprocess.run(
["podman", "inspect", "--format", "{{.State.Pid}}", container_id],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
["podman", "init", container_id],
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
check=True,
)
.stdout.decode()
.strip()
)
except subprocess.CalledProcessError as e:
raise BenchExecException(
"Initializing the podman container failed:\n" + e.stderr.decode()
)

try:
container_pid = (
subprocess.run(
["podman", "inspect", "--format", "{{.State.Pid}}", container_id],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
check=True,
)
.stdout.decode()
.strip()
)
except subprocess.CalledProcessError as e:
raise BenchExecException(
"Inspecting the podman container failed:\n" + e.stderr.decode()
)

def join_ns(namespace):
namespace = f"/proc/{container_pid}/ns/{namespace}"
Expand Down

0 comments on commit 7d38b32

Please sign in to comment.