Repository navigation
Automate images re-spinning in GH actions #12144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #! /bin/bash | ||
| set -euxo pipefail | ||
|
|
||
| image=$1 | ||
| # Get Latest Keycloak release tag | ||
| tag=$(curl -sL http://github.com/keycloak/keycloak/releases/latest -H "Accept: application/json" | jq -r '.tag_name') | ||
|
|
||
| docker pull ${image}:${tag} | ||
|
|
||
| base_image_url=$(docker inspect ${image}:${tag} | jq -r '.[0].Config.Labels.url') | ||
|
|
||
| base_image_name=$(docker inspect ${image}:${tag} | jq -r '.[0].Config.Labels.url' | sed 's/.*#\///' | sed 's/\/images.*//') | ||
|
|
||
| docker pull ${base_image_name}:latest | ||
|
|
||
| latest_base_image_url=$(docker inspect ${base_image_name}:latest | jq -r '.[0].Config.Labels.url') | ||
|
|
||
| if [ "${base_image_url}" = "${latest_base_image_url}" ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andreaTP, thanks for submitting those changes. If I understood it correctly, the script will check if the base image had changed to perform the respin on the daily basis. If that's the case, I'd suggest to respin the build of those images more frequently to fix known CVEs that will eventually emerge. The latest UBI was released 27 days ago, that means that if there's a new CVE, the only way to remediate those CVEs is waiting until the next release to benefit from the fix, instead of trigger Does it make some sense? //cc @ASzc
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might have understood it wrongly, but, my impression was that @stianst expressed an opinion toward less frequent re-spins (e.g. max once a day) without quickly reacting to upstream to give users a more "stable" experience. I'm open to discuss the tradeoffs and eventually steer the PR in the desired direction.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andreaTP no problem, we can wait for more feedback. Even with less frequent respins, which is a valid concern. We need some agreement about when to patch those CVEs. As you are already aware, we have 2 alternatives:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abstractj agreed, my personal vote goes to option 1, leaving 2 "covered" by manual triggers. A third option would be to check for dependencies updates at a "slower pace" e.g. once a week/month.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory UBI should be maintained at a Health Score of A at all times, so there shouldn't be significant public CVEs whenever you happen to pull the latest UBI, even though it could be many weeks old (29 days as of this comment, with no CVEs listed). I don't think |
||
| exit -1 # no need respin | ||
| else | ||
| exit 0 | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to access the manifests without downloading the images. It's a little tricky, as each repo seems to implement the dockerhttp API slightly differently (particularly around the access tokens), but it could save a lot of time.
Quay needs an anonymous token with the right service and scope parameters:
Which returns
https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8-minimal/images/8.6-751Red Hat's repo provides tokenless anonymous access:
Which returns
https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8-minimal/images/8.6-751So you could make your approach to the comparison faster based of off this method. It won't be as generic an approach as you're trying to write. However, the assumption around the url label isn't generic either, it's something that happens to work for UBI
That got me thinking, this check could also be done by comparing the layer hashes. The code for that is simpler, compared to parsing the label, but does require you to hardcode the parent URL:
Which would return exit code 0 if the latest ubi layers were present in the keycloak layers (no respin required), or exit code 1 if they were not (respin required)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the accurate review @ASzc !
With this implementation, I was working under the assumption that the job will run pretty seldom and I was preferring (as you noticed) "portability" over "speed".
You are correct that the code is not completely portable as it relies on RedHat specific UBI image labels but, at least, it will run on both
quay.ioanddockerhubwhich is convenient for testing IMHO; also, we are not likely to use an image that is not a UBI any time soon AFAIK.I think I'm still inclined to keep the original implementation using
docker pull, mostly because it still looks simpler (more dumb 🙂 ) to me (i.e. doesn't require knowledge about the docker HTTP API nor tokens etc.), but I'm happy to hear more feedback in this regard.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it's a tradeoff :)
I think for a once-per-day check, the performance hit of downloading several hundred megabytes of data shouldn't be too bad