Skip to content

Commit 579aaaf

Browse files
committed
Add Verify function to check if Ulimit max value is too big
When parsing the ulimit, we should check if the ulimit max value is greater then the processes max value. If yes then we should return an error. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
1 parent 519db1e commit 579aaaf

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

ulimit_linux_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// +build linux
2+
3+
package units
4+
5+
import (
6+
"testing"
7+
)
8+
9+
func TestParseUlimitTooBig(t *testing.T) {
10+
u, err := ParseUlimit("nofile=512:1000024")
11+
if err != nil {
12+
t.Fatalf("expected valid value got %q", err)
13+
}
14+
if err := u.Verify(); err == nil {
15+
t.Fatalf("expected invalid hard limit")
16+
}
17+
}

ulimit_unsupported.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// +build !linux
2+
3+
package units
4+
5+
// Verify that ulimit values work with current kernel
6+
func (u *Ulimit) Verify() error {
7+
return nil
8+
}

0 commit comments

Comments
 (0)