Skip to content

Fixes #38455 - Add container cert setup workflow to global registration #11402

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

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

Conversation

sjha4
Copy link
Member

@sjha4 sjha4 commented May 29, 2025

What are the changes introduced in this pull request?

Enable container registry certificate setup in the global registration workflow by adding a UI control and exposing the corresponding backend parameter.

New Features:

  • Add a SetupContainerRegistryCerts checkbox to the registration UI to toggle container registry certificate setup.

Enhancements:

  • Expose the setup_container_registry_certs variable in plugin allowed registration parameters and the registration commands API.

What are the testing steps for this pull request? (Same steps as on the foreman PR)

  1. Checkout related foreman PR: Fixes #38454 - Add container cert setup workflow to global registration theforeman/foreman#10554
  2. Register a host to your foreman server using global registartion.
  3. In the adavanced tab of the global registration form, check the Set up ctainer registry certs checkbox and generate registration command.
  4. Run it on your host to register.
  5. After registration, look at the /etc/containers/certs.d/ directory and make sure you see a directory named as foreman server.
  6. The contents of the directory <foreman_server> should be soft links to ca-bundle.cert, entitlement cert and entitlement key.
  7. You can test podman and flatpak(EL10) with this setup to verify.
  8. You can also try re-registering and make sure the soft links are recreated to point to the new entitlement certs.

Summary by Sourcery

Enable container registry certificate setup in the global registration workflow by adding a UI toggle and exposing the corresponding backend parameter.

New Features:

  • Add SetupContainerRegistryCerts checkbox to the global registration UI to allow toggling container registry certificate setup.

Enhancements:

  • Expose setup_container_registry_certs variable in plugin allowed registration parameters and include it in the registration commands API.

Copy link

sourcery-ai bot commented May 29, 2025

Reviewer's Guide

This PR integrates a new UI checkbox for toggling container registry certificate setup into the global registration workflow and exposes the corresponding backend flag by extending allowed registration variables and API parameters.

Sequence Diagram for Global Registration with Container Cert Setup

sequenceDiagram
    actor User
    participant RegistrationUI as "Registration UI"
    participant BackendAPI as "Backend API"
    participant Host

    User->>RegistrationUI: Navigates to Global Registration Form
    User->>RegistrationUI: Checks "Set up container registry certs" checkbox
    User->>RegistrationUI: Clicks "Generate Command"
    RegistrationUI->>BackendAPI: POST /api/v2/registration_commands/generate (with setup_container_registry_certs=true)
    BackendAPI-->>RegistrationUI: Returns registration command
    User->>Host: Executes registration command
    Host->>BackendAPI: Registers with Foreman (standard process)
    alt Command includes cert setup instruction
        Host->>Host: Sets up /etc/containers/certs.d/ (soft links)
    end
    BackendAPI-->>Host: Registration confirmation (standard process)
Loading

File-Level Changes

Change Details Files
Add container registry certificate setup checkbox to the registration UI
  • Created a new SetupContainerRegistryCerts React component with PatternFly Checkbox and LabelIcon
  • Imported and rendered SetupContainerRegistryCerts in RegistrationCommands, wired its value and onChange props
webpack/components/extensions/RegistrationCommands/fields/SetupContainerRegistryCerts.js
webpack/components/extensions/RegistrationCommands/index.js
Expose setup_container_registry_certs parameter in backend registration workflow
  • Extended allowed registration vars to include setup_container_registry_certs in plugin.rb
  • Declared the setup_container_registry_certs Boolean param in the registration_commands API extension
lib/katello/plugin.rb
app/controllers/katello/concerns/api/v2/registration_commands_controller_extensions.rb

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @sjha4 - I've reviewed your changes - here's some feedback:

  • Fix the typo in the SetupContainerRegistryCerts label ("Set up ctainer registry certs" → "Set up container registry certs").
  • Remove the unused pluginValues prop passed into SetupContainerRegistryCerts since the component only uses value, onChange, and isLoading.
  • Make sure the registration command generator is updated to include the --setup-container-registry-certs flag when the checkbox is selected.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

Working well at first try, just one comment for now:

@@ -31,6 +31,7 @@ module ApiPieExtensions
param :activation_keys, Array, desc: N_('Activation keys for subscription-manager client, required for CentOS and Red Hat Enterprise Linux. Required only if host group has no activation keys or if you do not provide a host group.')
param :force, :bool, required: false, desc: N_('Clear any previous registration and run subscription-manager with --force.')
param :ignore_subman_errors, :bool, required: false, desc: N_('Ignore subscription-manager errors for `subscription-manager register` command')
param :setup_container_registry_certs, :bool, required: false, desc: N_('Use container certificates for container registry authentication. If it is set to true, container registry certificates will be installed on the host')
Copy link
Member

Choose a reason for hiding this comment

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

Have we thought about also adding a host parameter for this too? Similar to what we do for Insights, where in the registration form for "Set up Insights" you can either inherit from the param, or override it with the registration option.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't really thought about making this a host parameter. Would it make sense here? The boolean basically controls whether we copy certs from entitlements to containers directory during this registration. It isn't reliable information after the fact given entitlement certs can change leaving container cert setup out of date.

Copy link
Member

Choose a reason for hiding this comment

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

My main concern is how is the default set? If you have container repositories, you might want to set this to true for all new registered hosts. If you don't, you probably don't want to run this. And adding a param may be a good way for the user to express "this is my preference for all new hosts..". Or maybe we could automate that some other way. Just throwing thoughts out there.

Copy link
Member Author

Choose a reason for hiding this comment

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

The default here would be false/nil. I'm not opposed to making this a host param eventually if the API param is not enough with the caveat that the host param value doesn't necessarily mean cert-auth is working on the host due to the nature of container cert auth. In the future, we can look at some way to have sub-man place the certs directly in the container certs directory so we don't have to update the links when entitlement certs change.

Copy link
Member

Choose a reason for hiding this comment

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

Agree, can definitely add that later.

Oh I didn't think about that either.. When entitlement certs change, the filenames will also change so we would need to update the symlinks as well. Maybe a REX job will be needed for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya..I am planning to reuse the existing flatpak rex template to do this: #11403

@sjha4 sjha4 force-pushed the global_reg_param branch from 4175af0 to 863e626 Compare June 3, 2025 15:50
Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

This is working well with theforeman/foreman#10554!

@sjha4 sjha4 force-pushed the global_reg_param branch from 863e626 to 984960f Compare June 4, 2025 19:17
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.

3 participants