Repository navigation
Handle commands that return 'inf' as a float value - #54
Merged
Merged
Conversation
For now, this appears to be limited to read balancer fields, which show up in OSD dumps and pool details.
alram-do
approved these changes
Dec 17, 2024
phoerious
reviewed
Dec 18, 2024
Comment on lines
+761
to
+763
| // Some Ceph commands can return "inf" as a float value; this is not allowed by | ||
| // the json spec or the golang parser (though it is apparently allowed by the | ||
| // Python parser), so we convert such cases to "null". |
There was a problem hiding this comment.
Just FYI: I used Python for validating the Ceph JSON output to find out why pgremapper was throwing errors. It did what I expected it to so, so it's definitely not allowed.
Apparently, what Python does is replace inf with JavaScript's Infinity (same for NaN):
>>> json.dumps({'x': float('inf')})
'{"x": Infinity}'
>>> json.loads(json.dumps({'x': float('inf')}))
{'x': inf}
Contributor
Author
There was a problem hiding this comment.
Ah, interesting. I had done some digging when I wrote this for ceph_exporter and thought I had found references to Python accepting this, but I'd have to go digging for those references again. Perhaps I had also assumed that the mgr handled this OK without custom code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For now, this appears to be limited to read balancer fields, which show up in OSD dumps and pool details.
(this is a port of digitalocean/ceph_exporter#252 to pgremapper)