Skip to content

Commit

Permalink
Merge pull request #252 from digitalocean/fix-reef-inf
Browse files Browse the repository at this point in the history
rados: Handle commands that return 'inf' as a float value
  • Loading branch information
jbaergen-do authored Sep 23, 2024
2 parents f87851d + 0808753 commit e586c59
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rados/rados.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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")

Expand Down Expand Up @@ -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
}

0 comments on commit e586c59

Please sign in to comment.