-
Notifications
You must be signed in to change notification settings - Fork 432
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
Take config's OS, Dist, OS X image name, known Env var values into cache slug computation #706
Conversation
We assume that these values are reasonably set, and that environment variables are explicitly set. Since we must compute cache URL signatures at script compile time, we cannot use the actual values of the environment variables at run time. Also note that we do *not* take secure environment variables when computing the SHA256 digest.
Currently, this PR does not take secure env vars into consideration. As we are just taking the SHA256 digest, I think it is acceptable to take secure env vars into computation. (There is no way to recover secure env vars from the SHA256 digest.) |
Actually, I think it is best to not include secure environment variables, since we do not use salt for the digest. |
Or add salt on the app side. |
The salt can be defined user or repo level in the database. Either as a new field (preferred) or reusing an existing secret (less preferred). |
Maybe we should take the |
We should also consider not printing the hash at all, or omitting some characters. This requires a change to casher. |
No longer needed
Would it be possible to include an extra user-defined salt value as well, so that individual builds may set themselves apart from others in the matrix? We're currently working around this with a hack: https://github.com/bitcoin/bitcoin/blob/master/.travis.yml#L38 It would be great to use instead, something like: - cache_salt: arm
env: HOST=arm-linux-gnueabihf PACKAGES="g++-arm-linux-gnueabihf" DEP_OPTS="NO_QT=1" CHECK_DOC=1 GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports"
- cache_salt: win32
... Edit: or does this take all yml-defined env vars into account as well? If so, that would work solve our problem as well :) |
Ok, I clicked too fast, assuming this only applied to vars set outside of the .yml. Obviously that's not the case, and this work addresses our use-case exactly. Thanks! |
There are some cases where user-defined variables contain pre-defined vars from the builder. For example: https://travis-ci.org/bitcoin/bitcoin/jobs/125738866#L161 Would the values of vars like TRAVIS_BUILD_ID/TRAVIS_COMMIT/etc. be expanded before being used to calculate the slug? If so, I imagine there are many that would cause new cache id's for each build. |
@theuni Thanks for taking time to look at this PR. I really appreciate the interest in this feature. This PR considers only the environment variables defined in Some environment variables are evaluated and assigned only at the run time. Some can be reasoned beforehand (e.g., I also thought about some mechanism for the user to influence the cache name besides setting environment variables (e.g., with |
My inclinations:
|
@BanzaiMan Agree on leaving out secure vars. As a suggestion though, it would be helpful to see (maybe behind a debug var?) which env vars have been considered for the slug, without their values. |
@theuni Do you want that information always printed? Sees a bit noisy. And adding a key to |
@BanzaiMan No, only for troubleshooting the non-obvious cases. As a stupid example off the top of my head: before: env:
global:
- FOO=bar
matrix:
include:
- compiler: gcc
env: BAR=blah
- compiler: clang
env: after: env:
global:
- FOO=bar BAR=blah
matrix:
include:
- compiler: gcc
env:
- compiler: clang
env: BAR= Do those end up with new cache ids? It would be helpful in this case to see what's happening with BAR, as I'm not sure if empty is the same as nonexistent. Not the end of the world if printing it is a hassle though, It would only take a few quick experiments to figure out what's happening. |
The very presence of such a variable should affect the cache name. |
So that we don't delete secure variables
Can't use `Hash#fetch` here, becauce it might be explicitly `nil`.
Conflicts: spec/build/script/r_spec.rb
The merge conflict was resolved incorrectly.
This has been deployed to production. I will observe how it behaves for the next several hours, after which, if it's behaving well, I will merge this code and redeploy. |
Given a cache with name like: cache-linux-precise-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855--rvm-2.0.0--gemfile-Gemfile.tgz We want cache--rvm-2.0.0--gemfile-Gemfile.tgz not cache--gemfile-Gemfile.tgz
(and was fixed by the previous commit)
This PR addresses the issue with cache name collisions by taking into account extra pieces of information known at the build script compilation time.
Related issues:
travis-ci/travis-ci#4393
travis-ci/travis-ci#3023
travis-ci/travis-ci#5460