Skip to content

Commit 0a75258

Browse files
authored
[CI] ensure one shot-worker (#22588)
1 parent b6896ee commit 0a75258

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
@@ -211,7 +211,7 @@ def generateStages(Map args = [:]) {
211211
}
212212

213213
def cloud(Map args = [:]) {
214-
node(args.label) {
214+
withNode(args.label) {
215215
startCloudTestEnv(name: args.directory, dirs: args.dirs)
216216
}
217217
withCloudTestEnv() {
@@ -226,7 +226,7 @@ def cloud(Map args = [:]) {
226226
def k8sTest(Map args = [:]) {
227227
def versions = args.versions
228228
versions.each{ v ->
229-
node(args.label) {
229+
withNode(args.label) {
230230
stage("${args.context} ${v}"){
231231
withEnv(["K8S_VERSION=${v}", "KIND_VERSION=v0.7.0", "KUBECONFIG=${env.WORKSPACE}/kubecfg"]){
232232
withGithubNotify(context: "${args.context} ${v}") {
@@ -271,7 +271,7 @@ def target(Map args = [:]) {
271271
def directory = args.get('directory', '')
272272
def withModule = args.get('withModule', false)
273273
def isMage = args.get('isMage', false)
274-
node(args.label) {
274+
withNode(args.label) {
275275
withGithubNotify(context: "${context}") {
276276
withBeatsEnv(archive: true, withModule: withModule, directory: directory, id: args.id) {
277277
dumpVariables()
@@ -681,6 +681,18 @@ def notifyBuildReason() {
681681
}
682682
}
683683

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

0 commit comments

Comments
 (0)