From d3379270c48f74e8807b5a954ea515baa654b6ba Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 25 Sep 2025 18:52:44 -0500 Subject: [PATCH] bci2: Add resources argument Instead of a top-level boolean that says whether or not the build can/should run on a Raspberry Pi, we'll expose a `resources` argument that allows jobs to specify their compute requirements. If they're not specified, then the job can run anywhere. Otherwise, if the requirements are too large for a Pi, then the autoscaler will launch a cloud worker to handle the build. --- vars/buildContainerImage2.groovy | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/vars/buildContainerImage2.groovy b/vars/buildContainerImage2.groovy index 891c1ff..e79ddb2 100644 --- a/vars/buildContainerImage2.groovy +++ b/vars/buildContainerImage2.groovy @@ -9,6 +9,7 @@ def call(args) { def schedule = args?.schedule def defaultBranch = args?.defaultBranch def pi = args?.pi + def resources = args?.resources properties([ pipelineTriggers([cron(schedule ?: 'H H H * *')]) @@ -32,9 +33,6 @@ def call(args) { if (defaultBranch == null) { defaultBranch = 'main' } - if (pi == null) { - pi = true - } def repo = "${registry}/${project}/${name}" def full_name = "${repo}:${tag}" @@ -48,14 +46,14 @@ def call(args) { full_name: full_name, registry: registry, arch: arch, - pi: pi, + resources: resources, ) } } } parallel stages - runInPod(pi: false) { + runInPod() { container('buildah') { withBuildahCreds(registry) { if (archlist.size() > 1) { @@ -96,9 +94,9 @@ def buildStage(args) { def full_name = args.full_name def registry = args.registry def arch = args.arch - def pi = args.pi + def resources = args?.resources - runInPod(arch: arch, pi: pi) { + runInPod(arch: arch, resources: resources) { checkout scm container('buildah') { @@ -113,21 +111,17 @@ def buildStage(args) { def runInPod(args, block) { def arch = args?.arch - def pi = args?.pi - if (pi == null) { - pi = true - } + def resources = args?.resources def podTemplateYaml = libraryResource('podTemplate2.yaml') - if (pi) { + if (resources) { def tmpl = readYaml(text: podTemplateYaml) - def tolerations = tmpl['spec']['tolerations'] ?: [] - tolerations.push([ - key: 'du5t1n.me/machine', - value: 'raspberrypi', - effect: 'NoExecute', - ]) - tmpl['spec']['tolerations'] = tolerations + tmpl.spec.containers.each { + it.resources = [ + requests = resources, + limits = resources, + ] + } podTemplateYaml = writeYaml(data: tmpl, returnText: true) } podTemplate(