Skip to content

Commit

Permalink
Merge pull request #700 from stgraber/cgroup
Browse files Browse the repository at this point in the history
incusd/instance/lxc: Don't set a soft limit when no hard limit
  • Loading branch information
hallyn authored Mar 29, 2024
2 parents ec8d61a + 6e46410 commit 18a13cd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions internal/server/instance/drivers/driver_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4618,7 +4618,7 @@ func (d *lxc) Update(args db.InstanceArgs, userRequested bool) error {

// Set the new values
if memoryEnforce == "soft" {
// Set new limit
// Set new limit.
err = cg.SetMemorySoftLimit(memoryInt)
if err != nil {
revertMemory()
Expand Down Expand Up @@ -4654,11 +4654,13 @@ func (d *lxc) Update(args db.InstanceArgs, userRequested bool) error {
}
}

// Set soft limit to value 10% less than hard limit
err = cg.SetMemorySoftLimit(int64(float64(memoryInt) * 0.9))
if err != nil {
revertMemory()
return err
// Set soft limit to value 10% less than hard limit.
if memoryInt > 0 {
err = cg.SetMemorySoftLimit(int64(float64(memoryInt) * 0.9))
if err != nil {
revertMemory()
return err
}
}
}

Expand Down

0 comments on commit 18a13cd

Please sign in to comment.