Project

General

Profile

Actions

Bug #80440

closed
DP SB

cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring)

Bug #80440: cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring)

Added by David Pérez Ruiz 3 months ago. Updated 7 days ago.

Status:
Resolved
Priority:
Urgent
Category:
cephadm
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
umbrella, tentacle, squid
Regression:
No
Severity:
2 - major
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-3460-g28794f775e
Released In:
Upkeep Timestamp:
2026-11-26T01:06:34+00:00

Description

Summary

On a cephadm cluster with LVM BlueStore OSDs (--no-tmpfs), every reconfig of an OSD stops the OSD, rewrites the osd_key BlueStore label and starts it again. This happens even though the OSD's cephx key has not changed. The trigger is a plain-text comparison in create_daemon_dirs that can never succeed after the OSD has been started once. The cephadm serve loop reconfigures all OSDs one after another on a monmap change, so adding or removing a monitor restarts every OSD in the cluster within about a minute, without ok-to-stop checks and without waiting for each OSD to come back up.

Environment

  • Ceph 19.2.6 (quay.io/ceph/ceph@sha256:ff836bb28e7d0be0ec4dd22e79407174452a96e11ee62e9cdd1fa47f4bcc3bdc), deployed with cephadm
  • 3 hosts, 6 LVM BlueStore OSDs (2 per host), replicated pools with size 3 and min_size 2
  • Hosts: Ubuntu 22.04 (kernel 5.15, docker 27.5.1) and Ubuntu 26.04 (kernel 7.0, podman 5.7.0) (Upgrade in process)
  • The unit.run of the OSDs uses ceph-volume activate --osd-id N --osd-uuid U --no-systemd --no-tmpfs

What happened

A monitor was added back to the mon placement (host re-added after an OS reinstall). The serve loop then logged Reconfiguring osd.N (monmap changed)... for every OSD. Each reconfig stopped and restarted the OSD, as seen in the OSD journal (prepare_to_stop telling mon we are shutting down and dead, then a new container start) and in cephadm.log (Successfully rotated osd.N keyring). The keyring blob sent by the mgr contained the same key before and after, so no rotation was needed.

07:07:54 cephadm [INF] Saving service mon spec with placement host-a;host-b;host-c
07:07:58 cephadm [INF] Deploying daemon mon.host-c on host-c
07:08:08 (host-a journal) osd.1 prepare_to_stop telling mon we are shutting down and dead
07:08:11 cephadm [INF] Reconfiguring osd.5 (monmap changed)...
07:08:11 cephadm [INF] Reconfiguring daemon osd.5 on host-a
07:08:22 cephadm [INF] Reconfiguring daemon osd.4 on host-b
07:08:29 cephadm [INF] Reconfiguring daemon osd.2 on host-b
07:08:36 cephadm [INF] Reconfiguring daemon osd.3 on host-c
07:08:40 (host-c cephadm.log) INFO Successfully rotated osd.3 keyring
07:08:46 cephadm [INF] Reconfiguring daemon osd.0 on host-c
07:08:50 (host-c cephadm.log) INFO Successfully rotated osd.0 keyring

Root cause

  1. create_daemon_dirs() in src/cephadm/cephadm.py (same code in v19.2.6 and main) compares the full text of the existing keyring file with the keyring received from the mgr:
    if (
        ident.daemon_type == 'osd'
        and key_path_exists
        and key_path_content != keyring
    ):
        # need to update keyring with ceph-bluestore-tool
        update_bluestore_label_osd_keyring = True
    ...
    if update_bluestore_label_osd_keyring:
        osd_daemon_form = OSD.create(ctx, ident)
        osd_daemon_form.rotate_osd_lv_keyring(ctx, keyring_path)
    
  2. The keyring sent by the mgr is exactly the output of ceph auth get osd.N: a tab-indented key = ... line followed by the three caps ... lines. We verified this: the sha256 of config_blobs.keyring logged in cephadm.log is identical to the sha256 of ceph auth get osd.N.
  3. At every OSD start, ceph-volume activate --no-tmpfs runs ceph-bluestore-tool prime-osd-dir. That rewrites /var/lib/ceph/<fsid>/osd.N/keyring from the osd_key label in a different, short format (src/os/bluestore/bluestore_tool.cc):
    if (k == "osd_key") {
      p = path + "/keyring";
      v = "[osd.";
      v += label.meta["whoami"];
      v += "]\nkey = " + i->second;
    }
    v += "\n";
    
  4. The key is the same but the text is different, so after any OSD start the comparison always reports a change. Every later reconfig of that OSD therefore calls rotate_osd_lv_keyring(), which runs <engine> stop on the OSD container, then ceph-bluestore-tool set-label-key -k osd_key, then systemctl start.

