Skip to content

Commit 2b72f62

Browse files
committed
ci: tidy image-build machinery and pin tap-summary via the manifest
Image-generation cleanup follow-up to the Jenkinsfile pass: - build-image.sh: fix the stale --push hint (it pointed at the removed CI_IMAGE-default scheme; the main pipeline now auto-discovers the tag via the content-addressed registry probe). Make --help self-adjust off the comment block instead of a hardcoded sed line range that had already drifted past the header. - Dockerfile: drop the duplicate trailing `WORKDIR /workspace`; switch the linux-firmware step from `set -eux` to `set -eu` (no self-added -x). - Pin pcolby/tap-summary's summary.gawk in ci/image-manifest as tap_summary_sha, consistent with the other external pins, instead of a defaulted Dockerfile ARG. Plumb TAP_SUMMARY_GIT_SHA as a fail-closed build-arg through the Dockerfile, build-image.sh (buildx + kaniko handoff), and the Jenkinsfile kaniko step. Also drop the generated colossus layer's `set -eux` to `set -eu`.
1 parent d8a21c1 commit 2b72f62

4 files changed

Lines changed: 38 additions & 18 deletions

File tree

ci/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
# root, not just write permission).
2525
# RUN_AS_GID=<int> — primary gid for `builder` and the CI
2626
# pod (pinned as run_as_gid).
27-
# Optional build-arg:
28-
# TAP_SUMMARY_GIT_SHA=<commit> — pin pcolby/tap-summary summary.gawk.
27+
# TAP_SUMMARY_GIT_SHA=<commit> — pin pcolby/tap-summary summary.gawk
28+
# (pinned in ci/image-manifest as
29+
# tap_summary_sha).
2930
#
3031
# Buildroot *sources* live in /opt/buildroot; the build is pre-staged in the
3132
# image at /opt/buildroot-out (host + target packages, rootfs staging, etc.).
@@ -102,7 +103,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
102103

103104
# TAP summary script (pcolby/tap-summary, MIT): fetch at image build so agents need no runtime download.
104105
# Upstream: https://github.com/pcolby/tap-summary
105-
ARG TAP_SUMMARY_GIT_SHA=ec9de3f6393083dd89052d519a23b2999a75be9b
106+
# Required build-arg from ci/image-manifest (tap_summary_sha=). No default,
107+
# like the other pins: a missing --build-arg fails the build loudly rather
108+
# than silently baking in a stale formatter commit.
109+
ARG TAP_SUMMARY_GIT_SHA
110+
RUN test -n "${TAP_SUMMARY_GIT_SHA}" || (echo "ERROR: TAP_SUMMARY_GIT_SHA --build-arg is required (pin lives in ci/image-manifest as tap_summary_sha)" >&2 && exit 1)
106111
RUN mkdir -p /usr/local/share/nova-ci \
107112
&& curl -fsSL -o /usr/local/share/nova-ci/tap-summary.gawk \
108113
"https://raw.githubusercontent.com/pcolby/tap-summary/${TAP_SUMMARY_GIT_SHA}/summary.gawk" \
@@ -174,7 +179,7 @@ RUN chmod 0700 /opt/nova-overlay/root/.ssh \
174179
# value: bumping the manifest pin is the only supported way to refresh the
175180
# firmware blobs in the agent image. Image build fails closed without it.
176181
ARG LINUX_FIRMWARE_GIT_SHA
177-
RUN set -eux; \
182+
RUN set -eu; \
178183
test -n "${LINUX_FIRMWARE_GIT_SHA}" || (echo "ERROR: LINUX_FIRMWARE_GIT_SHA --build-arg is required (pin lives in ci/image-manifest)" >&2 && exit 1); \
179184
git clone --no-checkout --no-tags --filter=blob:none --sparse \
180185
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git \
@@ -233,5 +238,3 @@ WORKDIR /workspace
233238
# Colossus CLI is internal and added on top by ci/build-image.sh:
234239
# COPY --chmod=0755 colossus /usr/local/bin/colossus
235240
# The Jenkinsfile expects `colossus` on PATH for Provision.
236-
237-
WORKDIR /workspace

