Skip to content

cephadm: report intentionally stopped daemons as stopped - #69283

Merged
rkachach merged 1 commit into
ceph:mainfrom
Shubhaj1810:node-exporter
Jun 30, 2026
Merged

rkachach merged 1 commit into
ceph:mainfrom
Shubhaj1810:node-exporter

Conversation

@Shubhaj1810

@Shubhaj1810 Shubhaj1810 commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

node-exporter exits with status code 143 when stopped via SIGTERM. Systemd interprets this as a failed service, causing cephadm to mark the daemon as error instead of stopped.

This change adds a node-exporter-specific systemd drop-in that sets:

SuccessExitStatus=143

so that intentional stops are treated as successful shutdowns.

Validation

Before:

  • ceph orch daemon stop node-exporter.<host>
  • daemon transitioned to error
  • cluster reported CEPHADM_FAILED_DAEMON

After:

  • ceph orch daemon stop node-exporter.<host>
  • daemon transitions to stopped
  • systemd reports inactive (dead) with exit code 143
  • cluster remains HEALTH_OK

Testing

  • Added unit tests for node-exporter-specific drop-in generation.
  • Verified on a test cluster using a custom image.

Signed-off-by: Shubha Jain [[email protected]]
Fixes: https://tracker.ceph.com/issues/68863
Resolves: IBMCEPH-8866

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.

@Shubhaj1810
Shubhaj1810 requested a review from a team as a code owner June 4, 2026 10:09
@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

I also reproduced the same symptom with mgr (status=143, systemd failed state, CEPHADM_FAILED_DAEMON). Since mgr is Ceph-owned, I kept this change scoped to node-exporter and will investigate the mgr behavior separately.

Comment thread src/cephadm/cephadmlib/systemd_unit.py Resolved
Comment thread src/cephadm/cephadmlib/systemd_unit.py Resolved
@phlogistonjohn

Copy link
Copy Markdown
Contributor

To elaborate a bit on my earlier comment:

  • systemd_unit.update_files is called in deploy_deamon_units
  • deploy_daemon_units takes a container: CephContainer argument
  • CephContainer could be extended to provide a list of success_exit_codes (or something)
  • systemd_unit.update_files can be extended to take a new argument success_exit_codes - which is populated via the same named attribute of CephContainer
  • Finally, we need to glue this together at the ContainerDaemonForm level. That's a matter of (potentially) customizing daemon_to_container OR possibly better just letting the ContainerDaemonForm for this type handle setting it in the container() method (in cephadmlib/daemons/monitoring.py).

@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

To elaborate a bit on my earlier comment:

  • systemd_unit.update_files is called in deploy_deamon_units
  • deploy_daemon_units takes a container: CephContainer argument
  • CephContainer could be extended to provide a list of success_exit_codes (or something)
  • systemd_unit.update_files can be extended to take a new argument success_exit_codes - which is populated via the same named attribute of CephContainer
  • Finally, we need to glue this together at the ContainerDaemonForm level. That's a matter of (potentially) customizing daemon_to_container OR possibly better just letting the ContainerDaemonForm for this type handle setting it in the container() method (in cephadmlib/daemons/monitoring.py).

Thanks for the clarification. I reworked this to follow the container path you suggested.

The success exit status is now carried by CephContainer. The Monitoring daemon form sets success_exit_status = [143] for node-exporter in its container() implementation, and deploy_daemon_units() passes that through to systemd_unit.update_files(). systemd_unit.py remains generic and only generates the drop-in when a non-empty list is provided.

This removes the separate daemon-form interface and keeps the daemon-specific knowledge within the daemon/container implementation.

@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

While validating the node-exporter fix, I also investigated the mgr portion of the original issue.

Reproduction

Stopping a standby mgr daemon:

ceph orch daemon stop mgr.<id>

results in:

HEALTH_WARN 1 failed cephadm daemon(s)
daemon mgr.<id> is in error state

Systemd reports:

Result=exit-code
ExecMainStatus=143

I reproduced this on:

  1. A standby mgr daemon.
  2. A mgr daemon that was previously active, after forcing failover via:
ceph mgr fail <active_mgr>

and then stopping the former active mgr.

Both cases produced the same result (status=143, daemon enters error state).

Comparison with other daemons

  • node-exporter exits with status 143 on SIGTERM and is the issue addressed by this PR.
  • mon exits cleanly (Result=success, ExecMainStatus=0) when stopped.
  • mgr exits with status 143 and is marked failed.

Code investigation

Mgr::init() registers a SIGTERM handler:

register_async_signal_handler_oneshot(SIGTERM, handle_mgr_signal);

which ultimately calls:

_exit(0);

suggesting that mgr is intended to exit cleanly on SIGTERM.

However, after reproducing the issue and inspecting the journal:

journalctl -u <mgr-unit>

I could not find the log message emitted by handle_mgr_signal():

*** Got signal SIGTERM ***

and the observed runtime behavior remains:

Result=exit-code
ExecMainStatus=143

Conclusion

The mgr behavior appears to be a separate issue from node-exporter.

The node-exporter fix in this PR is validated and behaves as expected (stopped daemon, HEALTH_OK, systemd accepts exit code 143 via SuccessExitStatus).

For mgr, the current evidence suggests that the SIGTERM handler is either not being invoked or the process is terminating before the handler can convert the exit status to 0.

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

Thank you very much for incorporating that feedback. Since the earlier version is an intermediate change can I impose on you to please squash the two patches together so we have a cleaner overall history? Feel free to ask for help if you haven't done this before.

node-exporter exits with status 143 when terminated via SIGTERM.
Systemd treats this as a failure by default, causing cephadm to
report an intentionally stopped daemon as being in an error state.

Allow daemon forms to provide daemon-specific success exit status
codes and generate a corresponding systemd SuccessExitStatus
drop-in when required.

For node-exporter, configure exit status 143 as successful so
intentional stops are reported as stopped rather than failed.

Fixes: https://tracker.ceph.com/issues/68863
Signed-off-by: Shubha Jain <[email protected]>
@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

Thank you very much for incorporating that feedback. Since the earlier version is an intermediate change can I impose on you to please squash the two patches together so we have a cleaner overall history? Feel free to ask for help if you haven't done this before.

Thanks for the review. I've squashed the implementation and refactor commits into a single commit and force-pushed the updated branch.

@rkachach

Copy link
Copy Markdown
Contributor

@Shubhaj1810 can you plz open a separate tracker for the mgr not existing correctly on SIGTERM?

@Shubhaj1810

Shubhaj1810 commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@Shubhaj1810 can you plz open a separate tracker for the mgr not existing correctly on SIGTERM?

Sure, I'll open a separate tracker for the mgr SIGTERM handling and keep this PR focused on the node-exporter issue.
Opened tracker https://tracker.ceph.com/issues/77116 for the mgr issue.

@phlogistonjohn phlogistonjohn 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, thanks

@Shubhaj1810

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@rkachach

Copy link
Copy Markdown
Contributor

@rkachach
rkachach merged commit ebbb3e1 into ceph:main Jun 30, 2026
6 checks passed
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.

3 participants