Skip to content

mgr/status: metadata is fetched async - #35161

Merged
yuriw merged 2 commits into
ceph:masterfrom
mgfritch:mgr-status-mds-version
Aug 10, 2020
Merged

yuriw merged 2 commits into
ceph:masterfrom
mgfritch:mgr-status-mds-version

Conversation

@mgfritch

Copy link
Copy Markdown
Contributor

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

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard backend
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@batrick
batrick requested a review from vshankar May 21, 2020 17:25

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 metadata

@mgfritch
mgfritch force-pushed the mgr-status-mds-version branch from ac16ba2 to 6ef1fc9 Compare June 25, 2020 00:40
@mgfritch

Copy link
Copy Markdown
Contributor Author

LGTM, but how about changing the existing a helper for getting given a value from metadata of a service, something like

much more elegant solution, thanks!

@mgfritch

Copy link
Copy Markdown
Contributor Author

jenkins test docs

@mgfritch mgfritch added the DNM label Jun 25, 2020
Comment thread src/pybind/mgr/mgr_module.py Outdated
Comment on lines 1074 to 1078

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if metadata is None:
if default is None:
return None
else:
return defaultdict(lambda: default)
if metadata is None:
return defaultdict(lambda: default)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 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 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

@tchaikov
tchaikov self-requested a review June 25, 2020 04:31
@mgfritch
mgfritch force-pushed the mgr-status-mds-version branch from 6ef1fc9 to f11e8e0 Compare June 25, 2020 21:15
mgfritch added 2 commits June 25, 2020 15:16
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]>
@mgfritch
mgfritch force-pushed the mgr-status-mds-version branch from f11e8e0 to f06e60b Compare June 25, 2020 21:21
@mgfritch

Copy link
Copy Markdown
Contributor Author

ping @tchaikov @vshankar ?

@jan--f jan--f left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants