Repository navigation
mgr/status: metadata is fetched async - #35161
Conversation
tchaikov
left a comment
There was a problem hiding this comment.
LGTM, but how about changing the existing a helper for getting given a value from metadata of a service, something like
from collections import defaultdict
# ...
def get_metadata(self, svc_type, svc_id, default=None):
metadata = self._ceph_get_metadata(svc_type, svc_id)
if metadata is None:
if default is None:
return None
else:
return defaultdict(lambda: default)
else:
return metadataac16ba2 to
6ef1fc9
Compare
much more elegant solution, thanks! |
|
jenkins test docs |
There was a problem hiding this comment.
| if metadata is None: | |
| if default is None: | |
| return None | |
| else: | |
| return defaultdict(lambda: default) | |
| if metadata is None: | |
| return defaultdict(lambda: default) |
There was a problem hiding this comment.
still not completely right ..
I want to make the suggested change, but then we need to modify all ref's that look like this:
if get_metadata is None:
...otherwise, the status module would need to pass an empty str (or similar):
metadata = self.get_metadata('mds', info['name'], default='')
mds_versions[metadata.get('ceph_version', 'unknown')].append(info['name'])@tchaikov wdyt?
There was a problem hiding this comment.
@mgfritch i think your original fix is to provide a default value of "unknown" for "ceph_version".
as we have
metadata = self.get_metadata('mds', info['name'])
mds_versions[metadata.get('ceph_version', "unknown")].append(info['name'])when trying to fill the mdsmap with mds daemon's version.
with the suggested change, i think we can instead put something like
metadata = self.get_metadata('mds', info['name'], 'unknown')
mds_versions[metadata.get('ceph_version')].append(info['name'])which works even if the metadata of f'mds.info['name'] is not available yet.
because we are only interested in a single value in metadata, a singe default value would suffice. if we want to read more than one value, and would like to have different default values, then default should be a dictionary, or we need to use kwargs for passing the default values.
I want to make the suggested change, but then we need to modify all ref's that look like this:
if get_metadata is None: ...
i don't think it's necessary, as, if default is None, the behavior of the new self.get_metadata() is identical to that of the existing one.
There was a problem hiding this comment.
with the suggested change, i think we can instead put something like
metadata = self.get_metadata('mds', info['name'], 'unknown') mds_versions[metadata.get('ceph_version')].append(info['name'])which works even if the metadata of
f'mds.info['name']is not available yet.
almost works but there are interesting nuances with the default value of an unknown key:
>>> from collections import defaultdict
>>> d = defaultdict(lambda: 'unknown')
>>> d.get('foo') is None
True
>>> d['foo']
'unknown'because we are only interested in a single value in metadata, a singe
defaultvalue would suffice. if we want to read more than one value, and would like to have different default values, thendefaultshould be a dictionary, or we need to usekwargsfor passing the default values.
I moved the defaultdict out of the get_metadata func (f06e60b)
not really sure if this is any cleaner, but any additional thoughts/feedback is welcome
6ef1fc9 to
f11e8e0
Compare
fix timing window during mds rejoin where metadata is not available Fixes: https://tracker.ceph.com/issues/45633 Signed-off-by: Michael Fritch <[email protected]>
fetch metadata using a defaultdict Signed-off-by: Michael Fritch <[email protected]>
f11e8e0 to
f06e60b
Compare
fix timing window during mds rejoin where metadata is not available
Fixes: https://tracker.ceph.com/issues/45633
Signed-off-by: Michael Fritch [email protected]
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard backendjenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume tox