Add podman-entitlement GitHub Action. - #60
Conversation
|
I've been playing with this approach for a while in https://github.com/adelton/redhat-entitlements because I'd need it for RHEL-based container image builds and tests of https://github.com/freeipa/freeipa-container. With RHEL 9 release this week, I updated and tested the approach to use I currently did not include any tests with this PR because
Please let me know how you'd like tests for this Action to be laid out. |
8c61d35 to
15f731b
Compare
|
I've now updated the code to make it a bit more readable. |
|
Hi @adelton, apologies for the delay in responding to this PR. Are you still interested in working on this? If so, it would be great to get an update on where things stand. Thanks! |
|
I've been using a copy of this code in https://github.com/freeipa/freeipa-container/ and its development and testing since I showed the code here: So strictly speaking I don't need this code merged in this repo because my itch got scratched by carrying it where I use it. If you or Red Hat folks overall would find it useful for the broader audience and would like to include and maintain it here, I'd be happy to revive the discussion here. |
|
Hi @adelton It would be good if you could add it here, looks like a useful addition. If you want to update the PR I'd be happy to review. |
e7e3404 to
6a01ef0
Compare
|
I've updated the action to use UBI10, squashed it and rebased it on top We might need some actions to test it but for that we'd need the some valid credentials ( Of course, comments welcome, also possibly in light of this PR being an attempt to address #32, although I did not get any feedback from folks there since 2022, so not sure how valid or needed that issue still is. |
snecklifter
left a comment
There was a problem hiding this comment.
Thanks for the contribution — the action solves a real problem. I've left inline comments on the main issues. The script injection vulnerability is a blocker; the rest are improvements to bring this in line with the other actions in the repo.
|
Thanks for the updates @adelton — the injection fix and required fields look good. A few more items to address before merge: Error handlingThe current bash -c 'set -e
/usr/sbin/subscription-manager register \
--org="$SM_ORG" --activationkey="$SM_KEY" --name="$SYSTEM_NAME"
trap "/usr/sbin/subscription-manager unregister" EXIT
cp /etc/pki/entitlement/* /etc/pki/entitlement-out/
cp -r /etc/rhsm/ca /etc/rhsm/rhsm.conf /etc/rhsm-out'This way:
Testing without real credentialsWe can test the full lifecycle with a mock # podman-entitlement/test/Dockerfile.mock
FROM registry.access.redhat.com/ubi10-micro
COPY subscription-manager /usr/sbin/subscription-manager
RUN chmod +x /usr/sbin/subscription-manager# podman-entitlement/test/subscription-manager
#!/bin/bash
case "$1" in
register)
mkdir -p /etc/pki/entitlement /etc/rhsm/ca
echo "mock-cert" > /etc/pki/entitlement/123456.pem
echo "mock-key" > /etc/pki/entitlement/123456-key.pem
echo "mock-ca" > /etc/rhsm/ca/redhat-uep.pem
echo "mock-conf" > /etc/rhsm/rhsm.conf
echo "System registered successfully."
;;
unregister)
echo "System unregistered."
;;
esacThen CI can build the mock image, run the action with fake credentials, and verify that:
No real Red Hat credentials needed. Pre-merge housekeeping
|
|
For the So in 7d8a263 I went with just setting the |
|
As for the CI testing, I'd much rather go with an "e2e" test with real credentials and a for which |
|
Example of such end-to-end CI is in 279cc53, and example workflow run in my fork is https://github.com/adelton/redhat-actions-common/actions/runs/30263269719. |
That's a good call — placing the |
Fair point — the mock approach tests plumbing but not the actual podman behavior. The e2e test with A few things to fix in the CI workflow before merge:
|
|
Per https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets:
That approach seems wasteful as we have no use for any of the steps in the job if we don't have the secrets. I can do a separate job to check for the entitlements, similar to https://github.com/freeipa/freeipa-container/blob/master/.github/workflows/test-rhel.yaml#L9-L28. |
2490953 to
43635c1
Compare
|
Guard with a separate job shown in 43635c1. Executed as https://github.com/adelton/redhat-actions-common/actions/runs/30275793011. |
|
I will flip the Added a reminder in 963aade. |
|
Changelog entry added in 70bb56a. |
|
This is looking great — nearly all feedback has been addressed. Two small things before the final squash:
|
Co-authored-by: Chris Brown <chribrow@redhat.com>
e947a5c to
14c6864
Compare
|
Rebased on |
|
Thanks @adelton for the contribution and for working through all the review feedback — this is a solid addition. Merged! |
Description
When building images that need Red Hat content beyond what is available in the Universal Base Image repositories, Red Hat subscription is needed. To avoid changing the Dockerfile and invoke
subscription-manager registermanually, this GitHub Actions calls that step in separate temporary container and uses/etc/containers/mounts.confto configure subsequentpodman buildinvocations to have access to the entitlements.Note that for example
registry.access.redhat.com/ubi9-minimaldoes not havesubscription-managerat all so the approach with tweaking the Dockerfile and somehow passing the subscription credentials to thepodman buildinvocation which gets sometimes recommended would not work with those minimalistic images at all.Related Issue(s)
Checklist
Changes made
podman-entitlement