diff --git a/rados/rados.go b/rados/rados.go index b75b937..29db732 100644 --- a/rados/rados.go +++ b/rados/rados.go @@ -120,6 +120,9 @@ func (c *RadosConn) MonCommand(args []byte) (buffer []byte, info string, err err ll.Trace("start executing mon command") buffer, info, err = c.conn.MonCommand(args) + if err == nil { + buffer = handleCephInf(buffer) + } 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") buffer, info, err = c.conn.MgrCommand(args) + if err == nil { + buffer = handleCephInf(buffer) + } ll.WithError(err).Trace("complete executing mgr command") @@ -163,3 +169,13 @@ func (c *RadosConn) GetPoolStats(pool string) (*ceph.PoolStat, error) { 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 +}