@@ -285,7 +285,7 @@ get_content_arg_names() {
285285 fi | awk ' NF && !seen[$0]++'
286286}
287287
288- compute_ci_base_content_hash () {
288+ compute_ci_base_content_hash_once () {
289289 local -a content_paths=()
290290 local -a content_args=()
291291 local dockerfile=" ${CI_BASE_DOCKERFILE:- } "
@@ -301,7 +301,8 @@ compute_ci_base_content_hash() {
301301 if [[ -n " ${dockerfile} " ]]; then
302302 printf ' dockerfile:%s\n' " ${dockerfile} "
303303 printf ' resolved-build-args:\n'
304- hash_dockerfile_arg_values " ${dockerfile} " " ${content_args[@]} "
304+ hash_dockerfile_arg_values " ${dockerfile} " " ${content_args[@]} " \
305+ || return 1
305306 if [[ -n " ${stages} " ]]; then
306307 printf ' dockerfile-stages:%s\n' " ${stages} "
307308 if [[ -f " ${dockerfile} " ]]; then
@@ -314,6 +315,53 @@ compute_ci_base_content_hash() {
314315 } | sha256sum | cut -d' ' -f1
315316}
316317
318+ compute_ci_base_content_hash () {
319+ local attempts=" ${CI_BASE_HASH_ATTEMPTS:- 3} "
320+ local delay_secs=" ${CI_BASE_HASH_RETRY_DELAY:- 5} "
321+ local attempt=0
322+ local hash=" "
323+ local failed=0
324+ local -a hashes=()
325+
326+ if [[ ! " ${attempts} " =~ ^[1-9][0-9]* $ ]]; then
327+ echo " Invalid CI_BASE_HASH_ATTEMPTS: ${attempts} " >&2
328+ return 1
329+ fi
330+ if [[ ! " ${delay_secs} " =~ ^[0-9]+$ ]]; then
331+ echo " Invalid CI_BASE_HASH_RETRY_DELAY: ${delay_secs} " >&2
332+ return 1
333+ fi
334+
335+ for (( attempt = 1 ; attempt <= attempts; attempt++ )) ; do
336+ if ! hash=$( compute_ci_base_content_hash_once) ; then
337+ echo " ci_base content hash calculation ${attempt} /${attempts} failed" >&2
338+ failed=1
339+ else
340+ hashes+=(" ${hash} " )
341+ echo " ci_base content hash calculation ${attempt} /${attempts} : ${hash} " >&2
342+ fi
343+
344+ if (( attempt < attempts)) ; then
345+ sleep " ${delay_secs} "
346+ fi
347+ done
348+
349+ if (( failed)) || (( ${# hashes[@]} != attempts)) ; then
350+ echo " Could not calculate a reliable ci_base content hash" >&2
351+ return 1
352+ fi
353+
354+ for hash in " ${hashes[@]: 1} " ; do
355+ if [[ " ${hash} " != " ${hashes[0]} " ]]; then
356+ echo " ci_base content hash changed between calculations" >&2
357+ printf ' observed: %s\n' " ${hashes[@]} " >&2
358+ return 1
359+ fi
360+ done
361+
362+ printf ' %s\n' " ${hashes[0]} "
363+ }
364+
317365extract_dockerfile_arg_default () {
318366 local dockerfile=" $1 "
319367 local arg_name=" $2 "
@@ -366,7 +414,11 @@ hash_dockerfile_arg_values() {
366414 printf ' arg:%s=%s\n' " ${arg_name} " " ${arg_value:- <empty>} "
367415 if [[ " ${arg_name} " == " BASE_IMAGE" && -n " ${arg_value} " ]]; then
368416 digest=$( resolve_image_digest " ${arg_value} " )
369- printf ' arg:%s.digest=%s\n' " ${arg_name} " " ${digest:- unknown} "
417+ if [[ -z " ${digest} " ]]; then
418+ echo " Failed to resolve digest for BASE_IMAGE=${arg_value} " >&2
419+ return 1
420+ fi
421+ printf ' arg:%s.digest=%s\n' " ${arg_name} " " ${digest} "
370422 fi
371423 done
372424}
@@ -1898,8 +1950,8 @@ confirm_remote_image_push() {
18981950 fi
18991951
19001952 if [[ -z " ${remote_revision} " \
1901- && ${IMAGE_EXISTED_BEFORE_BUILD} -eq 0 \
1902- && image_tag_is_commit_scoped ]] ; then
1953+ && ${IMAGE_EXISTED_BEFORE_BUILD} -eq 0 ]] \
1954+ && image_tag_is_commit_scoped; then
19031955 echo " Remote image exists under a commit-scoped tag; accepting push despite missing revision label."
19041956 return 0
19051957 fi
@@ -2029,36 +2081,57 @@ upload_wheel_artifacts_if_present() {
20292081 local wheel_dir=" ./wheel-export"
20302082 local artifact_dir=" artifacts/vllm-rocm-install"
20312083 local archive_name=" vllm-rocm-install.tar.gz"
2084+ local metadata_dir=" ${wheel_dir} /.vllm-ci-artifact"
2085+ local native_base_image=" "
20322086 local whl=" "
20332087 local whl_name=" "
2088+ local -a wheels=()
20342089
20352090 if ! should_upload_wheel_artifacts; then
20362091 return 0
20372092 fi
20382093
2039- if [[ ! -d " ${wheel_dir} " ]] || ! ls " ${wheel_dir} " /* .whl > /dev/null 2>&1 ; then
2040- echo " No ROCm wheel artifacts found in ${wheel_dir} "
2041- return 0
2094+ if [[ -d " ${wheel_dir} " ]]; then
2095+ mapfile -t wheels < <( find " ${wheel_dir} " -maxdepth 1 -type f -name ' *.whl' -print)
2096+ fi
2097+ if [[ ${# wheels[@]} -ne 1 ]]; then
2098+ echo " Expected exactly one ROCm wheel in ${wheel_dir} ; found ${# wheels[@]} " >&2
2099+ return 1
2100+ fi
2101+ whl=" ${wheels[0]} "
2102+ whl_name=$( basename " ${whl} " )
2103+ native_base_image=" ${CI_BASE_IMAGE_TAG_COMMIT_REF:- ${CI_BASE_IMAGE:- } } "
2104+ if [[ -z " ${native_base_image} " ]]; then
2105+ echo " Native ROCm artifact requires a ci_base image reference" >&2
2106+ return 1
20422107 fi
20432108
20442109 echo " --- :package: Uploading ROCm vLLM install artifact"
2045- mkdir -p " ${artifact_dir} "
2110+ rm -rf " ${artifact_dir} " " ${metadata_dir} "
2111+ mkdir -p " ${artifact_dir} " " ${metadata_dir} "
2112+
2113+ printf ' %s\n' " ${BUILDKITE_COMMIT:- local} " > " ${metadata_dir} /commit.txt"
2114+ printf ' %s\n' " ${native_base_image} " > " ${metadata_dir} /native-base-image.txt"
2115+ printf ' %s\n' " ${CI_BASE_IMAGE:- } " > " ${metadata_dir} /ci-base-image.txt"
2116+ printf ' %s\n' " ${IMAGE_TAG:- } " > " ${metadata_dir} /fallback-image.txt"
2117+ printf ' %s\n' " ${whl_name} " > " ${metadata_dir} /wheel-filename.txt"
20462118
20472119 tar -C " ${wheel_dir} " -czf " ${artifact_dir} /${archive_name} " .
2120+ (
2121+ cd " ${artifact_dir} "
2122+ sha256sum " ${archive_name} " > " ${archive_name} .sha256"
2123+ )
20482124 echo " Created ${archive_name} : $( du -sh " ${artifact_dir} /${archive_name} " | cut -f1) "
2049- printf ' %s\n' " ${CI_BASE_IMAGE:- } " > " ${artifact_dir} /ci-base-image.txt"
2050- printf ' %s\n' " ${IMAGE_TAG:- } " > " ${artifact_dir} /fallback-image.txt"
2051-
2052- for whl in " ${wheel_dir} " /* .whl; do
2053- [[ -f " ${whl} " ]] || continue
2054- whl_name=$( basename " ${whl} " )
2055- cp " ${whl} " " ${artifact_dir} /${whl_name} "
2056- echo " Copied ${whl_name} : $( du -sh " ${artifact_dir} /${whl_name} " | cut -f1) "
2057- done
2125+ cp " ${metadata_dir} " /* .txt " ${artifact_dir} /"
2126+ cp " ${whl} " " ${artifact_dir} /${whl_name} "
2127+ echo " Copied ${whl_name} : $( du -sh " ${artifact_dir} /${whl_name} " | cut -f1) "
20582128
20592129 if command -v buildkite-agent > /dev/null 2>&1 ; then
2060- buildkite-agent artifact upload " ${artifact_dir} /*"
2130+ buildkite-agent artifact upload " ${artifact_dir} /*" || return 1
20612131 echo " ROCm vLLM install artifacts uploaded to ${artifact_dir} /"
2132+ elif [[ " ${BUILDKITE:- false} " == " true" ]]; then
2133+ echo " buildkite-agent not found; cannot upload required ROCm artifacts" >&2
2134+ return 1
20622135 else
20632136 echo " Not in Buildkite, skipping artifact upload"
20642137 fi
@@ -2090,6 +2163,11 @@ main() {
20902163 echo " BAKE_PRINT_ONLY=1 set; skipping build"
20912164 return 0
20922165 fi
2166+ if should_upload_wheel_artifacts; then
2167+ # wheel-export is an output directory, not a BuildKit cache. Starting
2168+ # clean prevents a failed/retried export from packaging a stale wheel.
2169+ rm -rf ./wheel-export
2170+ fi
20932171 seed_dependency_caches_if_needed
20942172 run_bake
20952173 upload_wheel_artifacts_if_present
0 commit comments