From 4936cd476bf31cfa87e4e3e121dc932776496e90 Mon Sep 17 00:00:00 2001 From: Steve Azzopardi Date: Tue, 25 Feb 2020 06:58:28 +0100 Subject: [PATCH] Fix golint issues for `pkg/util/rlimit` pkg/util/rlimit/rlimit_linux.go:25:1: exported function RlimitNumFiles should have comment or be unexported pkg/util/rlimit/rlimit_linux.go:25:6: func name will be used as rlimit.RlimitNumFiles by other packages, and that stutters; consider calling this NumFiles pkg/util/rlimit/rlimit_unsupported.go:25:1: exported function RlimitNumFiles should have comment or be unexported pkg/util/rlimit/rlimit_unsupported.go:25:6: func name will be used as rlimit.RlimitNumFiles by other packages, and that stutters; consider calling this NumFiles Ref: https://github.com/kubernetes/kubernetes/issues/68026 --- cmd/kubelet/app/server.go | 2 +- hack/.golint_failures | 1 - pkg/util/rlimit/rlimit_linux.go | 3 ++- pkg/util/rlimit/rlimit_unsupported.go | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index 648214bbc34..e515500c600 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -1112,7 +1112,7 @@ func RunKubelet(kubeServer *options.KubeletServer, kubeDeps *kubelet.Dependencie } podCfg := kubeDeps.PodConfig - if err := rlimit.RlimitNumFiles(uint64(kubeServer.MaxOpenFiles)); err != nil { + if err := rlimit.SetNumFiles(uint64(kubeServer.MaxOpenFiles)); err != nil { klog.Errorf("Failed to set rlimit on max file handles: %v", err) } diff --git a/hack/.golint_failures b/hack/.golint_failures index 348f055f8d1..ae32b4edafb 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -193,7 +193,6 @@ pkg/util/labels # See previous effort in PR #80685 pkg/util/oom pkg/util/procfs pkg/util/removeall -pkg/util/rlimit pkg/util/selinux pkg/util/taints pkg/volume diff --git a/pkg/util/rlimit/rlimit_linux.go b/pkg/util/rlimit/rlimit_linux.go index 263fced6c4b..ef14f883811 100644 --- a/pkg/util/rlimit/rlimit_linux.go +++ b/pkg/util/rlimit/rlimit_linux.go @@ -22,6 +22,7 @@ import ( "golang.org/x/sys/unix" ) -func RlimitNumFiles(maxOpenFiles uint64) error { +// SetNumFiles sets the linux rlimit for the maximum open files. +func SetNumFiles(maxOpenFiles uint64) error { return unix.Setrlimit(unix.RLIMIT_NOFILE, &unix.Rlimit{Max: maxOpenFiles, Cur: maxOpenFiles}) } diff --git a/pkg/util/rlimit/rlimit_unsupported.go b/pkg/util/rlimit/rlimit_unsupported.go index 25f57be2c31..44011948342 100644 --- a/pkg/util/rlimit/rlimit_unsupported.go +++ b/pkg/util/rlimit/rlimit_unsupported.go @@ -22,6 +22,7 @@ import ( "errors" ) -func RlimitNumFiles(maxOpenFiles uint64) error { +// SetNumFiles sets the rlimit for the maximum open files. +func SetNumFiles(maxOpenFiles uint64) error { return errors.New("SetRLimit unsupported in this platform") }