-
Notifications
You must be signed in to change notification settings - Fork 55
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
Job cacher PoC #4351
base: master
Are you sure you want to change the base?
Job cacher PoC #4351
Changes from 13 commits
43c892f
8d32a57
49f8ce2
922618f
4fc2c68
231de43
27a61d0
1928633
8e2c2ac
5eaffb4
d110e8d
c70f328
1b4f8f2
966274d
11b55d0
fb832b7
d7f8ab6
68a2f27
8d95f0f
4699a7a
f13c081
bd0300f
1f195bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Change this file if you need to invalidate the cache. | ||
1 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,12 +19,31 @@ def mavenEnv(Map params = [:], Closure body) { | |||||
timeout(120) { | ||||||
withChecks(name: 'Tests', includeStage: true) { | ||||||
infra.withArtifactCachingProxy { | ||||||
withEnv([ | ||||||
'JAVA_HOME=/opt/jdk-' + params['jdk'], | ||||||
"MAVEN_ARGS=${env.MAVEN_ARGS != null ? MAVEN_ARGS : ''} -B -ntp -Dmaven.repo.local=${WORKSPACE_TMP}/m2repo" | ||||||
]) { | ||||||
body() | ||||||
} | ||||||
def cacheBaseDir = env.JOBCACHER_CACHE_DIR ?: "/tmp" | ||||||
def mavenRepoPath = "${cacheBaseDir}/.m2-cache-${params['cacheKey']}" | ||||||
cache( | ||||||
timja marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
// max cache size in MB, will be reset after exceeding this size | ||||||
maxCacheSize: 3072, | ||||||
defaultBranch: 'master', | ||||||
timja marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
// don't save pull requests, only cache on master branches | ||||||
// skipSave: env.BRANCH_NAME != 'master', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commit before merge
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes think about the reliability: does the build fail (on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there's an issue with the cache no it doesn't fail, if it fails to save then yes I did manage to trigger this exception in one build: #4351 (comment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which looks to be it fails if it takes 5 mins or more to upload the cache There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 Since the initial trigger of this effort (besides of course the technical efficiency and cost decrease) was to avoid slowing down or blocking the BOM team and releases, such failure would force them to deal with re-triggering builds. Do you think it could be feasible to have a separate build in charge of seeding the cache, keeping the BOM build (even on master) to only "read" the cache and decouple both? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If the S3 bucket is in the same region as the agents, then it costs no bandwidth. It's the case: we do not use multiple AWS regions. The BOM is one of the rare builds on ci.jio which clearly benefit from caching: the combined costs of "EC2 machines minute not needed thanks to the cache" (a gain of ~1 hour as per @timja first tests) and "the BOM maintainers not blocked and not requiring infra team to restart builds" is clearly worth! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Trying.
Hmm possibly, maybe a parameterised build, it would need to skip the tests and just download dependencies (but make sure it resolves them all?) Likely do-able but potentially we try without and see how we go? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Fine by me if it is ok for @darinpope @alecharp @basil and @MarkEWaite There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Same problem: https://ci.jenkins.io/job/Tools/job/bom/job/PR-4351/17/pipeline-console/?start-byte=0&selected-node=4438#log-0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This didn't actually test it, I had the |
||||||
caches: [ | ||||||
arbitraryFileCache( | ||||||
// using a fixed path for Maven cache instead of the normal workspace pattern | ||||||
// due to the cache name being calculated from the path | ||||||
// this prevents seeding working if you use the normal pattern | ||||||
path: mavenRepoPath, | ||||||
cacheValidityDecidingFile: '.repository-cache-marker' | ||||||
) | ||||||
] | ||||||
) { | ||||||
withEnv([ | ||||||
'JAVA_HOME=/opt/jdk-' + params['jdk'], | ||||||
"MAVEN_ARGS=${env.MAVEN_ARGS != null ? MAVEN_ARGS : ''} -B -ntp -Dmaven.repo.local=${mavenRepoPath}" | ||||||
]) { | ||||||
body() | ||||||
} | ||||||
} | ||||||
} | ||||||
if (junit(testResults: '**/target/surefire-reports/TEST-*.xml,**/target/failsafe-reports/TEST-*.xml').failCount > 0) { | ||||||
// TODO JENKINS-27092 throw up UNSTABLE status in this case | ||||||
|
@@ -52,17 +71,14 @@ def fullTestMarkerFile | |||||
def weeklyTestMarkerFile | ||||||
|
||||||
stage('prep') { | ||||||
mavenEnv(jdk: 21) { | ||||||
mavenEnv(jdk: 21, cacheKey: "sample-plugin") { | ||||||
checkout scm | ||||||
withEnv(['SAMPLE_PLUGIN_OPTS=-Dset.changelist']) { | ||||||
withCredentials([ | ||||||
usernamePassword(credentialsId: 'app-ci.jenkins.io', usernameVariable: 'GITHUB_APP', passwordVariable: 'GITHUB_OAUTH') | ||||||
]) { | ||||||
sh ''' | ||||||
mvn -v | ||||||
echo "Starting artifact caching proxy pre-heat" | ||||||
mvn -ntp dependency:go-offline | ||||||
echo "Finished artifact caching proxy pre-heat" | ||||||
bash prep.sh | ||||||
''' | ||||||
} | ||||||
|
@@ -102,7 +118,7 @@ if (BRANCH_NAME == 'master' || fullTestMarkerFile || weeklyTestMarkerFile || env | |||||
pluginsByRepository.each { repository, plugins -> | ||||||
branches["pct-$repository-$line"] = { | ||||||
def jdk = line == 'weekly' ? 21 : 17 | ||||||
mavenEnv(jdk: jdk, nodePool: true) { | ||||||
mavenEnv(jdk: jdk, nodePool: true, cacheKey: repository) { | ||||||
unstash line | ||||||
withEnv([ | ||||||
"PLUGINS=${plugins.join(',')}", | ||||||
|
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.
will be either invalided on exceeding
maxCacheSize
or if someone changes the file, e.g. incrementing 1 to 2