-
Notifications
You must be signed in to change notification settings - Fork 244
subscription-manager pre-registration #1528
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -229,7 +229,7 @@ spec: | |||||
| - $(params.SOURCE_ARTIFACT)=/var/workdir/source | ||||||
| - $(params.CACHI2_ARTIFACT)=/var/workdir/cachi2 | ||||||
| - name: build | ||||||
| image: quay.io/konflux-ci/buildah-task:latest@sha256:5cbd487022fb7ac476cbfdea25513b810f7e343ec48f89dc6a4e8c3c39fa37a2 | ||||||
| image: quay.io/konflux-ci/buildah-task:latest@sha256:b2d6c32d1e05e91920cd4475b2761d58bb7ee11ad5dff3ecb59831c7572b4d0c | ||||||
| args: | ||||||
| - --build-args | ||||||
| - $(params.BUILD_ARGS[*]) | ||||||
|
|
@@ -429,16 +429,34 @@ spec: | |||||
| ACTIVATION_KEY_PATH="/activation-key" | ||||||
| ENTITLEMENT_PATH="/entitlement" | ||||||
|
|
||||||
| # do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key. | ||||||
| # when activation keys are used an empty directory on shared emptydir volume to "/etc/pki/entitlement" to prevent certificates from being included in the produced container | ||||||
| # To use activation key file 'org' must exist, which means the key 'org' must exist in the key/value secret | ||||||
| # 1. do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key. | ||||||
| # 2. Activation-keys will be used when the key 'org' exists in the activation key secret. | ||||||
| # 3. try to pre-register and mount files to the correct location so that users do no need to modify Dockerfiles. | ||||||
| # 3. If the Dockerfile contains the string "subcription-manager register", add the activation-keys volume | ||||||
| # to buildah but don't pre-register for backwards compatibility. In this case mount an empty directory on | ||||||
| # shared emptydir volume to "/etc/pki/entitlement" to prevent certificates from being included in the produced | ||||||
| # container. | ||||||
|
|
||||||
| REGISTERED="false" | ||||||
| if [ -e /activation-key/org ]; then | ||||||
| cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key | ||||||
| mkdir /shared/rhsm-tmp | ||||||
| VOLUME_MOUNTS+=(--volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z) | ||||||
| echo "Adding activation key to the build" | ||||||
|
|
||||||
| if ! grep subscription-manager "$dockerfile_path" | grep -q register; then | ||||||
| # user is not running registration in the Containerfile: pre-register. | ||||||
| echo "Pre-registering with subscription manager." | ||||||
|
brianwcook marked this conversation as resolved.
|
||||||
| subscription-manager register --org "$(cat /tmp/activation-key/org)" --activationkey "$(cat /tmp/activation-key/activationkey)" | ||||||
| REGISTERED=$? | ||||||
|
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.
Suggested change
This will make us unregister always, even if the build fails
Member
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. did not get this in but I will file a follow up PR. testing all cases manually was getting complicated |
||||||
| # copy generated certificates to /shared/rhsm-tmp | ||||||
| cp /etc/pki/entitlement/*.pem /shared/rhsm-tmp | ||||||
|
|
||||||
| # and then mount get /etc/rhsm/ca/redhat-uep.pem into /run/secrets/rhsm/ca | ||||||
| VOLUME_MOUNTS+=(--volume /etc/rhsm/ca/redhat-uep.pem:/run/secrets/rhsm/ca/redhat-uep.pem) | ||||||
|
brianwcook marked this conversation as resolved.
|
||||||
| fi | ||||||
|
chmeliik marked this conversation as resolved.
|
||||||
|
|
||||||
| # was: if [ -d "$ACTIVATION_KEY_PATH" ]; then | ||||||
| elif find /entitlement -name "*.pem" >>null; then | ||||||
| cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement | ||||||
| VOLUME_MOUNTS+=(--volume /tmp/entitlement:/etc/pki/entitlement) | ||||||
|
|
@@ -496,6 +514,11 @@ spec: | |||||
|
|
||||||
| # Needed to generate base images SBOM | ||||||
| echo "$BASE_IMAGES" >/shared/base_images_from_dockerfile | ||||||
|
|
||||||
| # unregister pod from subscription manager | ||||||
| if [ "$REGISTERED" == "0" ]; then | ||||||
| subscription-manager unregister | ||||||
| fi | ||||||
| computeResources: | ||||||
| limits: | ||||||
| cpu: "4" | ||||||
|
|
@@ -581,7 +604,7 @@ spec: | |||||
| securityContext: | ||||||
| runAsUser: 0 | ||||||
| - name: inject-sbom-and-push | ||||||
| image: quay.io/konflux-ci/buildah-task:latest@sha256:5cbd487022fb7ac476cbfdea25513b810f7e343ec48f89dc6a4e8c3c39fa37a2 | ||||||
| image: quay.io/konflux-ci/buildah-task:latest@sha256:b2d6c32d1e05e91920cd4475b2761d58bb7ee11ad5dff3ecb59831c7572b4d0c | ||||||
| workingDir: /var/workdir | ||||||
| volumeMounts: | ||||||
| - mountPath: /var/lib/containers | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.