5 Commits

Author SHA1 Message Date
83d694d663 fixup! bci2: Add resources argument 2025-09-25 19:07:09 -05:00
316a16b124 fixup! bci2: Add resources argument 2025-09-25 19:04:42 -05:00
3f09e3a3b3 fixup! bci2: Add resources argument 2025-09-25 18:58:02 -05:00
835ec75472 xxx 2025-09-25 18:57:24 -05:00
d3379270c4 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.
2025-09-25 18:52:44 -05:00

View File

@@ -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,22 +111,20 @@ 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 { c ->
c.resources = c.resources ?: [:]
c.resources.requests = c.resources.requests ?: [:]
c.resources.limits = c.resources.limits ?: [:]
c.resources.requests += resources
c.resources.limits += resources
}
podTemplateYaml = writeYaml(data: tmpl, returnText: true)
echo podTemplateYaml
}
podTemplate(
yaml: podTemplateYaml,