diff --git a/scripts/merge-group-evicted.sh b/scripts/merge-group-evicted.sh index e38936d1c..a5726ecc0 100755 --- a/scripts/merge-group-evicted.sh +++ b/scripts/merge-group-evicted.sh @@ -119,7 +119,16 @@ while :; do exit 0 fi - [ "$polls" -lt "$max_polls" ] || - fail "#${number} had not merged, or the queue had not drained, after ${max_polls} reads; its outcome is unknown" + # The bound ends in one of two different states (#5014), and the failure names which, + # with the queued count it last read: this group's own entry may still be queued, or + # the PR has left and the answer is waiting for the queue to drain. In the second + # case main is NOT restored, so production can keep the unmerged artifact until a + # later deploy replaces it. + if [ "$polls" -ge "$max_polls" ]; then + if [ -z "$left" ]; then + fail "#${number}: this merge group's own queue entry was still queued after ${max_polls} reads (last read: ${queued} entries queued); it had neither merged nor left, so its outcome is unknown" + fi + fail "#${number} left the merge queue (${left}), but the queue had not drained after ${max_polls} reads (last read: ${queued} entries queued); main was not restored, so production may still run this PR's unmerged artifact until a later deploy replaces it" + fi sleep "$poll_seconds" done diff --git a/scripts/tests/test-merge-group-evicted.sh b/scripts/tests/test-merge-group-evicted.sh index 512a12b45..c005eed0b 100755 --- a/scripts/tests/test-merge-group-evicted.sh +++ b/scripts/tests/test-merge-group-evicted.sh @@ -54,6 +54,7 @@ run_case() { STUB_CALLS="$scratch/calls" STUB_RC="$stub_rc" EVICTED_POLL_SECONDS=0 EVICTED_MAX_POLLS=5 \ EVICTED_REPOSITORY=devantler-tech/platform EVICTED_HEAD_REF="$ref" EVICTED_GROUP_CREATED_AT="$at" \ GITHUB_OUTPUT="$scratch/output" "$script" 2>&1)"; then rc=0; else rc=$?; fi + printf "%s\n" "$out" >"$scratch/stdout" got_output="$(cat "$scratch/output")" reads="$(cat "$scratch/calls")" @@ -79,6 +80,17 @@ logged() { fi } +#