ci/Jenkinsfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ def ensureImage(Map pins) {
10241024

10251025
// pins were parsed + format-validated by the caller (Phase 1). Here we
10261026
// only assert that every pin the image build consumes is present.
1027-
['buildroot_tag', 'linux_firmware_sha', 'colossus_version',
1027+
['buildroot_tag', 'linux_firmware_sha', 'tap_summary_sha', 'colossus_version',
10281028
'run_as_uid', 'run_as_gid'].each { k ->
10291029
if (!pins[k]) error("imageBuild: ci/image-manifest is missing required pin '${k}'")
10301030
}
@@ -1099,6 +1099,7 @@ def ensureImage(Map pins) {
10991099
--destination='${imageFull}' \\
11001100
--build-arg BUILDROOT_TAG=${pins.buildroot_tag} \\
11011101
--build-arg LINUX_FIRMWARE_GIT_SHA=${pins.linux_firmware_sha} \\
1102+
--build-arg TAP_SUMMARY_GIT_SHA=${pins.tap_summary_sha} \\
11021103
--build-arg RUN_AS_UID=${pins.run_as_uid} \\
11031104
--build-arg RUN_AS_GID=${pins.run_as_gid} \\
11041105
--snapshot-mode=redo \\

ci/build-image.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,20 @@
2424
# into DIR, ready for `kaniko --context=dir://DIR --dockerfile=DIR/Dockerfile`.
2525
# Skips the `docker buildx build`, the smoke check, and the push.
2626
#
27-
# Pin resolution: BUILDROOT_TAG, LINUX_FIRMWARE_GIT_SHA, COLOSSUS_VERSION
28-
# default to the values pinned in ci/image-manifest. They can be overridden
29-
# via environment variable when iterating locally (e.g. to test a newer
30-
# linux-firmware sha before updating the pin). The first two are also passed
31-
# through as --build-arg to docker buildx; the third drives the colossus
32-
# tarball download and the private-layer COPY in the generated Dockerfile.
27+
# Pin resolution: BUILDROOT_TAG, LINUX_FIRMWARE_GIT_SHA, TAP_SUMMARY_GIT_SHA,
28+
# COLOSSUS_VERSION, RUN_AS_UID and RUN_AS_GID default to the values pinned in
29+
# ci/image-manifest. They can be overridden via environment variable when
30+
# iterating locally (e.g. to test a newer linux-firmware sha before updating
31+
# the pin). All but COLOSSUS_VERSION are passed through as --build-arg to
32+
# docker buildx / kaniko; COLOSSUS_VERSION instead drives the colossus tarball
33+
# download and the private-layer COPY in the generated Dockerfile.
3334
#
3435
# Environment overrides:
3536
# REGISTRY gitlab-master.nvidia.com:5005
3637
# REPO epeer/nova-test/nova-kernel-ci
3738
# BUILDROOT_TAG upstream buildroot tag (default: manifest pin).
3839
# LINUX_FIRMWARE_GIT_SHA linux-firmware commit sha (default: manifest pin).
40+
# TAP_SUMMARY_GIT_SHA pcolby/tap-summary summary.gawk commit (default: manifest pin).
3941
# COLOSSUS_VERSION Colossus CLI version to install (default: manifest pin).
4042
# RUN_AS_UID uid for the in-image `builder` user; matches the
4143
# CI pod's runAsUser so the pre-built buildroot tree
@@ -78,7 +80,11 @@ while [[ $# -gt 0 ]]; do
7880
--stage-only) STAGE_ONLY_DIR="$2"; shift 2 ;;
7981
--stage-only=*) STAGE_ONLY_DIR="${1#--stage-only=}"; shift ;;
8082
-h|--help)
81-
sed -n '2,55p' "$0" | sed 's/^# \{0,1\}//'
83+
# Print the leading comment header (everything from the line after the
84+
# shebang down to the first non-comment line), stripping the "# " prefix.
85+
# Driven off the comment block itself so it can't drift out of sync with
86+
# the header's length the way a hardcoded line range did.
87+
awk 'NR==1{next} /^#/{sub(/^# ?/,"");print;next} /^[[:space:]]*$/{print;next} {exit}' "$0"
8288
exit 0
8389
;;
8490
*) echo "unknown arg: $1" >&2; exit 2 ;;
@@ -113,10 +119,11 @@ manifest_pin() {
113119
}
114120
: "${BUILDROOT_TAG:=$(manifest_pin buildroot_tag)}"
115121
: "${LINUX_FIRMWARE_GIT_SHA:=$(manifest_pin linux_firmware_sha)}"
122+
: "${TAP_SUMMARY_GIT_SHA:=$(manifest_pin tap_summary_sha)}"
116123
: "${COLOSSUS_VERSION:=$(manifest_pin colossus_version)}"
117124
: "${RUN_AS_UID:=$(manifest_pin run_as_uid)}"
118125
: "${RUN_AS_GID:=$(manifest_pin run_as_gid)}"
119-
for v in BUILDROOT_TAG LINUX_FIRMWARE_GIT_SHA COLOSSUS_VERSION RUN_AS_UID RUN_AS_GID; do
126+
for v in BUILDROOT_TAG LINUX_FIRMWARE_GIT_SHA TAP_SUMMARY_GIT_SHA COLOSSUS_VERSION RUN_AS_UID RUN_AS_GID; do
120127
if [[ -z "${!v}" ]]; then
121128
echo "ERROR: ${v} is empty after manifest resolution; check ${MANIFEST}" >&2
122129
exit 1
@@ -218,7 +225,7 @@ fi
218225
echo "# --- private layer: colossus CLI ${COLOSSUS_VER} (PyInstaller bundle) ---"
219226
echo "# Tarball contains a colossus-cli/ directory with colossus + _internal/."
220227
echo "COPY colossus-cli.tar.gz /tmp/colossus-cli.tar.gz"
221-
echo "RUN set -eux; \\"
228+
echo "RUN set -eu; \\"
222229
echo " mkdir -p /opt; \\"
223230
echo " tar -xzf /tmp/colossus-cli.tar.gz -C /opt; \\"
224231
echo " chmod -R a+rX /opt/colossus-cli; \\"
@@ -239,6 +246,7 @@ if [[ -n "${STAGE_ONLY_DIR}" ]]; then
239246
echo " /kaniko/executor --context=dir://${BUILD_CTX} --dockerfile=${BUILD_CTX}/Dockerfile \\"
240247
echo " --build-arg BUILDROOT_TAG=${BUILDROOT_TAG} \\"
241248
echo " --build-arg LINUX_FIRMWARE_GIT_SHA=${LINUX_FIRMWARE_GIT_SHA} \\"
249+
echo " --build-arg TAP_SUMMARY_GIT_SHA=${TAP_SUMMARY_GIT_SHA} \\"
242250
echo " --build-arg RUN_AS_UID=${RUN_AS_UID} \\"
243251
echo " --build-arg RUN_AS_GID=${RUN_AS_GID} \\"
244252
echo " --destination=${IMAGE}"
@@ -267,6 +275,7 @@ echo "==> docker build --platform ${PLATFORM} -t ${IMAGE}"
267275
--load \
268276
--build-arg "BUILDROOT_TAG=${BUILDROOT_TAG}" \
269277
--build-arg "LINUX_FIRMWARE_GIT_SHA=${LINUX_FIRMWARE_GIT_SHA}" \
278+
--build-arg "TAP_SUMMARY_GIT_SHA=${TAP_SUMMARY_GIT_SHA}" \
270279
--build-arg "RUN_AS_UID=${RUN_AS_UID}" \
271280
--build-arg "RUN_AS_GID=${RUN_AS_GID}" \
272281
-t "${IMAGE}" \
@@ -308,8 +317,9 @@ if [[ "${PUSH}" -eq 1 ]]; then
308317
"${DOCKER}" push "${IMAGE}"
309318
echo
310319
echo "Pushed ${IMAGE}"
311-
echo "Bump Jenkinsfile CI_IMAGE default (or pass it via Build with Parameters):"
312-
echo " ${IMAGE}"
320+
echo "The main pipeline auto-discovers this tag: Phase 1 hashes ci/image-manifest"
321+
echo "+ inputs and, on its next run for these same inputs, the registry probe"
322+
echo "hits this tag and skips the kaniko rebuild. No Jenkinsfile edit needed."
313323
else
314324
echo
315325
echo "Built ${IMAGE} (not pushed; pass --push to push)."

ci/image-manifest

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ linux_firmware_sha=adb6dceb45b98c4149e1ce68fc1a5f394fd67695
4141
# folder at the URL above and update this pin.
4242
colossus_version=2.3.0
4343

44+
# TAP summary formatter (pcolby/tap-summary, MIT). summary.gawk is fetched
45+
# from raw.githubusercontent.com at this commit inside the Dockerfile and
46+
# installed to /usr/local/share/nova-ci/tap-summary.gawk. Bump to pull a
47+
# newer formatter; pinning keeps the agent image reproducible.
48+
tap_summary_sha=ec9de3f6393083dd89052d519a23b2999a75be9b
49+
4450
# Runtime NIS uid/gid the nova-ci container will run under at CI time
4551
# (Phase 2 podSpec runAsUser/runAsGroup, also the owner of the NFS
4652
# /scratch export). The Dockerfile creates the `builder` user with

0 commit comments

Comments
 (0)