Skip to content

qa/suites: serialize mgr key rotation in rotate-keys task - #72361

Merged
rkachach merged 1 commit into
ceph:mainfrom
yzaken:fix_pulpito_failure_591135
Oct 8, 2026
Merged

rkachach merged 1 commit into
ceph:mainfrom
yzaken:fix_pulpito_failure_591135

Conversation

@yzaken

@yzaken yzaken commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Rotating both mgr keys back-to-back can leave both mgr daemons restarting at the same time. When that race hits, both daemons may fail cephx auth and crash-loop, leaving no active mgr and causing ceph orch commands to hang.

Rework the task flow to rotate OSDs first, then rotate only the standby mgr, wait until it is running, force failover, and rotate the new standby. This serializes mgr redeploys and closes the window where both mgrs are down.

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

Sequence of event from log output

  1. Script fires ceph orch daemon redeploy mgr.x right after, while mgr.y had just been redeployed/was still settling (only 5s + a "ps --refresh" gap, not full 60s, before moving to the next entity.

  2. Redeploying the active mgr while standby's key was just rotated too races the mgr failover with key/keyring regeneration on disk.

  3. Journal shows both mgr.y and mgr.x repeatedly: Control process exited, code=exited, status=1/FAILURE → new container fails immediately, eventually Start request repeated too
    quickly → unit stays failed, no more retries.

  4. No mgr ever comes back up → orchestrator module in teardown blocks indefinitely, there's no active mgr to route the command:

2026-09-29T15:30:40.918 DEBUG:teuthology.orchestra.run.trial040:> sudo cephadm --image quay.ceph.io/ceph-ci/ceph:4e3e8341c054a671a3f1bf5300eec97a8e9ef07f shell -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring --fsid fdd9688e-bc19-11f1-bdb7-d404e6e7d460 -- ceph orch ps --daemon_type agent --refresh -f json

As seen in log this command never returns until we hit max job timeout ~6 hours later.

Conclusion:
The test does not wait long enough / does not verify mgr daemon is actually running before moving to redeploy the second mgr — both mgrs restart too close together.

Testing

Executed the updated script on a local Ceph cluster, looks OK.

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.

@yzaken
yzaken requested a review from a team as a code owner October 3, 2026 16:52
@github-actions

github-actions Bot commented Oct 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.

@yzaken
yzaken force-pushed the fix_pulpito_failure_591135 branch from 8432b0b to 8497260 Compare October 5, 2026 19:22
@yzaken
yzaken requested a review from rkachach October 5, 2026 19:32

@kginonredhat kginonredhat 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 mgr ordering is right, but the failover wait can still rotate the second key before a mgr is available, which is the hang this task is trying to stop.

After ceph mgr fail, wait until ceph mgr stat shows available == true and active_name equal to the rotated standby. active_name != the old mgr is already true when mgr fail returns, and it is also true when the name is empty or null. The sleep 60 does not check that the new mgr is serving.

Wait until the old active mgr is back in ceph mgr dump .standbys[] before calling rotate_and_redeploy on it. Rotating its key first, then calling ceph orch ps with no timeout, can leave no mgr up.

Treat a redeploy as finished only when started is non-empty and different from the saved value. An empty string or null from a failed ceph orch ps currently ends the loop.

Check the daemon status from JSON (status == 1) for more than one poll. grep running is a substring match and can pass on a single sample during a crash loop.

Replace the unbounded key while loop with one comparison after ceph auth rotate. get-key reads the monitor, so the loop does not show that the daemon loaded the new key, and it can sleep forever.

Change the comment on ceph mgr fail so it says the active mgr is failed and the rotated standby takes over.

@yzaken
yzaken force-pushed the fix_pulpito_failure_591135 branch 4 times, most recently from 848524c to ee36394 Compare October 6, 2026 11:11
Rotating both mgr keys back-to-back can leave both mgr daemons
restarting at the same time. When that race hits, both daemons may fail
cephx auth and crash-loop, leaving no active mgr and causing ceph orch
commands to hang.

Rework the task flow to rotate OSDs first, then rotate only the standby
mgr, wait until it is running, force failover, and rotate the new
standby. This serializes mgr redeploys and closes the window where both
mgrs are down.

Fixes: https://tracker.ceph.com/issues/81386
Signed-off-by: Yonatan Zaken <[email protected]>
@yzaken
yzaken force-pushed the fix_pulpito_failure_591135 branch from ee36394 to ec30e78 Compare October 6, 2026 11:14
@yzaken

yzaken commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

The mgr ordering is right, but the failover wait can still rotate the second key before a mgr is available, which is the hang this task is trying to stop.

Done

After ceph mgr fail, wait until ceph mgr stat shows available == true and active_name equal to the rotated standby. active_name != the old mgr is already true when mgr fail returns, and it is also true when the name is empty or null. The sleep 60 does not check that the new mgr is serving.

Done, checking both active and standby after failover were swapped

Wait until the old active mgr is back in ceph mgr dump .standbys[] before calling rotate_and_redeploy on it. Rotating its key first, then calling ceph orch ps with no timeout, can leave no mgr up.

Done, checking both active and standby after failover were swapped

Treat a redeploy as finished only when started is non-empty and different from the saved value. An empty string or null from a failed ceph orch ps currently ends the loop.

I am ok with the loop exiting even if the string is empty, it's just a mechanism to track that something was changed. After that we wait for the daemon to be in running state.

Check the daemon status from JSON (status == 1) for more than one poll. grep running is a substring match and can pass on a single sample during a crash loop.

Keeping one poll should be enough. But I did change to read the status_desc from the JSON output for more robustness over the grep. I chose status_desc == running over status just cause it's more readable that status == 1.

Replace the unbounded key while loop with one comparison after ceph auth rotate. get-key reads the monitor, so the loop does not show that the daemon loaded the new key, and it can sleep forever.

Done, added timeout on the key change check.

Change the comment on ceph mgr fail so it says the active mgr is failed and the rotated standby takes over.

Done

Tested a script execution with the latest changes on a deployed ceph cluster on my workstation.

@yzaken
yzaken requested a review from kginonredhat October 6, 2026 11:34

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

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

Overall LGTM. Just a minor comment.

@rkachach

rkachach commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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