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: Refactor multiple duplicates of get_rate() #21022

Merged
merged 2 commits into from Apr 11, 2018

Conversation

sebastian-philipp
Copy link
Contributor

@sebastian-philipp sebastian-philipp commented Mar 23, 2018

... And get_latest().

I've removed all duplicates of get_rate with the exception of the iSCSI controller and moved it to CephService.
Also, I've moved get_latest() to MgrModule, as it is already used there. And there are two other mgr modules make use of get_latest.

Also affected by #21021

EDIT:

Signed-off-by: Sebastian Wagner sebastian.wagner@suse.com

o['stats'][prop] = self.get_rate(osd_spec, s)
o['stats_history'][prop] = self.get_counter(osd_spec, s)
o['stats'][prop] = CephService.get_rate('osd', osd_spec, s)
o['stats_history'][prop] = mgr.get_counter('osd', osd_spec, s)
Copy link

Choose a reason for hiding this comment

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

It needs to be o['stats_history'][prop] = mgr.get_counter('osd', osd_spec, s)[s] with [s] at the end to get the same return as from the local method before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right. looks like we need a teuthology test for that, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. Also added a new API test

@@ -12,6 +12,8 @@
@AuthRequired()
class TcmuIscsi(RESTController):
def _get_rate(self, daemon_type, daemon_name, stat):
# Also see ..services.ceph_service.CephService#get_rate
Copy link
Contributor

Choose a reason for hiding this comment

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

is this comment relevant for the implementation of this function? if not I would remove it.

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 function and .services.ceph_service.CephService#get_rate are very similar and share a common history. In contrast to .services.ceph_service.CephService#get_rate, this function calculates the differentiation for all inputs, instead of just the last one. In the long term, we should IMO aim for unifying both functions. E.g. using this get_rate also in other places.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, in that case I would remove the comment, and open an issue in tracker.ceph.com to keep track of that enhancement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this comment, the relationship between both get_rates is also clear in the git history. Why do you think this comment is harmful?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's harmful, (it's just a comment), but usually comments explain or alert to some part of the code that is unclear, while this comment feels more like a "TODO" item, that should be tracked in the tracker rather than in the code.

Choose a reason for hiding this comment

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

Note that I had changed this function after I noticed “get_rate” is broken throughout the dashboard [1]

[1] https://tracker.ceph.com/issues/23389

@rjfd
Copy link
Contributor

rjfd commented Mar 28, 2018

... And  `get_latest()`.

* OSD Controller: `.stats_history` now returns the
  derivative.

  Fixes https://tracker.ceph.com/issues/23389

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Refactored `OsdTest` to make use of `self.assertSchema()`

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
@rjfd
Copy link
Contributor

rjfd commented Apr 11, 2018

@rjfd rjfd removed the needs-qa label Apr 11, 2018
@LenzGr LenzGr merged commit 34232b3 into ceph:master Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants