[9.4](backport #50772) Mount Git alternates in crossbuild containers#50954
[9.4](backport #50772) Mount Git alternates in crossbuild containers#50954mergify[bot] wants to merge 1 commit into
Conversation
Buildkite reference clones can borrow objects from host-side mirrors that are not visible inside Docker. Mount those alternate object directories read-only so Go VCS stamping can resolve repository metadata during crossbuilds. GenAI-Assisted: Yes Human-Reviewed: Yes Tool: Cursor, Model: GPT-5.5 Agent Mode Assisted-By: Cursor Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> (cherry picked from commit 20a6af1)
🤖 GitHub commentsJust comment with:
|
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
TL;DRBoth failed Buildkite jobs are failing before Remediation
Investigation detailsRoot CauseCurrent evidence is inconclusive for a code-level issue. Both job logs end at repository clone initialization and never show execution of Given both independent pipelines failed in the same early phase with Evidence
Verification
Follow-upIf a rerun fails with complete logs, we can classify precisely (specific hook/config/dependency) and propose a targeted patch. What is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
Proposed commit message
Mount Git alternate object directories into golang-crossbuild Docker containers.
Buildkite checks out Beats using reference clones:
That checkout shape leaves
.git/objects/info/alternatespointing at object directories under/opt/git-mirrors. The checkout itself is valid on the Buildkite host, but the crossbuild path runsgo buildinside a golang-crossbuild Docker container. Before this change, the container only had the Beats checkout mounted, not the host-side mirror object directory.Go VCS stamping (
-buildvcs, enabled by default for module builds) shells out to Git while building. In a reference clone, those Git commands may need borrowed objects from the alternate object directory to resolve repository metadata. When the alternate directory exists on the host but is not visible in the container, the repository appears incomplete from inside Docker and the build can fail even though the checkout is healthy on the agent.This also explains why the failures showed up across unrelated Filebeat Go integration test PRs. The affected builds were tied to the CI checkout/build environment, not to the PR code under test:
The fix teaches
GolangCrossBuilderto detect.git/objects/info/alternatesand mount each existing alternate object directory read-only into the crossbuild container. Absolute alternates, such as Buildkite's/opt/git-mirrors/.../objects, are mounted at the same absolute path in the container, which matches the path recorded by Git. Relative alternates are resolved relative to the checkout's object directory and mapped into the corresponding container checkout path.The behavior is intentionally narrow:
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesstresstest.shscript to run them under stress conditions and race detector to verify their stability.I have added an entry in./changelog/fragmentsusing the changelog tool.Disruptive User Impact
None expected. This only affects crossbuild Docker invocations from repositories that use Git alternates. The additional mounts are read-only and are only added when
.git/objects/info/alternatesexists.How to test this PR locally
Run the focused unit tests for the new helper behavior:
The end-to-end validation is to rerun a Buildkite
Filebeat: Go Integration Testsjob on an agent that checks out Beats withgit clone --reference /opt/git-mirrors/.... In that environment, the crossbuilddocker runcommand should include read-only volume mounts for the alternate object directories.## Related issueserror obtaining VCS status: exit status 128#50789Use cases
Buildkite agents use reference clones to avoid re-fetching the full Beats repository for every job. This PR keeps that optimization while making crossbuild containers see the same Git object graph that the host checkout sees.
The same behavior also helps any local or CI environment using Git alternates with the Beats crossbuild path.
Screenshots
Not applicable.
Logs
The relevant checkout evidence from the failing Buildkite log:
The error: