Skip to content

Support non-root Candlepin by running as tomcat with owned secrets - #651

Merged
evgeni merged 1 commit into
theforeman:masterfrom
Alleny244:fix/candlepin-nonroot-user
Jul 15, 2026
Merged

Support non-root Candlepin by running as tomcat with owned secrets#651
evgeni merged 1 commit into
theforeman:masterfrom
Alleny244:fix/candlepin-nonroot-user

Conversation

@Alleny244

@Alleny244 Alleny244 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Why are you introducing these changes? (Problem description, related links)

Candlepin is moving to a non-root container user (tomcat). By default, Podman mounts secrets as root:root with mode 0440, which prevents the tomcat user from reading the mounted certificates and configuration files unless it is added to the root group inside the container.

This PR updates foremanctl to run Candlepin as tomcat and sets the ownership of secret mounts to the same user, enabling the companion candlepin-oci-images change (USER tomcat, no root group membership).

What are the changes introduced in this pull request?

  • Add candlepin_container_user: tomcat as the default.
  • Configure the Candlepin Quadlet to run with User=tomcat.
  • Add user.yml to determine the tomcat UID/GID from the container image at deploy time (podman run ... id -u/-g).
  • Set the uid/gid on all Candlepin secret mounts so the mounted files are owned by tomcat (mode 0440).
  • Add test_candlepin_runs_as_tomcat to verify Candlepin runs as tomcat and can read the mounted secrets.

Related

How to test this pull request

Deploy

Use a Candlepin image built with the companion candlepin-oci-images change (USER tomcat):

./foremanctl deploy --foreman-initial-admin-password=changeme --tuning development

Verify

podman exec candlepin id -un
# tomcat

podman exec candlepin ls -l /etc/candlepin/candlepin.conf

podman exec candlepin ls -l /etc/candlepin/certs/

podman exec candlepin test -r /etc/candlepin/certs/tomcat.key

curl -k https://localhost:23443/candlepin/status
# HTTP 200

Run automated tests

./forge test --pytest-args="tests/candlepin_test.py -vv"

Note: The non-root behavior is fully validated only with the companion candlepin-oci-images PR. Deployments continue to work with the current image, but the container will still run as the existing image user.

Checklist

  • Tests added/updated (if applicable)
  • Documentation updated (if applicable)

Comment thread src/roles/candlepin/tasks/user.yml Outdated
@Alleny244
Alleny244 force-pushed the fix/candlepin-nonroot-user branch from b050bfe to bd0e421 Compare July 14, 2026 07:03
Comment thread tests/feature/katello/candlepin_test.py
Comment thread src/roles/candlepin/tasks/main.yml Outdated
Comment on lines +92 to +93
[Container]
User={{ candlepin_container_user }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we set this in https://github.com/theforeman/candlepin-oci-images/blob/master/images/candlepin/Containerfile, so all users of the container benefit from it?

(Not blocking, we can change it here, see it works, change it in the container and then remove the two lines here again)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hah, just realized you already have theforeman/candlepin-oci-images#52 open. Nice!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the image change is merged, this should be dropped, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

okay, got it. Can I drop it then, assuming the other pr would be merged first?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But we're using foreman-nightly, not nightly in

container_tag_stream: "nightly"
candlepin_container_image: quay.io/foreman/candlepin
candlepin_container_tag: "foreman-{{ container_tag_stream }}"

What updates the foreman-nightly tag?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any merge that you do on foreman-nightly the image is built and published by Konflux right after.

This is the tag that we are using now https://gitlab.com/fedora/infrastructure/konflux/tenants-config/-/blob/main/clusters/kflux-fedora-01/tenants/theforeman-org-tenant/candlepin/releaseplans/develop/kustomization.yaml?ref_type=heads#L30

Should we also add foreman-nightly alongside nightly as tag?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just added here https://gitlab.com/fedora/infrastructure/konflux/tenants-config/-/merge_requests/212, I'll make sure it's there in one hour after everything syncs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can now use quay.io/foreman/candlepin:foreman-nightly

podman pull quay.io/foreman/candlepin:foreman-nightly
Trying to pull quay.io/foreman/candlepin:foreman-nightly...
Getting image source signatures
Copying blob 0a3d34aa24dc done   | 
Copying blob 452eff874a29 done   | 
Copying config f7a84f58b6 done   | 
Writing manifest to image destination
f7a84f58b60c2c0a002523d70594e708264d17d5b3c652d9357d49028202592d

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't necessarily say this needs to be updated at the same time you tag a new candlepin (or pulp!) nightly. More when there is a new candlepin (or pulp) that should go with foreman nightly (e.g. after a pipeline run that verifies those are compatible, or whatever).

@Alleny244
Alleny244 force-pushed the fix/candlepin-nonroot-user branch from bd0e421 to 3e320ee Compare July 14, 2026 07:43

@archanaserver archanaserver left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread src/roles/candlepin/defaults/main.yml Outdated
@Alleny244
Alleny244 force-pushed the fix/candlepin-nonroot-user branch from 3e320ee to d01bc67 Compare July 15, 2026 06:29
@evgeni

evgeni commented Jul 15, 2026

Copy link
Copy Markdown
Member

"migration" test failure unrelated, explanation and possible fix in #661

@@ -11,6 +11,7 @@ candlepin_ciphers:
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
candlepin_container_image: quay.io/foreman/candlepin
candlepin_container_tag: "4.4.14"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right now our container on nightly is built with 4.8.2, do we need to update it here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No

@ekohl

ekohl commented Jul 15, 2026

Copy link
Copy Markdown
Member

#657 was merged and introduced a merge conflict. My apologies.

auto-merge was automatically disabled July 15, 2026 15:27

Head branch was pushed to by a user without write access

@Alleny244
Alleny244 force-pushed the fix/candlepin-nonroot-user branch from 27ad2c8 to 1a89427 Compare July 15, 2026 15:27
@evgeni
evgeni merged commit 856029f into theforeman:master Jul 15, 2026
12 of 15 checks passed
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.

6 participants