Add fallback logic to find-upstream-image for timing races

Summary

When a squash merge lands on develop, the new commit's image may not exist yet (upstream pipeline still building). Previously, downstream repos would fail immediately when the latest commit's image wasn't found.

The fix: Instead of checking only the latest commit, iterate through recent source commits and use the first one that has an available image.

Problem

  1. HAF MR is squash-merged to develop → creates new commit abc123
  2. HAF pipeline starts building haf:abc123
  3. balance_tracker pipeline starts, find_haf_image finds abc123 as latest
  4. Image doesn't exist yet → pipeline fails

Solution

  • Check up to 10 recent commits (configurable via --max-search)
  • Use the first commit that has an existing image
  • Set UPSTREAM_FALLBACK=true when using an older commit's image

Changes

  • scripts/bash/find-upstream-image.sh: Iterate through commits, use first with image
  • templates/source_change_detection.gitlab-ci.yml: Add UPSTREAM_MAX_SEARCH and UPSTREAM_OVERRIDE_TAG variables

New Variables

Variable Default Description
UPSTREAM_MAX_SEARCH 10 Max commits to check for existing image
UPSTREAM_OVERRIDE_TAG "" Skip lookup, use this exact tag

Backward Compatibility

Fully backward compatible. Downstream repos get the fix automatically without changes.

Test Plan

  • Run balance_tracker pipeline when HAF develop has a recent commit without image
  • Verify fallback to older commit's image works
  • Verify UPSTREAM_OVERRIDE_TAG works for pinning to specific image

Merge request reports

Loading