Fix MaxCPU and MaxMemory semantics

If a limit of 0 (or negative) is given for both cpu and memory, then
no limiting will be triggered. If any value between 1 and 100 (inclusive)
is given, then limiting will be triggered when that limit is reached.

I.e. giving a limit of 100 doesn't not mean unlimited.
This commit is contained in:
Ingo Oppermann
2023-07-12 11:53:39 +02:00
parent 519f39b217
commit 51d8b30e8f
2 changed files with 42 additions and 25 deletions

View File

@@ -177,6 +177,16 @@ func TestHasLimits(t *testing.T) {
require.True(t, r.HasLimits())
r, err = New(Config{
MaxCPU: 100,
MaxMemory: 100,
PSUtil: &util{},
Logger: nil,
})
require.NoError(t, err)
require.True(t, r.HasLimits())
r, err = New(Config{
MaxCPU: 0,
MaxMemory: 0,