|
18 | 18 | # OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE=... |
19 | 19 | # OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE_PULL_POLICY=Always|IfNotPresent|Never |
20 | 20 | # |
21 | | -# The default community sandbox image uses :latest and is pulled with Always so |
22 | | -# local e2e runs do not reuse stale images that drift from the repo toolchain. |
| 21 | +# The default community sandbox image uses :latest. This wrapper refreshes it |
| 22 | +# before starting the gateway, while the Docker driver defaults to IfNotPresent |
| 23 | +# so local Dockerfile-built images remain usable. |
23 | 24 |
|
24 | 25 | set -euo pipefail |
25 | 26 |
|
@@ -367,14 +368,21 @@ image_uses_latest_tag() { |
367 | 368 | [[ "${last_component}" == *:latest ]] |
368 | 369 | } |
369 | 370 |
|
370 | | -default_sandbox_pull_policy() { |
| 371 | +ensure_sandbox_image_available() { |
371 | 372 | local image=$1 |
372 | 373 |
|
373 | 374 | if image_uses_latest_tag "${image}"; then |
374 | | - printf '%s\n' "Always" |
375 | | - else |
376 | | - printf '%s\n' "IfNotPresent" |
| 375 | + echo "Refreshing latest sandbox image ${image}..." |
| 376 | + docker_pull_with_retry "${image}" |
| 377 | + return |
377 | 378 | fi |
| 379 | + |
| 380 | + if docker image inspect "${image}" >/dev/null 2>&1; then |
| 381 | + return |
| 382 | + fi |
| 383 | + |
| 384 | + echo "Pulling ${image}..." |
| 385 | + docker_pull_with_retry "${image}" |
378 | 386 | } |
379 | 387 |
|
380 | 388 | DAEMON_ARCH="$(normalize_arch "$(docker info --format '{{.Architecture}}' 2>/dev/null || true)")" |
|
421 | 429 |
|
422 | 430 | DEFAULT_SANDBOX_IMAGE="ghcr.io/nvidia/openshell-community/sandboxes/base:latest" |
423 | 431 | SANDBOX_IMAGE="${OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE:-${OPENSHELL_SANDBOX_IMAGE:-${DEFAULT_SANDBOX_IMAGE}}}" |
424 | | -SANDBOX_IMAGE_PULL_POLICY="${OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE_PULL_POLICY:-${OPENSHELL_SANDBOX_IMAGE_PULL_POLICY:-}}" |
425 | | -if [ -z "${SANDBOX_IMAGE_PULL_POLICY}" ]; then |
426 | | - SANDBOX_IMAGE_PULL_POLICY="$(default_sandbox_pull_policy "${SANDBOX_IMAGE}")" |
427 | | -fi |
428 | | -if ! docker image inspect "${SANDBOX_IMAGE}" >/dev/null 2>&1; then |
429 | | - echo "Pulling ${SANDBOX_IMAGE}..." |
430 | | - if ! docker_pull_with_retry "${SANDBOX_IMAGE}"; then |
431 | | - echo "ERROR: sandbox image '${SANDBOX_IMAGE}' is not available." >&2 |
432 | | - exit 2 |
433 | | - fi |
| 432 | +SANDBOX_IMAGE_PULL_POLICY="${OPENSHELL_E2E_DOCKER_SANDBOX_IMAGE_PULL_POLICY:-${OPENSHELL_SANDBOX_IMAGE_PULL_POLICY:-IfNotPresent}}" |
| 433 | +if ! ensure_sandbox_image_available "${SANDBOX_IMAGE}"; then |
| 434 | + echo "ERROR: sandbox image '${SANDBOX_IMAGE}' is not available." >&2 |
| 435 | + exit 2 |
434 | 436 | fi |
435 | 437 |
|
436 | 438 | PKI_DIR="${WORKDIR}/pki" |
|
0 commit comments