"available" resources on VmHost/Pod in API, broken?

I’m writing a simple placement algorithm to compose LXD VMs onto an appropriate VmHost and in doing so I’ve noticed that the information the the “available” key from the pod info, GET /MAAS/api/2.0/pods/{id} for cores, memory doesn’t align with what the UI is showing, nor does it appear to account for over commit.

Observations:

  1. total = used + available looks good. But what happens with over-commit? available goes negative?!
  2. In looking into why the UI is showing something different, I see that the UI uses a different field for allocated memory from the websocket getpod which isn’t present in the REST API (“resources” key). However the values here also require client side “fudging” to match those displayed in the GUI.

Is there a plan to “fix” these statistics as they’re important if you’re writing your own placement logic?

@smallsam, i’m not sure, but this sounds like a bug. could you file one please?

@smallsam, did you ever file a bug on this?