Skip to content

Conversation

@doanac
Copy link
Contributor

@doanac doanac commented May 12, 2025

The current artifact upload logic requires the self-hosted runner and the file-server to share the same NFS volume as a means of uploading artifacts. This change decouples that so that we could use any runner and still upload artifacts.

We do this by leveraging the GITHUB_TOKEN included in every CI job (including PRs from forked repositories). This is an ephemeral token only valid during the lifetime of the workflow. By granting it read access to the "security-events" API, our file-serve can assert the token it gets is a valid qualcomm-linux token before allowing an upload to happen.

The upload logic gets a little hard to maintain with inline yaml and shell script, so I've created a Python helper to do the upload. It has a few handy features:

  • parallel uploads
  • upload progress
  • better logging/info messages

@doanac doanac requested a review from lool May 12, 2025 16:48
@doanac
Copy link
Contributor Author

doanac commented May 12, 2025

NOTE: This script is a stop-gap measure while we wait for approval to make a common github action for our QLI repos to use.

Copy link
Contributor

@lool lool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, I've left a few suggestions for improvements if you have the chance

# python3-requests is used by publish_aritfacts.py
apt -y install python3-requests
# create a directory for the current run
dir="/fileserver-builds/${BUILD_ID}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can drop this volume now:
- /srv/gh-runners/quic-yocto/builds:/fileserver-builds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. should be addressed in force push.

@@ -0,0 +1,104 @@
#!/usr/bin/env python3
# Copyright (c) 2025 Qualcomm Innovation Center, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the workflow files should have a license, the debos recipes and shell scripts use BSD-3-Clause and that's the license in the repo and usually what Qualcomm defaults to, so perhaps let's use BSD-3-Clause or we need to add MIT license to the repo as LICENSE.MIT or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as it was copied directly from meta-qcom, I wasn't sure.

if URL[-1] != "/":
URL = URL + "/"

main(BUILD_DIR, URL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this script will be replaced soon, but the BUILD_DIR/URL env inputs are not easy to guess when reading the workflow files. Perhaps these should be passed as args publish-artifacts.py some-dir some-url or public-artifacts.py --build-dir dir --url url

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer your approach as well, but I'd like to keep this the exact same as meta-qcom for now and then move things over to the github action once approved (should be soon i think).


failed = False
work = [(f"{base_url}{x}", artifacts_dir, x) for x in paths]
with Pool(5) as p:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move the 5 to a constant at the top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in force-push


# Fibonacci backoff
for x in (1, 2, 3, 5, 0):
r = requests.put(url, headers=headers, allow_redirects=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need two put requests; IIUC, we get redirected by the web service to the actual place where we're supposed to upload? Perhaps this scheme should be capture in a comment in the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've added a docstring in the force-push

doanac added 4 commits May 13, 2025 08:35
This comes from meta-qcom. Its a temporary thing while we wait for
permission to create a common Github Action.

Signed-off-by: Andy Doan <[email protected]>
By publishing this way, we are no longer dependent on NFS file share.
This will make it easier to transition to the new IT provided
self-hosted runners.

Signed-off-by: Andy Doan <[email protected]>
@lool
Copy link
Contributor

lool commented May 14, 2025

Seems fine overall, there were some HTTP 500 in this run, which went away after retry, I don't know if that's common, I see you've implemented backoff/retry logic originally in the script, so I guess that's something that's happening regularly.

This makes me think we should probably avoid hitting github or our GCP server with a bunch of requests, but rather a single one to upload multiple assets, this would simplify the logic dramatically. I believe that's what github upload-artifacts does – it creates an archive and uploads that.

+ .github/workflows/publish_artifacts.py
= Found 6 files to publish
Error getting signed URL for dtbs.tar.gz: Correlation ID: wkjwmolfz1eo2acc HTTP_500 - Unexpected error submitting request to github

Retrying in 1 seconds
Error getting signed URL for rootfs.tar.gz: Correlation ID: 0d80rt3het3rlzay HTTP_500 - Unexpected error submitting request to github

Retrying in 1 seconds
= 1 of 6 - dtbs.tar.gz
Error getting signed URL for disk-ufs.img.gz: Correlation ID: pfhnyyqc98v1bzoe HTTP_500 - Unexpected error submitting request to github

Retrying in 1 seconds
Error getting signed URL for flash-ufs.tar.gz: Correlation ID: qax7hwtqe19xtnr2 HTTP_500 - Unexpected error submitting request to github

Retrying in 1 seconds
= 2 of 6 - rootfs.tar.gz
= 3 of 6 - disk-sdcard.img.gz
= 4 of 6 - disk-ufs.img.gz
= 5 of 6 - flash-emmc.tar.gz
= 6 of 6 - flash-ufs.tar.gz
+ echo Image available at: https://quic-yocto-fileserver-1029608027416.us-central1.run.app/qualcomm-linux/qcom-deb-images-1499810[243](https://github.com/qualcomm-linux/qcom-deb-images/actions/runs/14998102432/job/42137390493?pr=42#step:10:244)2-1/
Image available at: https://quic-yocto-fileserver-1029608027416.us-central1.run.app/qualcomm-linux/qcom-deb-images-14998102432-1/

@lool lool merged commit ced4b83 into qualcomm-linux:main May 14, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants