Skip to content

Handle commands that return 'inf' as a float value - #54

Merged
jbaergen-do merged 1 commit into
mainfrom
fix-reef-inf
Dec 17, 2024
Merged

jbaergen-do merged 1 commit into
mainfrom
fix-reef-inf

Conversation

@jbaergen-do

Copy link
Copy Markdown
Contributor

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)

For now, this appears to be limited to read balancer fields, which show
up in OSD dumps and pool details.
@jbaergen-do
jbaergen-do merged commit 41ad448 into main Dec 17, 2024
@jbaergen-do
jbaergen-do deleted the fix-reef-inf branch December 17, 2024 16:48
Comment thread ceph.go
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".

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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}

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.

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants