Merge pull request #252 from digitalocean/fix-reef-inf

rados: Handle commands that return 'inf' as a float value
This commit is contained in:
jbaergen-do 2024-09-23 11:42:51 -06:00 committed by GitHub
commit e586c59fc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 0 deletions

View File

@ -120,6 +120,9 @@ func (c *RadosConn) MonCommand(args []byte) (buffer []byte, info string, err err
ll.Trace("start executing mon command") ll.Trace("start executing mon command")
buffer, info, err = c.conn.MonCommand(args) buffer, info, err = c.conn.MonCommand(args)
if err == nil {
buffer = handleCephInf(buffer)
}
ll.WithError(err).Trace("complete executing mon command") ll.WithError(err).Trace("complete executing mon command")
@ -132,6 +135,9 @@ func (c *RadosConn) MgrCommand(args [][]byte) (buffer []byte, info string, err e
ll.Trace("start executing mgr command") ll.Trace("start executing mgr command")
buffer, info, err = c.conn.MgrCommand(args) buffer, info, err = c.conn.MgrCommand(args)
if err == nil {
buffer = handleCephInf(buffer)
}
ll.WithError(err).Trace("complete executing mgr command") ll.WithError(err).Trace("complete executing mgr command")
@ -163,3 +169,13 @@ func (c *RadosConn) GetPoolStats(pool string) (*ceph.PoolStat, error) {
return poolSt, nil return poolSt, nil
} }
// 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".
func handleCephInf(buf []byte) []byte {
buf = bytes.ReplaceAll(buf, []byte("\": inf"), []byte("\": null"))
buf = bytes.ReplaceAll(buf, []byte("\":inf"), []byte("\":null"))
return buf
}