diff --git a/docs/skills/bonedigger/SKILL.md b/docs/skills/bonedigger/SKILL.md index 29dfe974..79ebc50d 100644 --- a/docs/skills/bonedigger/SKILL.md +++ b/docs/skills/bonedigger/SKILL.md @@ -48,6 +48,9 @@ configuration, or lifecycle automation owned by `projectbluefin/actions`. - Applying both queue labels, using `machine-id`, or reviving generic OTel capture. - Falling back to a browser issue form or a QR login flow. +- Parsing a booted OCI ref by cutting at the first colon: that colon may be a + registry port (`localhost:5000/bluefin:latest` → `localhost`). Strip the + digest, take the repository basename, then strip the tag — in that order. ## Verification diff --git a/system_files/bluefin/usr/libexec/bonedigger-report b/system_files/bluefin/usr/libexec/bonedigger-report index 5b566d2a..c944dcb9 100755 --- a/system_files/bluefin/usr/libexec/bonedigger-report +++ b/system_files/bluefin/usr/libexec/bonedigger-report @@ -108,6 +108,22 @@ read_boot_status() { *@*) ;; # digest-pinned ref, no tag to extract *:*) IMAGE_TAG="${booted_ref##*:}" ;; esac + if [[ -n "$booted_ref" ]]; then + # image-name from image-info.json is baked at build time and is + # equally stale after a rebase (e.g. bluefin -> dakota); derive + # it from the booted ref's repository basename so issue routing + # follows the live deployment, not the original build + # (projectbluefin/common#1009). + # Take the basename before stripping the tag: the first colon in + # a full reference can belong to a registry port + # (localhost:5000/bluefin:latest), not the tag. + local booted_repo="${booted_ref%%@*}" + local booted_name="${booted_repo##*/}" + booted_name="${booted_name%%:*}" + if [[ -n "$booted_name" ]]; then + IMAGE_NAME="$booted_name" + fi + fi else BOOTED_DIGEST="unknown" fi diff --git a/tests/test_bonedigger_report.bats b/tests/test_bonedigger_report.bats index b7de0d7f..e9b9fc9f 100755 --- a/tests/test_bonedigger_report.bats +++ b/tests/test_bonedigger_report.bats @@ -62,6 +62,75 @@ teardown() { [ "$output" = "projectbluefin/common" ] } +@test "read_boot_status derives image name, tag, and ref from a rebased booted deployment" { + cat << 'EOF' > "$WORKDIR/bin/bootc" +#!/usr/bin/bash +if [[ "$1" == "status" && "$2" == "--json" ]]; then + printf '%s' '{"status":{"booted":{"image":{"image":{"image":"ghcr.io/projectbluefin/dakota:stable"},"imageDigest":"sha256:deadbeef"}}}}' + exit 0 +fi +printf 'Booted: ghcr.io/projectbluefin/dakota:stable\n' +EOF + chmod +x "$WORKDIR/bin/bootc" + + run env PATH="$WORKDIR/bin:$PATH" bash -c ' + source "$1" + IMAGE_NAME="bluefin" + IMAGE_TAG="latest" + read_boot_status + printf "%s|%s|%s" "$IMAGE_NAME" "$IMAGE_TAG" "$IMAGE_REF" + ' _ "$BONEDIGGER_SCRIPT" + + [ "$status" -eq 0 ] + [ "$output" = "dakota|stable|ghcr.io/projectbluefin/dakota:stable" ] +} + +@test "read_boot_status strips the digest from a digest-pinned booted ref" { + cat << 'EOF' > "$WORKDIR/bin/bootc" +#!/usr/bin/bash +if [[ "$1" == "status" && "$2" == "--json" ]]; then + printf '%s' '{"status":{"booted":{"image":{"image":{"image":"ghcr.io/projectbluefin/dakota@sha256:deadbeef"},"imageDigest":"sha256:deadbeef"}}}}' + exit 0 +fi +printf 'Booted: ghcr.io/projectbluefin/dakota@sha256:deadbeef\n' +EOF + chmod +x "$WORKDIR/bin/bootc" + + run env PATH="$WORKDIR/bin:$PATH" bash -c ' + source "$1" + IMAGE_NAME="bluefin" + IMAGE_TAG="latest" + read_boot_status + printf "%s|%s" "$IMAGE_NAME" "$IMAGE_TAG" + ' _ "$BONEDIGGER_SCRIPT" + + [ "$status" -eq 0 ] + [ "$output" = "dakota|latest" ] +} + +@test "read_boot_status keeps the repository basename when the registry has a port" { + cat << 'EOF' > "$WORKDIR/bin/bootc" +#!/usr/bin/bash +if [[ "$1" == "status" && "$2" == "--json" ]]; then + printf '%s' '{"status":{"booted":{"image":{"image":{"image":"localhost:5000/bluefin:latest"},"imageDigest":"sha256:deadbeef"}}}}' + exit 0 +fi +printf 'Booted: localhost:5000/bluefin:latest\n' +EOF + chmod +x "$WORKDIR/bin/bootc" + + run env PATH="$WORKDIR/bin:$PATH" bash -c ' + source "$1" + IMAGE_NAME="dakota" + IMAGE_TAG="stable" + read_boot_status + printf "%s|%s" "$IMAGE_NAME" "$IMAGE_TAG" + ' _ "$BONEDIGGER_SCRIPT" + + [ "$status" -eq 0 ] + [ "$output" = "bluefin|latest" ] +} + @test "queue choices map to at most one supported queue label" { run bash -c 'source "$1"; queue_label_for_choice "$2"' _ \ "$BONEDIGGER_SCRIPT" "Submit to the clanker queue for machine analysis"