tentacle: pybind/mgr/status: drop asserts that fight the defaultdict defaults#68954
Open
tchaikov wants to merge 2 commits into
Open
tentacle: pybind/mgr/status: drop asserts that fight the defaultdict defaults#68954tchaikov wants to merge 2 commits into
tchaikov wants to merge 2 commits into
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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