mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
update CoreOS builder pipeline to allow parallel runs
This commit is contained in:
parent
2cd8d580d8
commit
ede83bd555
@ -32,4 +32,4 @@ runcmd:
|
||||
- [chown, -R, github-actions-runner-user:github-actions-runner-user, /actions-runner]
|
||||
- [sudo, -u, github-actions-runner-user, /bin/bash, -c, "cd /actions-runner && /actions-runner/config.sh --url https://github.com/edgelesssys/constellation-images --ephemeral --labels nested-virt --replace --unattended --token $(curl -u api:$(gcloud secrets versions access latest --secret=constellation-images-coreos-builder-github-token) -X POST -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/edgelesssys/constellation-images/actions/runners/registration-token | jq -r .token)"]
|
||||
- [/bin/bash, -c, "cd /actions-runner && ./svc.sh install"]
|
||||
- [systemctl, enable, --now, actions.runner.edgelesssys-constellation-images.coreos-builder.service]
|
||||
- [/bin/bash, -c, "systemctl enable --now actions.runner.edgelesssys-constellation.$(hostname).service"]
|
||||
|
@ -3,6 +3,8 @@ import sys
|
||||
import re
|
||||
import hmac
|
||||
import hashlib
|
||||
import random
|
||||
import string
|
||||
import google.cloud.compute_v1 as compute_v1
|
||||
|
||||
LABEL="nested-virt"
|
||||
@ -55,8 +57,9 @@ def job_queued(workflow_job) -> str:
|
||||
if not LABEL in workflow_job['labels']:
|
||||
return f'unexpected job labels: {workflow_job["labels"]}'
|
||||
cloud_init = generate_cloud_init()
|
||||
instance_uid = ''.join(random.choice(string.ascii_lowercase + string.digits) for i in range(6))
|
||||
try:
|
||||
create_instance(metadata={'user-data': cloud_init})
|
||||
create_instance(metadata={'user-data': cloud_init}, instance_name=f'coreos-builder-{instance_uid}')
|
||||
except Exception as e:
|
||||
return f'creating instance failed: {e}'
|
||||
return 'success'
|
||||
@ -64,8 +67,9 @@ def job_queued(workflow_job) -> str:
|
||||
def job_completed(workflow_job) -> str:
|
||||
if not LABEL in workflow_job['labels']:
|
||||
return f'unexpected job labels: {workflow_job["labels"]}'
|
||||
instance_name = workflow_job["runner_name"]
|
||||
try:
|
||||
delete_instance()
|
||||
delete_instance(machine_name=instance_name)
|
||||
except Exception as e:
|
||||
return f'deleting instance failed: {e}'
|
||||
return 'success'
|
||||
|
Loading…
Reference in New Issue
Block a user