collect image pool results in one helper

Verify, copy and pull each repeated the same log, sort and summary loop;
one pool_collect helper now does it for all three, byte-identically.
This commit is contained in:
reyesj2 committed 2026-12-02 13:06:19 -06:00
1 parent 316bfbeadc
commit 1a717897f9
1 file changed
+26 -57
+26 -57
View File
@@ -422,6 +422,29 @@ pool_failed() { # pool_failed <phase> <image>...
return 1
}
# Append one phase's per-image logs, then name what failed or was skipped.
pool_collect() { # pool_collect <phase> <image>...; non-zero if any did not pass
local phase=$1
shift
local img failed=0
local -a bad=() skipped=()
for img in "$@"; do
cat "$SIGNPATH/$img.$phase.log" >> "$LOG_FILE" 2>/dev/null
if [ ! -f "$SIGNPATH/$img.$phase.rc" ]; then
skipped+=("$img")
failed=1
elif [ "$(cat "$SIGNPATH/$img.$phase.rc" 2>/dev/null)" != "0" ]; then
bad+=("$img")
failed=1
fi
done
if [ "$failed" -ne 0 ]; then
echo "$phase failed: ${bad[*]:-none}; skipped: ${skipped[*]:-none}" >> "$LOG_FILE" 2>&1
return 1
fi
return 0
}
launch_pool() {
local func=$1
local phase=$2
@@ -588,25 +611,7 @@ update_docker_containers() {
launch_pool verify_trusted_image verify "$jobs" "$progress_hook" "${TRUSTED_CONTAINERS[@]}"
local verify_failed=0
local -a verify_bad=() verify_skipped=()
for i in "${TRUSTED_CONTAINERS[@]}"; do
cat "$SIGNPATH/$i.verify.log" >> "$LOG_FILE" 2>/dev/null
if [ ! -f "$SIGNPATH/$i.verify.rc" ]; then
# No .rc: the pool skipped it, or the job died before writing one.
# Fail closed either way; a skipped image means another one failed.
verify_skipped+=("$i")
verify_failed=1
elif [ "$(cat "$SIGNPATH/$i.verify.rc" 2>/dev/null)" != "0" ]; then
verify_bad+=("$i")
verify_failed=1
fi
done
if [ "$verify_failed" -ne 0 ]; then
# Last line of the phase: the per-image logs above would bury it.
echo "verify failed: ${verify_bad[*]:-none}; skipped: ${verify_skipped[*]:-none}" >> "$LOG_FILE" 2>&1
exit 1
fi
pool_collect verify "${TRUSTED_CONTAINERS[@]}" || exit 1
# Verify only from here: no copy and no local pull.
if [[ -n "$SKIP_TAGPUSH" ]]; then
@@ -654,25 +659,7 @@ update_docker_containers() {
echo "Copying images (batch $wave_no): ${wave[*]}" >> "$LOG_FILE" 2>&1
launch_pool copy_verified_image copy "$jobs" "" "${wave[@]}"
local wave_failed=0
local -a copy_bad=() copy_skipped=()
for img in "${wave[@]}"; do
cat "$SIGNPATH/$img.copy.log" >> "$LOG_FILE" 2>/dev/null
if [ ! -f "$SIGNPATH/$img.copy.rc" ]; then
# No .rc: the pool skipped it, or the job died before writing one.
# Fail closed either way; a skipped image means another one failed.
copy_skipped+=("$img")
wave_failed=1
elif [ "$(cat "$SIGNPATH/$img.copy.rc" 2>/dev/null)" != "0" ]; then
copy_bad+=("$img")
wave_failed=1
fi
done
if [ "$wave_failed" -ne 0 ]; then
# Last line of the phase: the per-image logs above would bury it.
echo "copy failed: ${copy_bad[*]:-none}; skipped: ${copy_skipped[*]:-none}" >> "$LOG_FILE" 2>&1
exit 1
fi
pool_collect copy "${wave[@]}" || exit 1
for img in "${wave[@]}"; do
record_shared_blobs "$img" "${ref_manifest[$img]}" pushed_blob_repo
done
@@ -680,23 +667,5 @@ update_docker_containers() {
done
launch_pool pull_verified_image pull "$jobs" "" "${TRUSTED_CONTAINERS[@]}"
local pull_failed=0
local -a pull_bad=() pull_skipped=()
for i in "${TRUSTED_CONTAINERS[@]}"; do
cat "$SIGNPATH/$i.pull.log" >> "$LOG_FILE" 2>/dev/null
if [ ! -f "$SIGNPATH/$i.pull.rc" ]; then
# No .rc: the pool skipped it, or the job died before writing one.
# Fail closed either way; a skipped image means another one failed.
pull_skipped+=("$i")
pull_failed=1
elif [ "$(cat "$SIGNPATH/$i.pull.rc" 2>/dev/null)" != "0" ]; then
pull_bad+=("$i")
pull_failed=1
fi
done
if [ "$pull_failed" -ne 0 ]; then
# Last line of the phase: the per-image logs above would bury it.
echo "pull failed: ${pull_bad[*]:-none}; skipped: ${pull_skipped[*]:-none}" >> "$LOG_FILE" 2>&1
exit 1
fi
pool_collect pull "${TRUSTED_CONTAINERS[@]}" || exit 1
}