containerd / nri

Node Resource Interface
Apache License 2.0
220 stars 58 forks source link

Fix "argument list too long" error. #1

Closed mxpv closed 3 years ago

mxpv commented 3 years ago

When running from a service, each client.New call will append one more entry to PATH. Indirectly this affects fork/exec calls (the error message is a bit misleading, ideally it should be something like "argument list and environment are too long").

The problem can be reproduced with the following test:

func TestNewClient(t *testing.T) {
    for i := 0; i < 11000; i++ {
        _, err := New();
        if err != nil {
            t.Fatal(err)
        }

        _, err = exec.Command("true").CombinedOutput()
        if err != nil {
            t.Fatal(err)
        }
    }
}

--- FAIL: TestNewClient (7.84s)
    client_test.go:17: fork/exec /usr/bin/true: argument list too long
FAIL
exit status 1

In cri-containerd I observed this error after launching ~50 pods

Signed-off-by: Maksym Pavlenko pavlenko.maksym@gmail.com

crosbymichael commented 3 years ago

LGTM