Skip to content

mgr/devicehealth: fix _get_device_metrics ValueError#41946

Merged
tchaikov merged 1 commit intoceph:masterfrom
liewegas:fix-51294
Jun 26, 2021
Merged

mgr/devicehealth: fix _get_device_metrics ValueError#41946
tchaikov merged 1 commit intoceph:masterfrom
liewegas:fix-51294

Conversation

@liewegas
Copy link
Member

This appears to have broken with abd35d4

Fixes: https://tracker.ceph.com/issues/51294
Signed-off-by: Sage Weil sage@newdream.net

isample = None
imin_sample = None
try:
if sample:
Copy link
Member

Choose a reason for hiding this comment

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

The issue here seems to be that sample is ''. I would say that's not a valid input and the diskprediction module should be fixed:

r, outb, outs = self.remote(
'devicehealth', 'show_device_metrics', devid=devid, sample='')

Or we could change _t2epoch to accept the empty string and return 0.

@liewegas
Copy link
Member Author

retest this please

This appears to have broken with abd35d4

The SQL OR doesn't work because in the case that sample is passed,
_t2epoch(min_sample) is 0 and the 0 <= time portion of the expression
is always true.

Fixes: https://tracker.ceph.com/issues/51294
Signed-off-by: Sage Weil <sage@newdream.net>

def _t2epoch(self, t: Optional[str]) -> int:
if t is None:
if not t:
Copy link
Member

Choose a reason for hiding this comment

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

With this change I don't think the SQL changes are necesary, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think they are, or else you end up with (time = ? OR ? <= time) -> (time = 123 OR 0 <= time) which is everything instead of just 123.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I don't know how this worked in my testing when I made this change. Anyway, that makes sense to me.


def _t2epoch(self, t: Optional[str]) -> int:
if t is None:
if not t:
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I don't know how this worked in my testing when I made this change. Anyway, that makes sense to me.

@tchaikov
Copy link
Contributor

@tchaikov tchaikov merged commit 07143c4 into ceph:master Jun 26, 2021
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.

3 participants