Skip to content
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

[CI] one shot workers #22626

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def generateStages(Map args = [:]) {
}

def cloud(Map args = [:]) {
node(args.label) {
withNode(args.label) {
startCloudTestEnv(name: args.directory, dirs: args.dirs)
}
withCloudTestEnv() {
Expand All @@ -226,7 +226,7 @@ def cloud(Map args = [:]) {
def k8sTest(Map args = [:]) {
def versions = args.versions
versions.each{ v ->
node(args.label) {
withNode(args.label) {
stage("${args.context} ${v}"){
withEnv(["K8S_VERSION=${v}", "KIND_VERSION=v0.7.0", "KUBECONFIG=${env.WORKSPACE}/kubecfg"]){
withGithubNotify(context: "${args.context} ${v}") {
Expand Down Expand Up @@ -271,7 +271,7 @@ def target(Map args = [:]) {
def directory = args.get('directory', '')
def withModule = args.get('withModule', false)
def isMage = args.get('isMage', false)
node(args.label) {
withNode(args.label) {
withGithubNotify(context: "${context}") {
withBeatsEnv(archive: true, withModule: withModule, directory: directory, id: args.id) {
dumpVariables()
Expand Down Expand Up @@ -681,6 +681,27 @@ def notifyBuildReason() {
}
}

/**
* Guarantee a specific worker can only be used for a specific build. This was not the case
* with the customise node provisioner that reuses workers in some cases when there is a peak load.
*/
def withNode(def label, Closure body) {
def labels
// There are immutable workers and static ones, so the static ones are only metal, macosx and arm
if (label?.contains('arm') || label?.contains('macosx') || label?.contains('metal')) {
labels = label
} else {
// Otherwise use the dynamic UUID for the gobld
def uuid = UUID.randomUUID().toString()
// Ensure no double quotes are added to the labels.
labels = label?.trim() ? "${label} && extra/${uuid}" : "extra/${uuid}"
}
log(level: 'INFO', text: "Allocating a worker with the labels '${labels}'.")
node("${labels}") {
body()
}
}

/**
* This class is the one used for running the parallel stages, therefore
* its arguments are passed by the beatsStages step.
Expand Down