Skip to content

Commit be12efb

Browse files
committed
fix buildkit behavior + code rabbit feedback
Signed-off-by: Zoe Blevins <zblevins@nvidia.com>
1 parent 2842038 commit be12efb

3 files changed

Lines changed: 61 additions & 4 deletions

File tree

.github/workflows/kind-integration.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,36 @@ jobs:
120120
run: |
121121
for attempt in 1 2 3; do
122122
echo "Attempt ${attempt} of 3"
123-
if timeout --kill-after=1m 15m uv run pytest "${TEST_PATH}" -v \
123+
results_file="integration-test-results-${attempt}.xml"
124+
set +e
125+
timeout --kill-after=1m 15m uv run pytest "${TEST_PATH}" -v \
124126
--ci \
125127
--nv-config-manager-namespace "${NV_CONFIG_MANAGER_NAMESPACE}" \
126128
--tb=short \
127-
--junitxml=integration-test-results.xml; then
129+
--junitxml="${results_file}"
130+
test_status=$?
131+
set -e
132+
133+
if [ "${test_status}" -eq 0 ]; then
134+
cp -f "${results_file}" integration-test-results.xml
128135
exit 0
129136
fi
130-
if [ "${attempt}" -lt 3 ]; then
131-
sleep 10
137+
138+
if [ -f "${results_file}" ]; then
139+
cp -f "${results_file}" integration-test-results.xml
140+
fi
141+
142+
if [ "${test_status}" -eq 124 ] || \
143+
{ [ "${test_status}" -ge 128 ] && [ "${test_status}" -le 192 ]; }; then
144+
echo "Attempt ${attempt} failed with retryable status ${test_status}"
145+
if [ "${attempt}" -lt 3 ]; then
146+
sleep 10
147+
continue
148+
fi
149+
exit "${test_status}"
150+
else
151+
echo "Attempt ${attempt} failed with non-retryable status ${test_status}"
152+
exit "${test_status}"
132153
fi
133154
done
134155
exit 1

installer/src/nv_config_manager_installer/deployer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ def _build_images(self) -> None:
925925
apt_mirror_args += ["--build-arg", f"{env_var}={val}"]
926926

927927
build_env = {**os.environ, "DOCKER_BUILDKIT": "1"}
928+
build_output_args = ["--load"] if build_env.get("BUILDX_BUILDER") else []
928929
build_commands: list[_ParallelCommand] = []
929930
for name, dockerfile, context in images:
930931
build_tag = f"{name}:local"
@@ -936,6 +937,7 @@ def _build_images(self) -> None:
936937
"build",
937938
"--provenance=false",
938939
"--progress=plain",
940+
*build_output_args,
939941
"--build-context",
940942
"scripts=build/",
941943
*apt_mirror_args,

installer/tests/test_deployer.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ def fake_run(cmd, **kwargs):
462462
return MagicMock(returncode=0, stdout="", stderr="")
463463

464464
monkeypatch.setenv("NVCM_DOCKER_BUILD_PARALLELISM", "2")
465+
monkeypatch.delenv("BUILDX_BUILDER", raising=False)
465466
monkeypatch.setattr(
466467
"nv_config_manager_installer.deployer._run_logged_parallel",
467468
fake_run_logged_parallel,
@@ -486,12 +487,45 @@ def fake_run(cmd, **kwargs):
486487
command.cmd[:4] == ["docker", "build", "--provenance=false", "--progress=plain"]
487488
for command in commands
488489
)
490+
assert all("--load" not in command.cmd for command in commands)
489491
assert all(command.timeout == 900 for command in commands)
490492
assert all(command.env and command.env["DOCKER_BUILDKIT"] == "1" for command in commands)
491493
assert len(run_commands) == 6
492494
assert all(cmd[:2] == ["docker", "tag"] for cmd in run_commands)
493495
assert deployer._local_image_tags["nv-config-manager-ui"].startswith("sha-")
494496

497+
def test_build_images_loads_buildx_container_outputs(self, monkeypatch):
498+
parallel_calls: list[list[_ParallelCommand]] = []
499+
500+
def fake_run_logged_parallel(commands, step, callback, *, max_parallel, **kwargs):
501+
parallel_calls.append(commands)
502+
for command in commands:
503+
callback.on_log(f"[{command.label}] completed in 0s")
504+
505+
monkeypatch.setenv("BUILDX_BUILDER", "ci-builder")
506+
monkeypatch.setattr(
507+
"nv_config_manager_installer.deployer._run_logged_parallel",
508+
fake_run_logged_parallel,
509+
)
510+
monkeypatch.setattr(
511+
"nv_config_manager_installer.deployer._get_image_digest_tag",
512+
lambda image: "",
513+
)
514+
515+
deployer = Deployer(
516+
_make_config(),
517+
DeployOptions(build_images=True),
518+
RecordingCallback(),
519+
)
520+
deployer._build_images()
521+
522+
commands = parallel_calls[0]
523+
assert len(commands) == 6
524+
assert all("--load" in command.cmd for command in commands)
525+
assert all(
526+
command.env and command.env["BUILDX_BUILDER"] == "ci-builder" for command in commands
527+
)
528+
495529

496530
class TestKindImageLoading:
497531
def test_load_kind_tags_arch_specific_loader_image_as_canonical(self, monkeypatch):

0 commit comments

Comments
 (0)