Skip to content

tentacle: pybind/mgr/status: drop asserts that fight the defaultdict defaults#68954

Open
tchaikov wants to merge 2 commits into
ceph:tentaclefrom
tchaikov:wip-76634-tentacle
Open

tentacle: pybind/mgr/status: drop asserts that fight the defaultdict defaults#68954
tchaikov wants to merge 2 commits into
ceph:tentaclefrom
tchaikov:wip-76634-tentacle

Conversation

@tchaikov
Copy link
Copy Markdown
Contributor

backport tracker: https://tracker.ceph.com/issues/76634


backport of #68743
parent tracker: https://tracker.ceph.com/issues/76416

this backport was staged using ceph-backport.sh version 16.0.0.6848
find the latest version at https://github.com/ceph/ceph/blob/main/src/script/ceph-backport.sh

tchaikov added 2 commits May 17, 2026 10:30
Enable type narrowing for get_metadata() when a non-None default is
provided. Previously, the return type was always `Optional[Dict[str, str]]`,
forcing callers to use defensive `assert metadata` checks even when
a result was guaranteed.

The wrapper returns either the metadata from `_ceph_get_metadata()` or the
caller-supplied default. Providing an `@overload` allows type checkers to
prove the result is non-None, avoiding invalid assertions for falsy
defaults (like an empty defaultdict).

This is a hygienic change with no runtime impact.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
(cherry picked from commit 5722e48)
The 'assert metadata' checks in the status module were actually fighting
against our own defaults. Since an empty defaultdict is falsy, these
asserts would blow up the whole command if a single daemon was down
after a mgr restart.

This drops those four grumpy asserts. Now, instead of a traceback,
`ceph osd status` and `ceph fs status` will just show a blank hostname
 or "unknown" version as intended.

The trigger is common in practice: any mgr restart leaves daemons
that are currently down without metadata in daemon_state, since
they never reconnect via MMgrOpen to repopulate it. After such a
restart, `ceph osd status` and `ceph fs status` blow up:
```
  Error EINVAL: Traceback (most recent call last):
    ...
    File ".../status/module.py", line 340, in handle_osd_status
      assert metadata
  AssertionError
```

The bug was introduced in 5ac2901

Fixes: https://tracker.ceph.com/issues/76416
Reported-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
(cherry picked from commit 1c5a739)
@tchaikov tchaikov added this to the tentacle milestone May 17, 2026
@github-actions github-actions Bot added cephfs Ceph File System mgr releng-audit-pass Release engineering: passed backport verification audit. labels May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cephfs Ceph File System mgr pybind releng-audit-pass Release engineering: passed backport verification audit.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant