Repository navigation
pybind/mgr/status: drop asserts that fight the defaultdict defaults - #68743
Conversation
|
cc @A6GibKm |
d64cdbb to
ac9734e
Compare
|
jenkins test make check arm64 |
1 similar comment
|
jenkins test make check arm64 |
|
the test failure on arm64 should be addressed by #68816 |
|
jenkins test make check arm64 |
NitzanMordhai
left a comment
There was a problem hiding this comment.
@tchaikov LGTM, just a few questions
| svc_id: str) -> Optional[Dict[str, str]]: | ||
| ... | ||
|
|
||
| @overload |
There was a problem hiding this comment.
Missing default=None overload ?
There was a problem hiding this comment.
indeed. added in the latest revision.
| def get_metadata(self, | ||
| svc_type: str, | ||
| svc_id: str, | ||
| default: Dict[str, str]) -> Dict[str, str]: |
There was a problem hiding this comment.
Should default accept Mapping[str, str] to be more permissive about what callers can pass in?
There was a problem hiding this comment.
i am afraid we should not. if default is typed Mapping[str, str] but the return type is Dict[str, str], that would be a lie. because a Mapping is not necessarily a Dict. as, if the metadata does not have a matching key, the default is used for the return value.
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 <[email protected]>
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 <[email protected]>
Signed-off-by: Kefu Chai <[email protected]>
ac9734e to
1c5a739
Compare
|
changelog:
|
|
jenkins test pr |
|
jenkins test make check |
|
jenkins test make check arm64 |
|
jenkins test windows |
1 similar comment
|
jenkins test windows |
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 statusandceph fs statuswill just show a blank hostnameor "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 statusandceph fs statusblow up:The bug was introduced in 5ac2901
Fixes: https://tracker.ceph.com/issues/76416
Reported-by: Maximiliano Sandoval [email protected]
Signed-off-by: Kefu Chai [email protected]
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.