Skip to content

mgr/cephadm: track TLS spec changes in deps and cleanup stale certmgr entries on cert source transitions - #67308

Merged
rkachach merged 6 commits into
ceph:mainfrom
rkachach:fix_issue_ssl_cert_deps
May 23, 2026
Merged

rkachach merged 6 commits into
ceph:mainfrom
rkachach:fix_issue_ssl_cert_deps

Conversation

@rkachach

@rkachach rkachach commented Feb 11, 2026 •

Copy link
Copy Markdown
Contributor

This PR improves TLS certificate handling for cephadm-managed services:

  1. Include TLS-related spec fields in service deps (certificate_source + hashed ssl_cert/ssl_key/ssl_ca_cert) so changes reliably trigger reconciliation/reconfig.

  2. When switching to certificate_source: reference, remove inline-saved / non-editable certmgr entries (service-scope) to avoid pinning to old inline values and let users provision editable certs/keys via certmgr.

  3. Add best-effort cleanup for leftover TLS credentials during daemon removal and cert source changes, while keeping referenced/user-managed entries.

  4. Fix self-signed “with label” lookup to use the host (not FQDN) when fetching stored credentials.

Fixes: https://tracker.ceph.com/issues/75009

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@rkachach rkachach changed the title Fix issue ssl cert deps [WIP] Fix issue ssl cert deps Feb 11, 2026
@rkachach
rkachach force-pushed the fix_issue_ssl_cert_deps branch 3 times, most recently from 149c33a to 5ae0214 Compare February 13, 2026 15:24
@rkachach
rkachach force-pushed the fix_issue_ssl_cert_deps branch 2 times, most recently from 9685a8f to 469b7bd Compare February 16, 2026 16:48
@rkachach
rkachach force-pushed the fix_issue_ssl_cert_deps branch from 469b7bd to 695a73d Compare February 17, 2026 14:37
@rkachach
rkachach requested review from a team, ShwetaBhosale1 and Copilot February 17, 2026 14:38

Copilot AI 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.

Pull request overview

This PR fixes an issue with SSL certificate dependency tracking in cephadm. When services use SSL certificates, changes to the certificate source (inline, reference, or cephadm-signed) need to trigger service reconfiguration, and stale certificate artifacts need to be cleaned up when switching between sources.

Changes:

  • Added certificate_source as a tracked dependency for SSL-enabled services, ensuring reconfigurations occur when the certificate source changes
  • Implemented cleanup logic to remove stale certificate artifacts when services switch certificate sources, while preserving user-provisioned reference certificates
  • Added user warnings when certificate sources are changed to inform about potential client disconnections

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/pybind/mgr/cephadm/tlsobject_store.py Added get_tlsobject_if_exists method for safe certificate lookups without exceptions
src/pybind/mgr/cephadm/cert_mgr.py Added cleanup methods try_rm_self_signed_cert_key_pair and rm_inline_saved_cert_key_pair for certificate lifecycle management
src/pybind/mgr/cephadm/services/cephadmservice.py Updated base get_dependencies to track certificate_source, added reconciliation cleanup in get_certificates_generic, and refactored post_remove for proper scope-aware cleanup
src/pybind/mgr/cephadm/services/nfs.py Removed local SSL dependency tracking in favor of parent class implementation
src/pybind/mgr/cephadm/services/monitoring.py Fixed generate_config to pass spec to get_dependencies, enabling TLS dependency tracking
src/pybind/mgr/cephadm/services/ingress.py Updated to call parent get_dependencies for TLS certificate dependencies
src/pybind/mgr/cephadm/services/iscsi.py Updated to call parent get_dependencies for TLS certificate dependencies
src/pybind/mgr/cephadm/services/oauth2_proxy.py Updated to call parent get_dependencies for TLS certificate dependencies
src/pybind/mgr/cephadm/services/mgmt_gateway.py Updated to call parent get_dependencies for TLS certificate dependencies
src/pybind/mgr/cephadm/module.py Added user warnings for certificate source changes and improved reference certificate provisioning instructions
src/pybind/mgr/cephadm/tests/test_services.py Updated test expectations to account for new certificate_source dependency and adjusted daemon name indices in dependencies list
src/pybind/mgr/cephadm/tests/test_certmgr.py Added comprehensive tests for certificate cleanup logic, dependency tracking, and cross-source transitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rkachach
rkachach force-pushed the fix_issue_ssl_cert_deps branch 2 times, most recently from d9e93cd to 474ea9c Compare February 18, 2026 14:59
@rkachach rkachach changed the title [WIP] Fix issue ssl cert deps mgr/cephadm: track TLS spec changes in deps and cleanup stale certmgr entries on cert source transitions Feb 18, 2026
@rkachach
rkachach force-pushed the fix_issue_ssl_cert_deps branch 2 times, most recently from c0e6609 to 6d4d9e9 Compare February 18, 2026 16:10
@rkachach
rkachach marked this pull request as ready for review February 19, 2026 09:34
@rkachach
rkachach requested a review from abhidesai6 February 19, 2026 09:38
@abhidesai6