The file contents on a running OSD right after startup (key masked):

# /var/lib/ceph/<fsid>/osd.1/keyring
[osd.1]
key = <masked>

# ceph auth get osd.1   (what the mgr sends)
[osd.1]
    key = <masked>
    caps mgr = "allow profile osd" 
    caps mon = "allow profile osd" 
    caps osd = "allow *" 

Impact

Any action that makes cephadm reconfigure Ceph daemons restarts all OSDs in quick succession. Examples: adding or removing a mon (monmap changed), extra config changed, ceph orch daemon reconfig osd.N. There are about 7-10 seconds between OSDs, with no ok-to-stop check and no wait for the previous OSD to be up.

In our cluster this took all 225 PGs inactive for about 16 minutes. The restarts on their own would likely have been survivable, but on hosts with krbd devices mapped against the same cluster (Kubernetes with ceph-csi. Yes, maybe we need to go to rook), the restarted OSDs never came back: ceph-volume activate hung reading /dev/rbdN while the PGs were inactive. That is reported separately in the ceph-volume issue linked.

How to reproduce

Observed with a monmap change. ceph orch daemon reconfig goes through the same code path (_daemon_action('reconfig'), then _create_daemon(reconfig=True), then cephadm deploy --reconfig, then create_daemon_dirs):

# any cephadm cluster with LVM OSDs, after an OSD has been (re)started at least once
diff <(cat /var/lib/ceph/$FSID/osd.0/keyring) <(ceph auth get osd.0)   # differs only in format
ceph osd dump | grep '^osd.0 '        # note up_from
ceph orch daemon reconfig osd.0
grep 'osd.0 keyring' /var/log/ceph/cephadm.log | tail -1   # "Successfully rotated osd.0 keyring" 
ceph osd dump | grep '^osd.0 '        # up_from has changed -> the OSD was restarted

Workaround

Right before any operation that triggers a reconfig (for example a mon placement change), overwrite each OSD keyring file with the exact output of ceph auth get osd.N (owner 167:167, mode 0600). The texts then match, and the reconfig no longer stops the OSD. The workaround must be reapplied after any OSD restart, because prime-osd-dir rewrites the file again.

Related

ceph-volume activate probes every block device (including /dev/rbdN) with show-label before trying LVM; it hangs in D state when that RBD's PGs are inactive, deadlocking OSD start on hosts with krbd mappings


Related issues 4 (0 open — 4 closed)

Related to Orchestrator - Bug #80399: Unplanned OSD reconfig and bluestore key update during mon-only staggered upgradeResolvedShweta Bhosale

Actions
Copied to Orchestrator - Backport #80803: squid: cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring)ResolvedShweta Bhosale

Actions
Copied to Orchestrator - Backport #80804: tentacle: cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring)ResolvedShweta Bhosale

Actions
Copied to Orchestrator - Backport #80805: umbrella: cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring)ResolvedShweta Bhosale

Actions

DP Updated by David Pérez Ruiz 3 months ago Actions #1

Summary

On a cephadm cluster with LVM BlueStore OSDs (--no-tmpfs), every reconfig of an OSD stops the OSD, rewrites the osd_key BlueStore label and starts it again. This happens even though the OSD's cephx key has not changed. The trigger is a plain-text comparison in create_daemon_dirs that can never succeed after the OSD has been started once. The cephadm serve loop reconfigures all OSDs one after another on a monmap change, so adding or removing a monitor restarts every OSD in the cluster within about a minute, without ok-to-stop checks and without waiting for each OSD to come back up.

Environment

  • Ceph 19.2.6 (quay.io/ceph/ceph@sha256:ff836bb28e7d0be0ec4dd22e79407174452a96e11ee62e9cdd1fa47f4bcc3bdc), deployed with cephadm
  • 3 hosts, 6 LVM BlueStore OSDs (2 per host), replicated pools with size 3 and min_size 2
  • Hosts: Ubuntu 22.04 (kernel 5.15, docker 27.5.1) and Ubuntu 26.04 (kernel 7.0, podman 5.7.0)
  • The unit.run of the OSDs uses ceph-volume activate --osd-id N --osd-uuid U --no-systemd --no-tmpfs

What happened

A monitor was added back to the mon placement (host re-added after an OS reinstall). The serve loop then logged Reconfiguring osd.N (monmap changed)... for every OSD. Each reconfig stopped and restarted the OSD, as seen in the OSD journal (prepare_to_stop telling mon we are shutting down and dead, then a new container start) and in cephadm.log (Successfully rotated osd.N keyring). The keyring blob sent by the mgr contained the same key before and after, so no rotation was needed.

07:07:54 cephadm [INF] Saving service mon spec with placement host-a;host-b;host-c
07:07:58 cephadm [INF] Deploying daemon mon.host-c on host-c
07:08:08 (host-a journal) osd.1 prepare_to_stop telling mon we are shutting down and dead
07:08:11 cephadm [INF] Reconfiguring osd.5 (monmap changed)...
07:08:11 cephadm [INF] Reconfiguring daemon osd.5 on host-a
07:08:22 cephadm [INF] Reconfiguring daemon osd.4 on host-b
07:08:29 cephadm [INF] Reconfiguring daemon osd.2 on host-b
07:08:36 cephadm [INF] Reconfiguring daemon osd.3 on host-c
07:08:40 (host-c cephadm.log) INFO Successfully rotated osd.3 keyring
07:08:46 cephadm [INF] Reconfiguring daemon osd.0 on host-c
07:08:50 (host-c cephadm.log) INFO Successfully rotated osd.0 keyring

Root cause

  1. create_daemon_dirs() in src/cephadm/cephadm.py (same code in v19.2.6 and main) compares the full text of the existing keyring file with the keyring received from the mgr:
    if (
        ident.daemon_type == 'osd'
        and key_path_exists
        and key_path_content != keyring
    ):
        # need to update keyring with ceph-bluestore-tool
        update_bluestore_label_osd_keyring = True
    ...
    if update_bluestore_label_osd_keyring:
        osd_daemon_form = OSD.create(ctx, ident)
        osd_daemon_form.rotate_osd_lv_keyring(ctx, keyring_path)
    
  2. The keyring sent by the mgr is exactly the output of ceph auth get osd.N: a tab-indented key = ... line followed by the three caps ... lines. We verified this: the sha256 of config_blobs.keyring logged in cephadm.log is identical to the sha256 of ceph auth get osd.N.
  3. At every OSD start, ceph-volume activate --no-tmpfs runs ceph-bluestore-tool prime-osd-dir. That rewrites /var/lib/ceph/<fsid>/osd.N/keyring from the osd_key label in a different, short format (src/os/bluestore/bluestore_tool.cc):
    if (k == "osd_key") {
      p = path + "/keyring";
      v = "[osd.";
      v += label.meta["whoami"];
      v += "]\nkey = " + i->second;
    }
    v += "\n";
    
  4. The key is the same but the text is different, so after any OSD start the comparison always reports a change. Every later reconfig of that OSD therefore calls rotate_osd_lv_keyring(), which runs <engine> stop on the OSD container, then ceph-bluestore-tool set-label-key -k osd_key, then systemctl start.

The file contents on a running OSD right after startup (key masked):

# /var/lib/ceph/<fsid>/osd.1/keyring
[osd.1]
key = <masked>

# ceph auth get osd.1   (what the mgr sends)
[osd.1]
    key = <masked>
    caps mgr = "allow profile osd" 
    caps mon = "allow profile osd" 
    caps osd = "allow *" 

Impact

Any action that makes cephadm reconfigure Ceph daemons restarts all OSDs in quick succession. Examples: adding or removing a mon (monmap changed), extra config changed, ceph orch daemon reconfig osd.N. There are about 7-10 seconds between OSDs, with no ok-to-stop check and no wait for the previous OSD to be up.

In our cluster this took all 225 PGs inactive for about 16 minutes. The restarts on their own would likely have been survivable, but on hosts with krbd devices mapped against the same cluster (Kubernetes with ceph-csi. Yes, maybe we need to go to rook), the restarted OSDs never came back: ceph-volume activate hung reading /dev/rbdN while the PGs were inactive. That is reported separately in the ceph-volume issue linked below.

How to reproduce

Observed with a monmap change. ceph orch daemon reconfig goes through the same code path (_daemon_action('reconfig'), then _create_daemon(reconfig=True), then cephadm deploy --reconfig, then create_daemon_dirs):

# any cephadm cluster with LVM OSDs, after an OSD has been (re)started at least once
diff <(cat /var/lib/ceph/$FSID/osd.0/keyring) <(ceph auth get osd.0)   # differs only in format
ceph osd dump | grep '^osd.0 '        # note up_from
ceph orch daemon reconfig osd.0
grep 'osd.0 keyring' /var/log/ceph/cephadm.log | tail -1   # "Successfully rotated osd.0 keyring" 
ceph osd dump | grep '^osd.0 '        # up_from has changed -> the OSD was restarted

Workaround

Right before any operation that triggers a reconfig (for example a mon placement change), overwrite each OSD keyring file with the exact output of ceph auth get osd.N (owner 167:167, mode 0600). The texts then match, and the reconfig no longer stops the OSD. The workaround must be reapplied after any OSD restart, because prime-osd-dir rewrites the file again.

Related to

ceph-volume activate probes every block device (including /dev/rbdN) with show-label before trying LVM; it hangs in D state when that RBD's PGs are inactive, deadlocking OSD start on hosts with krbd mappings
https://tracker.ceph.com/issues/80441

JB Updated by Joshua Blanch 3 months ago Actions #2

  • Pull request ID set to 71705

JB Updated by Joshua Blanch 3 months ago Actions #3

  • Pull request ID changed from 71705 to 71640

JB Updated by Joshua Blanch 3 months ago Actions #4

  • Related to Bug #80399: Unplanned OSD reconfig and bluestore key update during mon-only staggered upgrade added

UB Updated by Upkeep Bot 2 months ago Actions #5

  • Status changed from New to Resolved
  • Merge Commit set to 28794f775eb18ca47951f30d392999a2af98e94e
  • Fixed In set to v21.3.0-3460-g28794f775e
  • Upkeep Timestamp set to 2026-09-21T11:44:46+00:00

RK Updated by Redouane Kachach Elhicou 2 months ago Actions #6

  • Status changed from Resolved to Pending Backport
  • Assignee set to Shweta Bhosale

RK Updated by Redouane Kachach Elhicou 2 months ago Actions #7

  • Backport set to umbrella, tentacle, squid

UB Updated by Upkeep Bot 2 months ago Actions #8

  • Copied to Backport #80803: squid: cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring) added

UB Updated by Upkeep Bot 2 months ago Actions #9

  • Copied to Backport #80804: tentacle: cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring) added

UB Updated by Upkeep Bot 2 months ago Actions #10

  • Copied to Backport #80805: umbrella: cephadm: every reconfig of an OSD stops and restarts it, because the keyring text never matches the one rewritten by ceph-volume (spurious rotate_osd_lv_keyring) added

UB Updated by Upkeep Bot 2 months ago Actions #11

  • Status changed from Pending Backport to Backporting
  • Upkeep Timestamp changed from 2026-09-21T11:44:46+00:00 to 2026-09-23T17:56:01+00:00

DV Updated by Dan van der Ster about 2 months ago Actions #12

  • Priority changed from Normal to Urgent

UB Updated by Upkeep Bot 7 days ago Actions #13

  • Status changed from Backporting to Resolved
  • Upkeep Timestamp changed from 2026-09-23T17:56:01+00:00 to 2026-11-26T01:06:34+00:00
Actions

Also available in: PDF Atom