Incorrect memory constraints on LXD cluster

Bug #1905827 reported by Stéphane Graber on 2020-11-27
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Joseph Phillips

Bug Description

When deploying with:

  juju deploy ubuntu --constraints "mem=4G cores=2"

The container shows:
  limits.cpu: "2"
  limits.memory: 4096MB

Looking at the documentation, it says that memory contraints are in MiB, so I would have expected this to end up as 4096MiB or 4GiB instead which would then resolve to the right amount of RAM being allocated to the container.

I see logic in Juju which attempts some kind of server version check to select whether the suffix will work or not but it looks like this isn't working since I'm getting the wrong result with LXD 4.8 and Juju 2.8.

»···»···// Ensure that we use the correct "MB"/"MiB" suffix.
»···»···template := "%dMB"
»···»···if current, err := version.Parse(serverVersion); err == nil {
»···»···»···if current.Compare(minMiBVersion) >= 0 {
»···»···»···»···template = "%dMiB"
»···»···c.Config["limits.memory"] = fmt.Sprintf(template, *cons.Mem)

I also did a bit of archeology and this syntax has been supported since LXD 3.0.2.
So technically, LXD 2.0.x which is still supported as our oldest LTS release is indeed missing support for this, anything else which is currently supported however does have it.

Stéphane Graber (stgraber) wrote :

Added a bit of debugging, so far I'm getting:

machine-0: 14:06:58 ERROR juju.container.lxd stgraber: version=4.8
machine-0: 14:06:58 ERROR juju.container.lxd stgraber: error=Invalid version format: ""

Stéphane Graber (stgraber) wrote :

I suspect it's a bug in our shared/version handler which we fixed some months ago, trying a refresh of the LXD Go package now.

Stéphane Graber (stgraber) wrote :

Yep, that did it:

stgraber@castiana:~/data/code/go/src/ (develop)$ lxc config show juju-cluster:juju-a25a73-7 | grep limits
  limits.cpu: "2"
  limits.memory: 4096MiB

Ian Booth (wallyworld) wrote :

The dependency we currently pull into juju is v0.0.0-20200306132355-582edb00c72c

which corresponds to the lxd-3.2.2 tag.

We should update that, but I'm confused why things are broken. in comment #2, are you saying you refreshed and rebuilt juju and it worked?

Stéphane Graber (stgraber) wrote :

See, the first commit fixes the issue.

Changed in juju:
status: New → Confirmed
importance: Undecided → High
milestone: none → 2.8.7
Changed in juju:
status: Confirmed → In Progress
assignee: nobody → Joseph Phillips (manadart)
milestone: 2.8.7 → 2.9-rc3
Joseph Phillips (manadart) wrote :
Changed in juju:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers