Bug #77151
openmgr: transient rados.connect() during module construction permanently fails the module (no retry)
0%
Description
A single transient rados.connect() failure while a mgr module is being constructed permanently fails that module and pins the cluster in HEALTH_ERR until a manual ceph mgr fail. Hit this on a healthy 19.2.2 (squid) production cluster.
What happened¶
The active mgr restarted while the mons were churning through slow elections. As the mgr loaded its always-on modules, the volumes module opened its own librados handle and the connect was rejected with a transient cephx EPERM:
0 librados: mgr.X authentication error (1) Operation not permitted
-1 mgr load Failed to construct class in 'volumes'
-1 mgr load Traceback (most recent call last):
File "/usr/share/ceph/mgr/volumes/module.py", line 562, in __init__
self.vc = VolumeClient(self)
File "/usr/share/ceph/mgr/volumes/fs/volume.py", line 62, in __init__
self.volspec = VolSpec(mgr.rados.conf_get('client_snapdir'))
File "/usr/share/ceph/mgr/mgr_module.py", line 2238, in rados
self._rados.connect()
rados.PermissionError: [errno 1] RADOS permission error (error connecting to the cluster)
Health stayed at:
HEALTH_ERR Module 'volumes' has failed: Not found or unloadable
even after the mons stabilized. The mgr never retried, so the only recovery was ceph mgr fail to reconstruct the module on a standby. The failure appeared exactly once in the logs (no standing misconfiguration), and the mons were logging "check_health: resetting beacon timeouts due to mon delay (slow election?)" right across that window.
Root cause¶
The shared rados property in src/pybind/mgr/mgr_module.py connects once with no retry:
@property
def rados(self) -> rados.Rados:
if self._rados:
return self._rados
ctx_capsule = self.get_context()
self._rados = rados.Rados(context=ctx_capsule) # cached before connect
self._rados.connect() # single attempt
self._ceph_register_client(None, self._rados.get_addrs(), False)
return self._rados
This handle is shared by volumes, rbd_support, nfs, snap_schedule and others. Whichever module touches it first during construction eats the transient failure, so the affected module is just load-order dependent (volumes on this cluster). A single connect failure in the mon-election window is enough to fail it permanently.
Secondary latent bug: self._rados is assigned before connect(), so a failed connect leaves a poisoned, unconnected handle cached on self._rados.
Reproducer¶
On a vstart cluster (MON=1 MGR=2 MDS=1 OSD=3), inject a one-shot fault at the connect() line gated by a sentinel file, then force reconstruction:
- arm the one-shot fault,
ceph mgr fail <active> - a standby takes over, the first module to use
self.radosthrows, and the cluster goes HEALTH_ERR and stays there for as long as you watch it - a second
ceph mgr fail(fault already consumed) recovers to HEALTH_OK
Matches the production signature exactly.
Proposed fix¶
Make the shared rados property tolerant of transient connect failures: connect a local handle with a small bounded retry/backoff and only cache it on self._rados after a successful connect (also fixes the poisoned-handle issue). rados.PermissionError and rados.TimedOut both derive from rados.Error, so catching rados.Error around connect() covers the transient cases. If the mons are genuinely unreachable the bounded retries still exhaust and the module fails as today, so this can't mask a permanent misconfig, it only rides out the election-window race.
LS Updated by Lumir Sliva 6 months ago
- Related to Bug #77152: mgr: failed always-on module construction is never retried, leaving the cluster in HEALTH_ERR until manual failover added
LS Updated by Lumir Sliva 6 months ago
- Status changed from New to In Progress
- Assignee set to Lumir Sliva
LS Updated by Lumir Sliva 6 months ago
LS Updated by Lumir Sliva 6 months ago
- Pull request ID set to 69318
SZ Updated by Steven Zuraski 5 months ago
- Backport set to squid, tentacle, umbrella
LS Updated by Lumir Sliva 3 months ago
- Status changed from In Progress to Fix Under Review