Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr/dashboard: improve error handling #18182

Merged
merged 1 commit into from Oct 26, 2017
Merged

mgr/dashboard: improve error handling #18182

merged 1 commit into from Oct 26, 2017

Conversation

nrdmn
Copy link
Contributor

@nrdmn nrdmn commented Oct 9, 2017

This commit replaces assertions and uncaught exceptions with appropriate http error codes.

Signed-off-by: Nick Erdmann n@nirf.de

@tchaikov tchaikov requested a review from jcsp October 9, 2017 10:50
content_data = {
"fs_status": global_instance().fs_status(fs_id)
}
except TypeError:
Copy link
Contributor

Choose a reason for hiding this comment

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

Catching TypeError is kind of weird here, better to change fs_status to raise a sane exception: (done in https://github.com/ceph/ceph/pull/18039/files)


try:
r = global_instance().fs_status(fs_id)
except TypeError:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above re. TypeError


try:
r = self._clients(fs_id)
except TypeError:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should update _clients to handle the RemoteViewCache.VALUE_NONE status instead so that we don't have to handle TypeError here (where the comment "TODO do something sensible with status" is in _clients)

@@ -779,7 +813,7 @@ def _get_mds_names(self, filesystem_id=None):

@cherrypy.expose
@cherrypy.tools.json_out()
def mds_counters(self, fs_id):
def mds_counters(self, mds_id):
Copy link
Contributor

Choose a reason for hiding this comment

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

This really is a filesystem ID rather than an MDS ID (see below where it is getting the list of MDSs in the filesystem)

@@ -895,7 +934,8 @@ def _osd(self, osd_id):
}),
"")
r, outb, outs = result.wait()
assert r == 0
if r != 0:
return None
Copy link
Contributor

Choose a reason for hiding this comment

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

Would make more sense to set histogram to None here rather than returning None. While removing assertion, should also add a global_instance().log.error so that we're not just dropping the error on the floor.

@@ -914,13 +954,24 @@ def perf(self, osd_id):
ceph_version=global_instance().version,
path_info='/osd' + cherrypy.request.path_info,
toplevel_data=json.dumps(toplevel_data, indent=2),
content_data=json.dumps(self._osd(osd_id), indent=2)
content_data=json.dumps(self.perf_data(osd_id), indent=2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually work? perf_data is returning a completely different type (a cherrypy response) than _osd (a dict).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works, yes. Do you want me to change it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, turns out that the cherrypy context managers work differently than I thought, and they don't actually change the type of the return value. Never mind!

"Invalid OSD id {0}".format(osd_id))

r = self._osd(osd_id)
if r is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

it's okay to push the HTTPError etc exceptions down into functions like _osd -- it's more pythonic than returning Nones to indicate something missing

This commit replaces assertions and uncaught exceptions with appropriate http error codes.

Signed-off-by: Nick Erdmann <n@nirf.de>
@jcsp jcsp merged commit 15e8b19 into ceph:master Oct 26, 2017
@nrdmn nrdmn deleted the dashboard branch January 30, 2018 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants