Skip to content

Commit 1f3db93

Browse files
authored
[CI] ensure one shot-worker (#22588) (#22592)
1 parent 9dd2462 commit 1f3db93

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

Jenkinsfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def generateStages(Map args = [:]) {
210210
}
211211

212212
def cloud(Map args = [:]) {
213-
node(args.label) {
213+
withNode(args.label) {
214214
startCloudTestEnv(name: args.directory, dirs: args.dirs)
215215
}
216216
withCloudTestEnv() {
@@ -225,7 +225,7 @@ def cloud(Map args = [:]) {
225225
def k8sTest(Map args = [:]) {
226226
def versions = args.versions
227227
versions.each{ v ->
228-
node(args.label) {
228+
withNode(args.label) {
229229
stage("${args.context} ${v}"){
230230
withEnv(["K8S_VERSION=${v}", "KIND_VERSION=v0.7.0", "KUBECONFIG=${env.WORKSPACE}/kubecfg"]){
231231
withGithubNotify(context: "${args.context} ${v}") {
@@ -270,7 +270,7 @@ def target(Map args = [:]) {
270270
def directory = args.get('directory', '')
271271
def withModule = args.get('withModule', false)
272272
def isMage = args.get('isMage', false)
273-
node(args.label) {
273+
withNode(args.label) {
274274
withGithubNotify(context: "${context}") {
275275
withBeatsEnv(archive: true, withModule: withModule, directory: directory, id: args.id) {
276276
dumpVariables()
@@ -680,6 +680,18 @@ def notifyBuildReason() {
680680
}
681681
}
682682

683+
/**
684+
* Guarantee a specific worker can only be used for a specific build. This was not the case
685+
* with the customise node provisioner that reuses workers when there is peak load.
686+
*/
687+
def withNode(def label, Closure body) {
688+
def uuid = UUID.randomUUID().toString()
689+
def labels = label?.trim() ? "${label} && extra/${uuid}" : "extra/${uuid}"
690+
node("${labels}") {
691+
body()
692+
}
693+
}
694+
683695
/**
684696
* This class is the one used for running the parallel stages, therefore
685697
* its arguments are passed by the beatsStages step.

0 commit comments

Comments
 (0)