Skip to content

ceph-dev-pipeline: Validate given BRANCH param against derived BRANCH - #2585

Open
djgalloway wants to merge 2 commits into
mainfrom
wip-73658
Open

ceph-dev-pipeline: Validate given BRANCH param against derived BRANCH#2585
djgalloway wants to merge 2 commits into
mainfrom
wip-73658

Conversation

@djgalloway

Copy link
Copy Markdown
Contributor

Handles an unlikely edge case but handled nonetheless. This could be problematic if, for example, a user triggered ceph-dev-pipeline by specifying::

SHA1=1234abcd
BRANCH=main

But that SHA1 actually belongs to a wip branch. Now both chacra and shaman think the tip of main is 1234abcd.

Fixes: https://tracker.ceph.com/issues/73658

@djgalloway
djgalloway requested a review from dmick May 15, 2026 21:50
Handles an unlikely edge case but handled nonetheless.  This could be problematic if, for example,
a user triggered ceph-dev-pipeline by specifying::

    SHA1=1234abcd
    BRANCH=main

But that SHA1 actually belongs to a wip branch.  Now both chacra and shaman think the tip of main
is 1234abcd.

Fixes: https://tracker.ceph.com/issues/73658

Signed-off-by: David Galloway <david.galloway@ibm.com>
@djgalloway
djgalloway force-pushed the wip-73658 branch 3 times, most recently from 4a0c506 to 46c099b Compare July 16, 2026 13:57
When SHA1 is provided, the checkout prefers it over BRANCH, but
dist/branch echoed the BRANCH parameter verbatim.  If the two
disagreed, downstream consumers of dist/branch (ceph-dev-pipeline and,
through it, chacra/shaman) would record the build under the wrong ref.

The checkout already fetched every branch head into
refs/remotes/origin, so look up which branches tip the built commit
and reset BRANCH accordingly.  The given BRANCH is kept when it
already tips the commit (including when several branches share the
tip) and, with a warning, when the commit is not the tip of any
branch, since older commits are contained by many branches and there
is no unambiguous answer.

Fixes: https://tracker.ceph.com/issues/73658

Signed-off-by: David Galloway <david.galloway@ibm.com>
@djgalloway

Copy link
Copy Markdown
Contributor Author

Works

++ git rev-parse HEAD
+ echo SHA1=5b8ba02b0047ca4d778cc5ae1717639d727e94a9
+ '[' '' = true ']'
+ '[' -n 5b8ba02b0047ca4d778cc5ae1717639d727e94a9 ']'
+ mapfile -t tip_branches
++ git for-each-ref --points-at HEAD '--format=%(refname:strip=3)' refs/remotes/origin
+ '[' 1 -eq 0 ']'
+ printf '%s
' main
+ grep -qxF not-a-real-branch
++ git rev-parse HEAD
+ echo 'BRANCH=not-a-real-branch does not point at SHA1=5b8ba02b0047ca4d778cc5ae1717639d727e94a9; using main'
BRANCH=not-a-real-branch does not point at SHA1=5b8ba02b0047ca4d778cc5ae1717639d727e94a9; using main
+ BRANCH=main
+ echo BRANCH=main

https://jenkins.ceph.com/job/ceph-source-dist/6126/console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant