From 35c87238d5ca56f583b49c572f18013da01fee96 Mon Sep 17 00:00:00 2001 From: TC Johnson Date: Mon, 17 Mar 2025 20:34:05 -0500 Subject: [PATCH] More CICD Hacking I've added more output to the Droplet control functions so as to better be able to troubleshoot why the delete job does not have the correct droplet ID in the config file. I also removed ARM64 RPM packaging from the packaging job because even though it's nice to know it's working, the repo isn't setup for multi-arch yet so including it is just burning time. Lastly, I created a new stage "cleanup" in the pipeline. The only job is the build machine delete. I did this because one can pass artifacts between jobs in a few ways: Define nothing and all artifacts from previous jobs are in the subsequent job. Use the _needs_ directive (which I was using for job ordering) to pull artifacts from that "needed" job (I don't know if artifacts from other jobs are downloaded in the case). Use the _dependiencies_ directive whicih cannot be used if _needs_ has been defined. So I placed droplet delete in its own stage so that I could remove the _needs_ directive and replace with the build droplets job as a dependency. --- .gitlab-ci.yml | 13 ++++++++----- scripts/cicd-python/config.json | 3 +-- scripts/cicd-python/utils/build_machine_control.py | 6 ++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59043b07..056b2350 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,7 @@ stages: - build_packages - distribute - release + - cleanup - failed format: @@ -278,7 +279,9 @@ dryrun_package_linux: - build-amd64-deb script: - earthly bootstrap - - earthly +package-linux + - earthly +package-linux-amd64-deb + - earthly +package-linux-amd64-rpm + - earthly +package-linux-arm64-deb artifacts: paths: - target/packages/* @@ -336,11 +339,11 @@ dryrun_deploy_repos: - if: $CI_COMMIT_MESSAGE =~ /\[ci dryrun]/ dryrun_delete_build_machines: - stage: distribute - needs: - - dryrun_deploy_repos + stage: cleanup tags: - build-orchestration + dependencies: + - dryrun_create_build_machines script: - uv --directory scripts/cicd-python sync - uv --directory scripts/cicd-python run veilid_release_utils.py --delete-build-machine @@ -367,7 +370,7 @@ nightly_create_build_machines: nightly_package_amd64_deb: stage: build_packages needs: - - dryrun_create_build_machines + - nightly_create_build_machines tags: - build-amd64-deb script: diff --git a/scripts/cicd-python/config.json b/scripts/cicd-python/config.json index ad461856..819ab438 100755 --- a/scripts/cicd-python/config.json +++ b/scripts/cicd-python/config.json @@ -3,6 +3,5 @@ "name": "build-server-tmp", "image": 181423111, "size": "c2-16vcpu-32gb" - }, - "droplet_id": 483191411 + } } \ No newline at end of file diff --git a/scripts/cicd-python/utils/build_machine_control.py b/scripts/cicd-python/utils/build_machine_control.py index cb389e96..59b527ce 100644 --- a/scripts/cicd-python/utils/build_machine_control.py +++ b/scripts/cicd-python/utils/build_machine_control.py @@ -79,7 +79,7 @@ async def create_build_machine(token: str) -> None: file=sys.stderr) sys.exit("Droplet data missing in polling response") - print("Droplet is up and running.") + print(f"Droplet ID {droplet_id} is up and running.") # Once active, send a final GET request to output the droplet's information. async with session.get(droplet_url, headers=headers) as final_resp: if final_resp.status != 200: @@ -104,6 +104,8 @@ async def delete_build_machine(token: str) -> None: "Content-Type": "application/json", } delete_url = f"https://api.digitalocean.com/v2/droplets/{droplet_id}" + + print(f"Deleting droplet ID {droplet_id}") async with aiohttp.ClientSession() as session: async with session.delete(delete_url, headers=headers) as resp: @@ -116,4 +118,4 @@ async def delete_build_machine(token: str) -> None: # Remove droplet ID from config config.pop("droplet_id", None) save_config(config) - print("Droplet ID removed from config.") + print(f"Droplet ID {droplet_id} removed from config.")