-
Notifications
You must be signed in to change notification settings - Fork 177
Mount Go build cache into crossbuild container #9094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
defer DockerChown(filepath.Join(params.OutputDir, params.Name+binaryExtension(GOOS))) | ||
defer DockerChown(filepath.Join(params.OutputDir)) | ||
|
||
mountPoint, err := ElasticBeatsDir() | ||
if err != nil { | ||
return err | ||
} | ||
if err := sh.Run("git", "config", "--global", "--add", "safe.directory", mountPoint); err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this was necessary because files written in the container were owned by root. They're now owned by the host user to begin with.
if CrossBuildMountModcache { | ||
// Make sure the module dependencies are downloaded on the host, | ||
// as they will be mounted into the container read-only. | ||
mg.Deps(func() error { return gotool.Mod.Download() }) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CrossBuildMountModCache
variable is always true, so I simply removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to test these set of changes in some of the other BK pipelines:
- packaging -
elastic-agent/catalog-info.yaml
Lines 268 to 272 in def141d
name: elastic-agent-package description: Buildkite pipeline for packaging Elastic Agent package spec: repository: elastic/elastic-agent pipeline_file: ".buildkite/pipeline.elastic-agent-package.yml" - DRA, https://github.com/elastic/elastic-agent/blob/main/catalog-info.yaml#L312-L324
Can you please run them and copy the link to those builds in this PR please?
@v1v both of them succeeded at the build steps, but failed at the publishing step, even though I set them to dry-run. Not sure if that's in some way an effect of this change or if I made a mistake. See: |
That's an expected error, I think it does not support feature branches:
https://buildkite.com/elastic/elastic-agent-package/builds/7168#01985144-a389-4509-af44-f1717edd59b2/282-310 As far as I see, you can override them with
I'm gonna run them again:
using the env variables:
|
You would need to define Just be careful because without the appropriate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I've just left a comment; however, I'm not an expert in the build system. Please take my +1
as only an acknowledgment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I've just left a comment; however, I'm not an expert in the build system. Please take my +1
as only an acknowledgment.
Co-authored-by: Victor Martinez <[email protected]>
|
💛 Build succeeded, but was flaky
Failed CI StepsHistory
cc @swiatekm |
What does this PR do?
Mounts the Go build cache into the golang-crossbuild container. To facilitate this and allow the container to generate the build cache, it also changes the crossbuild container to run as the host user.
This has been tested locally on both Mac and Linux, and the CI passes for this PR. It probably requires somewhat more careful testing, as permission changes in the host build cache could potentially result in breakage for unified releases.
Why is it important?
This reduces the build time of agent during packaging by around 75%. On my machine, the same-architecture build goes from 2 minutes to 25 seconds.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added tests that prove my fix is effective or that my feature works[ ] I have added an entry in./changelog/fragments
using the changelog tool[ ] I have added an integration test or an E2E testHow to test this PR locally
Run
mage crossbuild
and time it.Related issues