rados: Handle commands that return 'inf' as a float value
For now, this appears to be limited to read balancer fields, which show up in OSD dumps and pool details.
This commit is contained in:
parent
f87851df15
commit
0808753eb9
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue