Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incusd/instance/lxc: Don't set a soft limit when no hard limit #700

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading