Pipelines: reproducible builds#22887
Merged
tgamblin merged 3 commits intospack:developfrom May 28, 2021
Merged
Conversation
c6545dd to
dd119d1
Compare
eb5b9f8 to
80f5d62
Compare
Contributor
Author
|
@eugeneswalker @adrienbernede @shahzebsiddiqui Since I know you are all doing working with gitlab pipelines in one way or another, I wanted to draw your attention to this upcoming/proposed change to how pipelines will work. |
Contributor
Author
|
@hartzell In case you're interested, this is the PR I referred to earlier on slack when I mentioned making pipeline builds more easily reproducible outside of the pipeline environment. |
80f5d62 to
3534741
Compare
Contributor
Author
|
fyi @zackgalbreath |
3534741 to
89eb40a
Compare
2544ca5 to
863b7ca
Compare
52b47f7 to
c51f371
Compare
341f532 to
9ff10b3
Compare
becker33
previously requested changes
May 25, 2021
Member
becker33
left a comment
There was a problem hiding this comment.
Some minor requests, mostly documentation, and a few questions to confirm other sections are doing what I think they are.
aee3e13 to
83b2068
Compare
becker33
reviewed
May 26, 2021
- Write spack.lock after concretizing the environment - Change 'ci rebuild' to generate an install.sh script for building from source - Stop force-redirecting stdout/stderr to pipeline.log - Re-organize artifacts to avoid diamond dep conflicts, etc. - Add a subcommand to aid reproduction of failed builds - If enabled, report specs that break on develop pipelines
tgamblin
previously approved these changes
May 27, 2021
- then fix the installer try_install_from_binary test, though why there is now a mirror configured there is unknown
tgamblin
approved these changes
May 28, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The goal of this PR is to make gitlab pipeline builds (especially build failures) more reproducible outside of the pipeline environment. The two key changes here which aim to improve reproducibility are:
spack.lockduring pipeline generation which is passed to child jobs via artifacts. This concretized environment is used both by generated child jobs as well as uploaded as an artifact to be used when reproducing the build locally.spack ci rebuildcommand, if a spec needs to be rebuilt from source, do this by generating and running aninstall.shshell script which is then also uploaded as a job artifact to be run during local reproduction.To make it easier to take advantage of improved build reproducibility, this PR also adds a new subcommand,
spack ci reproduce-build, which, given a url to job artifacts:docker runcommand you can run to get an interactive shell for reproducing the buildSome highlights
One consequence of this change will be much smaller pipeline yaml files. By encoding the concrete environment in a
spack.lockand passing to child jobs via artifacts, we will no longer need to encode the concrete root of each spec and write it into the job variables, greatly reducing the size of the generated pipeline yaml.Additionally
spack ci rebuildoutput (stdout/stderr) is no longer internally redirected to a log file, so job output will appear directly in the gitlab job trace. With debug logging turned on, this often results in log files getting truncated because they exceed the maximum amount of log output gitlab allows. If this is a problem, you still have the option toteecommand output to a file in the within the artifacts directory, as now each generated job exposes auser_datadirectory as an artifact, which you can fill with whatever you want in your custom job scripts.There are some changes to be aware of in how pipelines should be set up after this PR:
Pipeline generation
Because the pipeline generation job now writes a
spack.lockartifact to be consumed by generated downstream jobs,spack ci generatetakes a new option--artifacts-root, inside which it creates aconcrete_envdirectory to place the lockfile. This artifacts root directory is also where theuser_datadirectory will live, in case you want to generate any custom artifacts. If you do not provide--artifacts-root, the default is for it to create ajobs_scratch_dirwithin yourCI_PROJECT_DIR(a gitlab predefined environment variable) or whatever is your current working directory if that variable isn't set. Here's the diff of the PR testing.gitlab-ci.ymltaking advantage of the new option:Notice how we replaced the specific pointer to the generated pipeline file with its containing folder, the same folder we passed as
--artifacts-root. This way anything in that directory (the generated pipeline yaml, as well as the concrete environment directory containing thespack.lock) will be uploaded as an artifact and available to the downstream jobs.Rebuild jobs
Rebuild jobs now must activate the concrete environment created by
spack ci generateand provided via artifacts. When the pipeline is generated, a directory calledconcrete_environmentis created within the artifacts root directory, and this is where thespack.lockfile is written to be passed to the generated rebuild jobs. The artifacts root directory can be specified using the--artifacts-rootoption tospack ci generate, otherwise, it is assumed to be$CI_PROJECT_DIR. The directory containing the concrete environment files (spack.yamlandspack.lock) is then passed to generated child jobs via theSPACK_CONCRETE_ENV_DIRvariable in the generated pipeline yaml file.When you don't provide custom
scriptsections in yourmappingswithin thegitlab-cisection of yourspack.yaml, the default behavior of rebuild jobs is now to change intoSPACK_CONCRETE_ENV_DIRand activate that environment. If you do provide custom rebuild scripts in yourspack.yaml, be aware those scripts should do the same thing: assumeSPACK_CONCRETE_ENV_DIRcontains the concretized environment to activate. No other changes to existing custom rebuild scripts should be required as a result of this PR.As mentioned above, one key change made in this PR is the generation of the
install.shscript by the rebuild jobs, as that same script is both run by the CI rebuild job as well as exported as an artifact to aid in subsequent attempts to reproduce the build outside of CI. The generatedinstall.shscript contains only a singlespack installcommand with arguments computed byspack ci rebuild. If the install fails, the job trace in gitlab will contain instructions on how to reproduce the build locally:When run locally, the
spack ci reproduce-buildcommand shown above will download and process the job artifacts from gitlab, then print out instructions you can copy-paste to run a local reproducer of the CI job.This PR includes a few other changes to the way pipelines work, see the documentation on pipelines for more details.
This PR erelies on
- [ ] #23194 to be able to refer to uninstalled specs by DAG hashEDIT: that is going to take longer to come to fruition, so for now, we will continue to install specs represented by a concrete
spec.yamlfile on disk.