bci2: Allow jobs to choose if they run on an RPi

Jobs that need to compile code, as opposed to simply installing
prebuilt packages and/or copying in files, probably do not want to run
on a Raspberry Pi.  To allow such jobs to opt out of running on a Pi and
wait for the Cluster Autoscaler to bring up an aarch64 node in AWS, the
`buildContainerImage2` function now takes an optional `pi` argument.
The argument defaults to `true`, so existing jobs that expect to run on
a Pi will continue to do so.
bci2-resources
Dustin 2024-01-14 16:48:55 -06:00
parent 6cc6c5ef36
commit 1b37d9510d
2 changed files with 24 additions and 11 deletions

View File

@ -17,7 +17,3 @@ spec:
limits:
github.com/fuse: 1
hostUsers: false
tolerations:
- key: du5t1n.me/machine
value: raspberrypi
effect: NoExecute

View File

@ -8,6 +8,7 @@ def call(args) {
def archlist = args?.archlist
def schedule = args?.schedule
def defaultBranch = args?.defaultBranch
def pi = args?.pi
properties([
pipelineTriggers([cron(schedule ?: 'H H H * *')])
@ -31,6 +32,9 @@ def call(args) {
if (defaultBranch == null) {
defaultBranch = 'main'
}
if (pi == null) {
pi = true
}
def repo = "${registry}/${project}/${name}"
def full_name = "${repo}:${tag}"
@ -44,13 +48,14 @@ def call(args) {
full_name: full_name,
registry: registry,
arch: arch,
pi: pi,
)
}
}
}
parallel stages
runInPod {
runInPod(pi: false) {
container('buildah') {
withBuildahCreds(registry) {
if (archlist.size() > 1) {
@ -91,8 +96,9 @@ def buildStage(args) {
def full_name = args.full_name
def registry = args.registry
def arch = args.arch
def pi = args.pi
runInPod(arch) {
runInPod(arch: arch, pi: pi) {
checkout scm
container('buildah') {
@ -105,14 +111,25 @@ def buildStage(args) {
}
}
def runInPod(... args) {
def arch = null
def block = args.last()
if (args.size() > 1) {
arch = args[0]
def runInPod(args, block) {
def arch = args?.arch
def pi = args?.pi
if (pi == null) {
pi = true
}
def podTemplateYaml = libraryResource('podTemplate2.yaml')
if (pi) {
def tmpl = readYaml(text: podTemplateYaml)
def tolerations = tmpl['spec']['tolerations'] ?: []
tolerations.push([
key: 'du5t1n.me/machine',
value: 'raspberrypi',
effect: 'NoExecute',
])
tmpl['spec']['tolerations'] = tolerations
podTemplateYaml = writeYaml(data: tmpl, returnText: true)
}
podTemplate(
yaml: podTemplateYaml,
nodeSelector: arch ? "kubernetes.io/arch=${arch}" : null,