abhidesai6 commented Feb 19, 2026 •

Copy link
Copy Markdown

Tested the PR with dashboard changes, check the screenplay in PR here . It consists of changing the certificate source for a service, where we can see the certificate source changes in the UI and old certs gets deleted

Adding more testing logs asap.

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

The code seems to be doing what you intended it to. I am a bit worried about accidentally cleaning something up here we shouldn't . I didn't really go through the UT (I guess we also need to address how those were generated at some point) and maybe they cover everything, but I just want to stress that this needs to be done carefully. Especially when you consider the variety of different ways of storing and marking certs users could have on their old cluster before they upgrade to a version with this change.

@rkachach
rkachach force-pushed the fix_issue_ssl_cert_deps branch from 221225e to f1afafd Compare February 23, 2026 16:01
@rkachach
rkachach requested review from adk3798 and Copilot February 23, 2026 16:35
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

rkachach added 4 commits May 14, 2026 11:08
This is especially important for inline certificates, so the certmgr
store is updated automatically whenever the user changes the values in
the spec and reapplies it.

Fixes: https://tracker.ceph.com/issues/75009

Signed-off-by: Redouane Kachach <[email protected]>
This PR improves certificate cleanup when a service switches
certificate sources (cephadm-signed <-> inline/reference). It also adds
best-effort post-remove helpers to purge stale cephadm-managed
cert/key pairs. Inline-stored (non-editable) certs/keys are removed,
while referenced/user-managed (editable) credentials are preserved.

Fixes: https://tracker.ceph.com/issues/75009

Signed-off-by: Redouane Kachach <[email protected]>

Copilot AI 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.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/pybind/mgr/cephadm/module.py:3945

  • In the per-host reference instructions, the key command uses --key-name {svc.cert_name}. This looks incorrect: it should reference the service's key object name (e.g. grafana_ssl_key), not the cert object name (grafana_ssl_cert). Using the cert name here will store the private key under the wrong object name and the service won't be able to fetch it.
                    f"\n\n\nWarning: SSL is configured with '{CertificateSource.REFERENCE.value}', and this service uses per-host certificates.\n\n"
                    f"To configure keys/certificates, run the following commands for each host daemons are deployed on:\n"
                    f"  > ceph orch certmgr cert set --cert-name {svc.cert_name} --service-name {spec.service_name()} --hostname <host>  -i <cert-file>\n"
                    f"  > ceph orch certmgr key set --key-name {svc.cert_name} --service-name {spec.service_name()} --hostname <host> -i <key-file>\n\n"
                    f"Once all certificates are provisioned, run:\n"

Comment thread src/pybind/mgr/cephadm/module.py Resolved
Comment thread src/pybind/mgr/cephadm/module.py Resolved
@rkachach
rkachach force-pushed the fix_issue_ssl_cert_deps branch from 513961d to 16b7a0b Compare May 22, 2026 18:22
@rkachach

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@rkachach

Copy link
Copy Markdown
Contributor Author

@rkachach
rkachach merged commit 4bc3c23 into ceph:main May 23, 2026
6 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/26327641792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants