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
- HAF MR is squash-merged to develop → creates new commit
abc123 - HAF pipeline starts building
haf:abc123 - balance_tracker pipeline starts,
find_haf_imagefindsabc123as latest - 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=truewhen 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: AddUPSTREAM_MAX_SEARCHandUPSTREAM_OVERRIDE_TAGvariables
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_TAGworks for pinning to specific image