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
parent
6cc6c5ef36
commit
1b37d9510d
|
@ -17,7 +17,3 @@ spec:
|
||||||
limits:
|
limits:
|
||||||
github.com/fuse: 1
|
github.com/fuse: 1
|
||||||
hostUsers: false
|
hostUsers: false
|
||||||
tolerations:
|
|
||||||
- key: du5t1n.me/machine
|
|
||||||
value: raspberrypi
|
|
||||||
effect: NoExecute
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ def call(args) {
|
||||||
def archlist = args?.archlist
|
def archlist = args?.archlist
|
||||||
def schedule = args?.schedule
|
def schedule = args?.schedule
|
||||||
def defaultBranch = args?.defaultBranch
|
def defaultBranch = args?.defaultBranch
|
||||||
|
def pi = args?.pi
|
||||||
|
|
||||||
properties([
|
properties([
|
||||||
pipelineTriggers([cron(schedule ?: 'H H H * *')])
|
pipelineTriggers([cron(schedule ?: 'H H H * *')])
|
||||||
|
@ -31,6 +32,9 @@ def call(args) {
|
||||||
if (defaultBranch == null) {
|
if (defaultBranch == null) {
|
||||||
defaultBranch = 'main'
|
defaultBranch = 'main'
|
||||||
}
|
}
|
||||||
|
if (pi == null) {
|
||||||
|
pi = true
|
||||||
|
}
|
||||||
def repo = "${registry}/${project}/${name}"
|
def repo = "${registry}/${project}/${name}"
|
||||||
def full_name = "${repo}:${tag}"
|
def full_name = "${repo}:${tag}"
|
||||||
|
|
||||||
|
@ -44,13 +48,14 @@ def call(args) {
|
||||||
full_name: full_name,
|
full_name: full_name,
|
||||||
registry: registry,
|
registry: registry,
|
||||||
arch: arch,
|
arch: arch,
|
||||||
|
pi: pi,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parallel stages
|
parallel stages
|
||||||
|
|
||||||
runInPod {
|
runInPod(pi: false) {
|
||||||
container('buildah') {
|
container('buildah') {
|
||||||
withBuildahCreds(registry) {
|
withBuildahCreds(registry) {
|
||||||
if (archlist.size() > 1) {
|
if (archlist.size() > 1) {
|
||||||
|
@ -91,8 +96,9 @@ def buildStage(args) {
|
||||||
def full_name = args.full_name
|
def full_name = args.full_name
|
||||||
def registry = args.registry
|
def registry = args.registry
|
||||||
def arch = args.arch
|
def arch = args.arch
|
||||||
|
def pi = args.pi
|
||||||
|
|
||||||
runInPod(arch) {
|
runInPod(arch: arch, pi: pi) {
|
||||||
checkout scm
|
checkout scm
|
||||||
|
|
||||||
container('buildah') {
|
container('buildah') {
|
||||||
|
@ -105,14 +111,25 @@ def buildStage(args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def runInPod(... args) {
|
def runInPod(args, block) {
|
||||||
def arch = null
|
def arch = args?.arch
|
||||||
def block = args.last()
|
def pi = args?.pi
|
||||||
if (args.size() > 1) {
|
if (pi == null) {
|
||||||
arch = args[0]
|
pi = true
|
||||||
}
|
}
|
||||||
|
|
||||||
def podTemplateYaml = libraryResource('podTemplate2.yaml')
|
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(
|
podTemplate(
|
||||||
yaml: podTemplateYaml,
|
yaml: podTemplateYaml,
|
||||||
nodeSelector: arch ? "kubernetes.io/arch=${arch}" : null,
|
nodeSelector: arch ? "kubernetes.io/arch=${arch}" : null,
|
||||||
|
|
Loading…
Reference in New Issue