Skip to content
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

prefetch-task-rhsm-integration #1205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

brianwcook
Copy link
Contributor

@brianwcook brianwcook commented Jul 26, 2024

update: this PR has been reworked to use the new ssl options sub-key introduced into cachi2's RPM package manager.

This PR causes the prefetch task to react to the same ACTIVATION_KEY parameter that is used for non-hermetic builds. The container will use the pipeline-provided activation key to register with Red Hat's subscription manager, container and set the proper environment variables and augment the Cachi2 input to use the generated entitlement certificates before executing Cachi2.

The following points are pertinent:

  • the RHSM (Red Hat subscription management) files generated by subscription-manager register are generated by this task (by running subscription-manager register, immediately before running cachi2
  • they are never used again

Therefore this implementation is safe from certificate revocation / rotation behavior of RHSM.

@brianwcook brianwcook marked this pull request as draft July 26, 2024 17:33
Comment on lines 221 to 335
subscription-manager register \
--org $(cat "/activation-key/orgid") \
--activationkey $(cat "/activation-key/activationkey")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the user running inside the container privileged?

Error: this command requires root access to execute

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where did you get that error? It is running properly already in Konflux using git ref pointing at my fork of build-defintions. The buildah task already has sufficient permissions with no modifications.

Copy link
Contributor

Choose a reason for hiding this comment

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

Default UBI container.

Copy link
Contributor Author

@brianwcook brianwcook Jul 29, 2024

Choose a reason for hiding this comment

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

the buildah task is running as user 0 already so imo this is a non-issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Checked the buildah task, there's nothing going on in terms of user setting really (apart from ID mapping), so by default this runs as root. I guess the container itself isn't privileged, so while not ideal, I guess it's acceptable, so consider my initial comment retracted.

However, that makes things easier for cachi2 then and since we're assuming the default root user inside the container, this whole RHSM registration should IMO be baked into cachi2 rpm-dnf backend rather than in the tekton task for proper integration - we could also leverage dbus to communicate with RHSM for better error handling rather than dealing with shell.

@brianwcook
Copy link
Contributor Author

brianwcook commented Jul 30, 2024

IMHO the way I have implemented it is the most versatile option.

  • If your task is running on a static Jenkins or gitlab runner which is registered with RHSM,set your environment variables and pull content
  • If your task is running on Openshift with insights operator, set your environment variables and pull content.
  • If you are running in an unregistered environment like Konflux is, you can register a container with activation key and then set variables and pull content.
  • In addition if you want to run your own client-cert protected yum repo, my code also works for that.

It also introduces no new dependencies on yum, dnf or subscription manager and so is insulated from changes there. The client certificate scheme hasn't changed in over a decade and should be quite stable.

@eskultety
Copy link
Contributor

IMHO the way I have implemented it is the most versatile option.

* If your task is running on a static Jenkins or gitlab runner which is registered with RHSM,set your environment variables and pull content

* If your task is running on Openshift with insights operator, set your environment variables and pull content.

* If you are running in an unregistered environment like Konflux is, you can register a container with activation key and then set variables and pull content.

* In addition if you want to run your own client-cert protected yum repo, my code also works for that.

It also introduces no new dependencies on yum, dnf or subscription manager and so is insulated from changes there. The client certificate scheme hasn't changed in over a decade and should be quite stable.

Which of ^these use cases does the following not comply with, rendering it less versatile?

this whole RHSM registration should IMO be baked into cachi2 rpm-dnf backend rather than in the tekton task

brianwcook added a commit to brianwcook/cachi2 that referenced this pull request Aug 6, 2024
This changes the container build to use UBI9 so that it is supportable
by a major user (Red Hat) with subscription enabled repositories. The
change requires using createrepo_c from PyPyi since the createrepo_c rpm
is not distributed as part of the UBI9 content set and it is desireable
to keep this image freely redistributable. Chaniging to UBI keeps
maintenance to a minimum (just one image flavor) but in the future
multiple images could be maintained if required.

The subscription-manager package is included to support
konflux-ci/build-definitions#1205 and
containerbuildsystem#580 where it will be
used to obtain TLS certificates to send to authenticate to private
repositories.

Signed-off-by: Brian Cook <[email protected]>
brianwcook added a commit to brianwcook/cachi2 that referenced this pull request Aug 6, 2024
This changes the container build to use UBI9 so that it is supportable
by a major user (Red Hat) with subscription enabled repositories. The
change requires using createrepo_c from PyPyi since the createrepo_c rpm
is not distributed as part of the UBI9 content set and it is desireable
to keep this image freely redistributable. Chaniging to UBI keeps
maintenance to a minimum (just one image flavor) but in the future
multiple images could be maintained if required.

The subscription-manager package is included to support
konflux-ci/build-definitions#1205 and
containerbuildsystem#580 where it will be
used to obtain TLS certificates to send to authenticate to private
repositories.

Signed-off-by: Brian Cook <[email protected]>
github-merge-queue bot pushed a commit to containerbuildsystem/cachi2 that referenced this pull request Aug 12, 2024
This changes the container build to use UBI9 so that it is supportable
by a major user (Red Hat) with subscription enabled repositories. The
change requires using createrepo_c from PyPyi since the createrepo_c rpm
is not distributed as part of the UBI9 content set and it is desireable
to keep this image freely redistributable. Chaniging to UBI keeps
maintenance to a minimum (just one image flavor) but in the future
multiple images could be maintained if required.

The subscription-manager package is included to support
konflux-ci/build-definitions#1205 and
#580 where it will be
used to obtain TLS certificates to send to authenticate to private
repositories.

Signed-off-by: Brian Cook <[email protected]>
@brianwcook brianwcook force-pushed the prefetch-task-rhsm-integration branch from 22f5975 to cd8cad9 Compare October 29, 2024 21:18
@brianwcook brianwcook force-pushed the prefetch-task-rhsm-integration branch from 1e0fb3d to 64ae5f9 Compare October 30, 2024 02:53
@brianwcook brianwcook force-pushed the prefetch-task-rhsm-integration branch from e032884 to 78a571d Compare November 1, 2024 20:30
@brianwcook brianwcook force-pushed the prefetch-task-rhsm-integration branch 4 times, most recently from 46f4e82 to 95e2128 Compare November 2, 2024 02:40
@brianwcook brianwcook marked this pull request as ready for review November 2, 2024 02:42
@openshift-ci openshift-ci bot requested a review from mkosiarc November 2, 2024 02:42
@brianwcook
Copy link
Contributor Author

/ok-to-test

@brianwcook
Copy link
Contributor Author

/retest

@brianwcook
Copy link
Contributor Author

@eskultety I wrote some simple tests to ensure that the input manipulation here was working as intended and they are here (https://github.com/brianwcook/cachi2-input-stdz). At some point I think it should become a part of tests for the task but those are not actually possible yet, so just an FYI for now.

@brianwcook brianwcook force-pushed the prefetch-task-rhsm-integration branch 7 times, most recently from 74ebe1e to a55a347 Compare November 4, 2024 21:58
@brianwcook
Copy link
Contributor Author

/ok-to-test

This adds steps to the prefetch task to detect when a Red Hat subscription activation key is
provided. When prefetch is configured for RPM package manager and an acivation key is provided,
the pod will be registered with Red Hat's subscription management service so that protected
content can be fetched. THe input is modified, injecting the entitlement certs. After prefetch
the pod is unregistered.
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.

4 participants