Skip to content

Commit

Permalink
Merge pull request #6720 from stgraber/master
Browse files Browse the repository at this point in the history
Pre-release bugfixes
  • Loading branch information
Christian Brauner authored Jan 15, 2020
2 parents 0a5afff + 6edc4b2 commit f9adc00
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
13 changes: 0 additions & 13 deletions lxd/cgroup/abstraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,8 @@ func (cg *CGroup) SetMemorySoftLimit(softLim string) error {
case Unavailable:
return ErrControllerMissing
case V1:
if softLim == "-1" {
return cg.rw.Set(version, "memory", "memory.soft_limit_in_bytes", "max")
}
return cg.rw.Set(version, "memory", "memory.soft_limit_in_bytes", softLim)
case V2:
if softLim == "-1" {
return cg.rw.Set(version, "memory", "memory.low", "max")
}
return cg.rw.Set(version, "memory", "memory.low", softLim)
}

Expand Down Expand Up @@ -129,15 +123,8 @@ func (cg *CGroup) SetMemorySwapMax(max string) error {
case Unavailable:
return ErrControllerMissing
case V1:
if max == "-1" {
return cg.rw.Set(version, "memory", "memory.memsw.limit_in_bytes", "max")
}

return cg.rw.Set(version, "memory", "memory.memsw.limit_in_bytes", max)
case V2:
if max == "-1" {
return cg.rw.Set(version, "memory", "memory.swap.max", "max")
}
return cg.rw.Set(version, "memory", "memory.swap.max", max)

}
Expand Down
14 changes: 9 additions & 5 deletions lxd/container_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4112,7 +4112,7 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error {
return errors.Wrap(err, "Initialize LXC")
}

cg, err := c.cgroup(c.c)
cg, err := c.cgroup(nil)
if err != nil {
return err
}
Expand Down Expand Up @@ -4317,11 +4317,13 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error {
return err
}
}

err = cg.SetMemoryMaxUsage("-1")
if err != nil {
revertMemory()
return err
}

err = cg.SetMemorySoftLimit("-1")
if err != nil {
revertMemory()
Expand All @@ -4343,6 +4345,7 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error {
revertMemory()
return err
}

err = cg.SetMemorySwapMax(memory)
if err != nil {
revertMemory()
Expand All @@ -4362,6 +4365,7 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error {
revertMemory()
return err
}

err = cg.SetMemorySoftLimit(fmt.Sprintf("%.0f", float64(valueInt)*0.9))
if err != nil {
revertMemory()
Expand Down Expand Up @@ -5756,7 +5760,7 @@ func (c *containerLXC) cpuState() api.InstanceStateCPU {
cpu := api.InstanceStateCPU{}

// CPU usage in seconds
cg, err := c.cgroup(c.c)
cg, err := c.cgroup(nil)
if err != nil {
return cpu
}
Expand Down Expand Up @@ -5832,7 +5836,7 @@ func (c *containerLXC) diskState() map[string]api.InstanceStateDisk {

func (c *containerLXC) memoryState() api.InstanceStateMemory {
memory := api.InstanceStateMemory{}
cg, err := c.cgroup(c.c)
cg, err := c.cgroup(nil)
if err != nil {
return memory
}
Expand Down Expand Up @@ -5945,7 +5949,7 @@ func (c *containerLXC) processesState() int64 {
return 0
}

cg, err := c.cgroup(c.c)
cg, err := c.cgroup(nil)
if err != nil {
return 0
}
Expand Down Expand Up @@ -6525,7 +6529,7 @@ func (c *containerLXC) removeDiskDevices() error {

// Network I/O limits
func (c *containerLXC) setNetworkPriority() error {
cg, err := c.cgroup(c.c)
cg, err := c.cgroup(nil)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/storage/drivers/driver_btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func (d *btrfs) Mount() (bool, error) {
}

// Custom mount options don't work inside containers
if !d.state.OS.RunningInUserNS {
if d.state.OS.RunningInUserNS {
return true, nil
}

Expand Down

0 comments on commit f9adc00

Please sign in to comment.