Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion system_files/bluefin/usr/libexec/bonedigger-report
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ read_image_info() {
IMAGE_REF="$(read_image_field image-ref)"
IMAGE_TAG="$(read_image_field image-tag)"
IMAGE_FLAVOR="$(read_image_field image-flavor)"

local booted_ref=""
if command -v jq &>/dev/null; then
booted_ref="$(printf '%s' "$BOOTC_JSON" | \
jq -r '.status.booted.image.image.image // empty' 2>/dev/null || true)"
fi
if [[ -n "$booted_ref" ]]; then
local ref_without_digest="${booted_ref%@*}"
local image_component="${ref_without_digest##*/}"
IMAGE_REF="$booted_ref"
if [[ "$image_component" == *:* ]]; then
IMAGE_NAME="${image_component%:*}"
IMAGE_TAG="${image_component##*:}"
else
IMAGE_NAME="$image_component"
IMAGE_TAG="unknown"
fi
fi
}

read_boot_status() {
Expand Down Expand Up @@ -662,6 +680,7 @@ start_bug_report() {
local description
local reproduction

read_boot_status
read_image_info
# read_boot_status must run before routing: it corrects IMAGE_TAG
# from the booted bootc image, and lts routing keys off the tag.
Expand Down Expand Up @@ -704,8 +723,8 @@ main() {

parse_args "$@"
if [[ -n "$CONFIRM_TARGET" ]]; then
read_image_info
read_boot_status
read_image_info
route_issue_repo
parse_confirm_target "$CONFIRM_TARGET" "$BUG_REPO"
confirm_report "$CONFIRM_ISSUE" "$CONFIRM_REPO"
Expand Down
34 changes: 34 additions & 0 deletions tests/test_bonedigger_report.bats
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,40 @@ teardown() {
[ "$output" = "projectbluefin/common" ]
}

@test "image info prefers booted image reference over stale build metadata" {
printf '%s\n' '{"image-name":"bluefin","image-tag":"latest","image-ref":"ghcr.io/projectbluefin/bluefin:latest","image-flavor":"main"}' \
> "$WORKDIR/stale-image-info.json"

run bash -c '
source "$1"
IMAGE_INFO_FILE="$2"
BOOTC_JSON="$3"
read_image_info
printf "%s|%s|%s" "$IMAGE_NAME" "$IMAGE_TAG" "$IMAGE_REF"
' _ "$BONEDIGGER_SCRIPT" "$WORKDIR/stale-image-info.json" \
'{"status":{"booted":{"image":{"image":{"image":"ghcr.io/projectbluefin/dakota:stable"}}}}}'

[ "$status" -eq 0 ]
[ "$output" = "dakota|stable|ghcr.io/projectbluefin/dakota:stable" ]
}

@test "image info falls back when no booted image is reported" {
printf '%s\n' '{"image-name":"bluefin","image-tag":"latest","image-ref":"ghcr.io/projectbluefin/bluefin:latest","image-flavor":"main"}' \
> "$WORKDIR/stale-image-info.json"

run bash -c '
source "$1"
IMAGE_INFO_FILE="$2"
BOOTC_JSON="$3"
read_image_info
printf "%s|%s" "$IMAGE_NAME" "$IMAGE_TAG"
' _ "$BONEDIGGER_SCRIPT" "$WORKDIR/stale-image-info.json" \
'{"status":{"booted":null}}'

[ "$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"
Expand Down
Loading