Skip to content

mgr/cephadm: wait after an OSD restart before restarting the next - #74801

Open
yasser-rafid wants to merge 1 commit into
ceph:mainfrom
yasser-rafid:wip-81929-cephadm-osd-restart-settle
Open

yasser-rafid wants to merge 1 commit into
ceph:mainfrom
yasser-rafid:wip-81929-cephadm-osd-restart-settle

Conversation

@yasser-rafid

@yasser-rafid yasser-rafid commented Dec 3, 2026 •

Copy link
Copy Markdown

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

When a spec change makes cephadm redeploy or reconfigure OSDs, _check_daemons runs osd ok-to-stop before each one. In the same serve loop, it checks the next OSD a few seconds after restarting the previous one. The mgr's PG stats don't show that restart yet, so the check counts the restarted OSD as a live copy and can pass. Two OSDs of the same PGs then go down at once. The tracker issue shows PGs down for 4 to 6 seconds.

Change

  • CephadmOrchestrator._daemon_action records when cephadm last restarted, stopped or started an OSD. It records the time after the action returns, or after it fails. Upgrades, ceph orch daemon … and _check_daemons all go through it, and a slow redeploy doesn't use up the wait.
  • _check_daemons defers an autonomous OSD redeploy or reconfig that comes within osd_restart_settle_time of the last restart, without asking ok-to-stop. User-scheduled actions skip ok-to-stop, as before.
  • New module option mgr/cephadm/osd_restart_settle_time: default 30 s, and 0 disables the wait. Its description is in the option itself (ceph config help mgr/cephadm/osd_restart_settle_time). I can add a doc commit if reviewers want one.
  • A deferred action, or a not-ok-to-stop answer within 5 minutes of a restart by cephadm, makes the serve loop sleep for the settle time instead of the full interval. Before, each refused OSD waited about 10 minutes for the next serve loop.

With the defaults, cephadm restarts at most about one OSD per 30 s during a spec change. That is slower than before, but it no longer takes PGs down.

Not in this PR

  • #81468: osd ok-to-stop N looks only at the PGs whose last acting OSD is N. That makes the check weaker too, but it is a separate fix in the mon/OSD code.
  • A state-based gate, which would wait until the restarted OSD is up and its PGs have re-peered. The time-based wait is a simple floor. A state check could come on top of it later.

Testing

  • New unit tests in cephadm/tests/test_cephadm.py cover:
    • deferral inside the settle time;
    • proceeding after it;
    • 0 disabling the wait;
    • the clock starting after a slow redeploy;
    • which OSD actions record a restart, including failed ones;
    • the retry window after a refusal;
    • the short serve-loop sleep.
  • 14 of the 17 tests I ran fail without the change. The other 3 are the existing ok-to-stop gate tests, which pass either way.
  • Full cephadm/tests run locally: no new failures compared with main.
  • flake8 is clean.

AI assistance

Claude Code (claude-opus-5-5) was used while writing this change. I reviewed and tested it.

Contribution Guidelines

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)

When a spec change makes cephadm redeploy or reconfigure OSDs, it checks
`osd ok-to-stop` before each one, but in the same serve loop it checks
the next OSD a few seconds after restarting the previous one. The mgr's
PG stats do not show that restart yet, so the check counts the
restarted OSD as a live copy and can pass. Two OSDs of the same PGs are
then down at once and PGs go down.

Record when cephadm last restarted, stopped or started an OSD, in
_daemon_action after the action returns, so upgrades, `ceph orch daemon`
actions and _check_daemons all count and a slow redeploy does not use up
the wait. An autonomous OSD action within osd_restart_settle_time
(default 30s, 0 disables) of that is deferred without asking ok-to-stop.

A deferred action, or a not-ok-to-stop answer within 5 minutes of a
restart by cephadm, makes the serve loop sleep for the settle time
instead of the full interval, so OSDs no longer wait about 10 minutes
each to be retried.

Fixes: https://tracker.ceph.com/issues/81929
Signed-off-by: Yasser Rafid <[email protected]>
@yasser-rafid
yasser-rafid requested a review from a team as a code owner December 3, 2026 14:51
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR ci-approved to allow Jenkins CI jobs to run.

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.

2 participants