fix(docker): use run_docker in docker_exec, docker_cp, verify_agent_image
The rebase onto lazy-backend-imports converts existing helpers (image_exists, container_exists, etc.) to run_docker; the three new functions added in this branch still called subprocess.run directly. Switch them over for consistency.
This commit is contained in:
@@ -82,7 +82,7 @@ def docker_exec(container: str, argv: list[str], *, user: str = "") -> None:
|
|||||||
if user:
|
if user:
|
||||||
cmd += ["-u", user]
|
cmd += ["-u", user]
|
||||||
cmd += [container, *argv]
|
cmd += [container, *argv]
|
||||||
result = subprocess.run(cmd, capture_output=True, text=True, check=False)
|
result = run_docker(cmd)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
die(
|
die(
|
||||||
f"docker exec in {container} failed: "
|
f"docker exec in {container} failed: "
|
||||||
@@ -92,9 +92,7 @@ def docker_exec(container: str, argv: list[str], *, user: str = "") -> None:
|
|||||||
|
|
||||||
def docker_cp(src: str, dest: str) -> None:
|
def docker_cp(src: str, dest: str) -> None:
|
||||||
"""Run `docker cp`, dying with the command's own stderr on failure."""
|
"""Run `docker cp`, dying with the command's own stderr on failure."""
|
||||||
result = subprocess.run(
|
result = run_docker(["docker", "cp", src, dest])
|
||||||
["docker", "cp", src, dest], capture_output=True, text=True, check=False,
|
|
||||||
)
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
die(f"docker cp {src} -> {dest} failed: "
|
die(f"docker cp {src} -> {dest} failed: "
|
||||||
f"{(result.stderr or '').strip() or '<no stderr>'}")
|
f"{(result.stderr or '').strip() or '<no stderr>'}")
|
||||||
@@ -144,12 +142,7 @@ def verify_agent_image(image: str, argv: tuple[str, ...]) -> None:
|
|||||||
hasn't declared a smoke test (`AgentProviderRuntime.smoke_test`)."""
|
hasn't declared a smoke test (`AgentProviderRuntime.smoke_test`)."""
|
||||||
if not argv:
|
if not argv:
|
||||||
return
|
return
|
||||||
result = subprocess.run(
|
result = run_docker(["docker", "run", "--rm", "--entrypoint", argv[0], image, *argv[1:]])
|
||||||
["docker", "run", "--rm", "--entrypoint", argv[0], image, *argv[1:]],
|
|
||||||
capture_output=True,
|
|
||||||
text=True,
|
|
||||||
check=False,
|
|
||||||
)
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
detail = (result.stderr or result.stdout or "").strip()
|
detail = (result.stderr or result.stdout or "").strip()
|
||||||
die(
|
die(
|
||||||
|
|||||||
Reference in New Issue
Block a user