Skip to content

feat(rhcconf): write rhc.conf configuration to rhsm.conf - #627

Merged
stephenbourke merged 1 commit into
mainfrom
sbourke/write-to-rhsm
Nov 4, 2026
Merged

stephenbourke merged 1 commit into
mainfrom
sbourke/write-to-rhsm

Conversation

@stephenbourke

@stephenbourke stephenbourke commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor
* Card ID: CCT-3023

- Write only the registration target, content base URL, and proxy keys
that rhc.conf sets explicitly into rhsm.conf, through
com.redhat.RHSM1.Config.SetAll. SetAll applies every key in a single
call so a failure cannot leave rhsm.conf with only some keys written.
Commented keys and embedded defaults are omitted, so the packaged
rhc.conf leaves rhsm.conf unchanged. api.insights and http.timeout are
not translated. api.rpm-content tls-verify and ca-path are not written:
server.insecure and rhsm.repo_ca_cert already come from
api.subscriptions.

- Map api.subscriptions.uri to server.hostname, server.port, and
server.prefix, and ca-path to rhsm.repo_ca_cert, except ca-path
"system", which selects the system trust store and is not a
certificate file. For an explicit ca-path, validate the file exists
and is readable before writing, and also set rhsm.ca_cert_dir to its
directory so subscription-manager trusts the CA when it opens the
registration connection, not only when dnf later reads repo files.
Invert tls-verify into server.insecure. Map an explicit
api.rpm-content.url to rhsm.baseurl as a whole http or https URI. Map
http.proxy uri, user, password, and no-proxy to the matching
server.proxy_* and server.no_proxy settings. Reject a subscriptions
URI that is not https://host[:port]/prefix, a missing or unreadable
ca-path, and an RPM content URI that is not an absolute http or https
URI, before any Config.SetAll or Register call.

- Apply the translation on rhc connect before registration, and on
rhc configure features enable when the system is not registered. A
write error stops before Register. Enabling a feature on an already
registered system does not rewrite the registration target.

- Added integration tests to test writing rhc.conf keys to rhsm.conf

Comment thread internal/subman/config.go Fixed
@stephenbourke
stephenbourke force-pushed the sbourke/write-to-rhsm branch 2 times, most recently from 63703ed to 780e453 Compare November 2, 2026 11:47
@stephenbourke
stephenbourke marked this pull request as ready for review November 2, 2026 13:16
@stephenbourke
stephenbourke requested a review from a team as a code owner November 2, 2026 13:16
Comment thread pkg/operations/rhsmconfig.go Resolved
Comment thread internal/rhcconf/rhsm.go Resolved

@pkoprda pkoprda 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.

Thanks @stephenbourke, I left some comments below.

Also please add Signed-off-by: at the end of your commit description.

Comment thread internal/rhcconf/rhsm.go Resolved
Comment thread internal/rhcconf/rhsm.go Resolved
Comment thread pkg/operations/rhsmconfig_test.go Resolved
Comment thread internal/rhcconf/rhsm.go Resolved
Comment thread pkg/operations/rhsmconfig.go Resolved
@stephenbourke
stephenbourke force-pushed the sbourke/write-to-rhsm branch 3 times, most recently from 64a6824 to b2826ba Compare November 3, 2026 11:37
@Archana-PandeyM

Copy link
Copy Markdown
Collaborator

Looked into the test_features_enable_writes_satellite_registration_target failure (DuplicateSectionError: section 'rhsm' already exists, rhsm.conf line 38).
looks lie It's not the rhc.conf to rhsm.conf translation rather a race in rhsm-service that our four sequential Config.Set calls expose.

Suggested fix on our side: use a single SetAll instead of four Set calls , one in-memory update, one persist, no intermediate events to race against. The subman Set() docstring recommends exactly this.

@stephenbourke
stephenbourke force-pushed the sbourke/write-to-rhsm branch 4 times, most recently from 1cdf8ac to 03cd5a0 Compare November 3, 2026 16:25
pkoprda
pkoprda previously approved these changes Nov 4, 2026

@pkoprda pkoprda 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 internal/subman/config.go Resolved
Archana-PandeyM
Archana-PandeyM previously approved these changes Nov 4, 2026

@Archana-PandeyM Archana-PandeyM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

Archana-PandeyM
Archana-PandeyM previously approved these changes Nov 4, 2026

@mjcr99 mjcr99 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.

Thanks @stephenbourke! I think I've spotted a couple of worth to do checks.

Comment thread internal/rhcconf/rhsm.go Resolved
Comment thread internal/rhcconf/rhsm.go Resolved
* Card ID: CCT-3023

- Write only the registration target, content base URL, and proxy keys
that rhc.conf sets explicitly into rhsm.conf, through
com.redhat.RHSM1.Config.SetAll. SetAll applies every key in a single
call so a failure cannot leave rhsm.conf with only some keys written.
Commented keys and embedded defaults are omitted, so the packaged
rhc.conf leaves rhsm.conf unchanged. api.insights and http.timeout are
not translated. api.rpm-content tls-verify and ca-path are not written:
server.insecure and rhsm.repo_ca_cert already come from
api.subscriptions.

- Map api.subscriptions.uri to server.hostname, server.port, and
server.prefix, and ca-path to rhsm.repo_ca_cert, except ca-path
"system", which selects the system trust store and is not a
certificate file. For an explicit ca-path, validate the file exists
and is readable before writing, and also set rhsm.ca_cert_dir to its
directory so subscription-manager trusts the CA when it opens the
registration connection, not only when dnf later reads repo files.
Invert tls-verify into server.insecure. Map an explicit
api.rpm-content.url to rhsm.baseurl as a whole http or https URI. Map
http.proxy uri, user, password, and no-proxy to the matching
server.proxy_* and server.no_proxy settings. Reject a subscriptions
URI that is not https://host[:port]/prefix, a missing or unreadable
ca-path, and an RPM content URI that is not an absolute http or https
URI, before any Config.SetAll or Register call.

- Apply the translation on rhc connect before registration, and on
rhc configure features enable when the system is not registered. A
write error stops before Register. Enabling a feature on an already
registered system does not rewrite the registration target.

- Added integration tests to test writing rhc.conf keys to rhsm.conf

Signed-off-by: Stephen Bourke <sbourke@redhat.com>
@stephenbourke
stephenbourke merged commit 716fc40 into main Nov 4, 2026
29 of 30 checks passed
@stephenbourke
stephenbourke deleted the sbourke/write-to-rhsm branch November 4, 2026 13:40
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.

5 participants