Skip to content

Commit

Permalink
CI: add resilience when ephemeral windows workers are reused (#24316) (
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Mar 4, 2021
1 parent 7e465a6 commit 4190249
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,10 @@ def target(Map args = [:]) {
*/
def withNode(String label, Closure body) {
sleep randomNumber(min: 10, max: 200)
// this should workaround the existing issue with reusing workers with the Gobld
def uuid = UUID.randomUUID().toString()
node(label) {
ws("workspace/${JOB_BASE_NAME}-${BUILD_NUMBER}") {
ws("workspace/${JOB_BASE_NAME}-${BUILD_NUMBER}-${uuid}") {
body()
}
}
Expand Down Expand Up @@ -559,7 +561,12 @@ def withBeatsEnv(Map args = [:], Closure body) {
gox_flags = '-arch 386'
}

deleteDir()
// IMPORTANT: Somehow windows workers got a different opinion regarding removing the workspace.
// Windows workers are ephemerals, so this should not really affect us.
if(isUnix()) {
deleteDir()
}

unstashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}")
// NOTE: This is required to run after the unstash
def module = withModule ? getCommonModuleInTheChangeSet(directory) : ''
Expand Down Expand Up @@ -603,17 +610,24 @@ def withBeatsEnv(Map args = [:], Closure body) {
if (archive) {
archiveTestOutput(testResults: testResults, artifacts: artifacts, id: args.id, upload: upload)
}
// Tear down the setup for the permanent workers.
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
fixPermissions("${WORKSPACE}")
// TODO: Somehow windows workers got a different opinion regarding removing the workspace
// IMPORTANT: windows workers are ephemerals, so this should not really affect us.
if (isUnix()) {
dir("${WORKSPACE}") {
deleteDir()
}
}
}
tearDown()
}
}
}
}

/**
* Tear down the setup for the permanent workers.
*/
def tearDown() {
catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
cmd(label: 'Remove the entire module cache', script: 'go clean -modcache', returnStatus: true)
fixPermissions("${WORKSPACE}")
// IMPORTANT: Somehow windows workers got a different opinion regarding removing the workspace.
// Windows workers are ephemerals, so this should not really affect us.
if (isUnix()) {
dir("${WORKSPACE}") {
deleteDir()
}
}
}
Expand Down

0 comments on commit 4190249

Please sign in to comment.