From 6fedcb02064a817a4d60bfe1938146670b4f1e6d Mon Sep 17 00:00:00 2001 From: Guangya Liu Date: Fri, 9 Feb 2018 00:16:24 +0800 Subject: [PATCH] Get file max from fs/file-max. --- internal/ingress/controller/util.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/ingress/controller/util.go b/internal/ingress/controller/util.go index 2c13764af3..38805e1ea6 100644 --- a/internal/ingress/controller/util.go +++ b/internal/ingress/controller/util.go @@ -17,8 +17,6 @@ limitations under the License. package controller import ( - "syscall" - "github.com/golang/glog" api "k8s.io/api/core/v1" @@ -57,12 +55,12 @@ func sysctlSomaxconn() int { // sysctlFSFileMax returns the value of fs.file-max, i.e. // maximum number of open file descriptors func sysctlFSFileMax() int { - var rLimit syscall.Rlimit - err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit) + fileMax, err := sysctl.New().GetSysctl("fs/file-max") if err != nil { - glog.Errorf("unexpected error reading system maximum number of open file descriptors (RLIMIT_NOFILE): %v", err) + glog.Errorf("unexpected error reading system maximum number of open file descriptors (fs.file-max): %v", err) // returning 0 means don't render the value return 0 } - return int(rLimit.Max) + glog.V(3).Infof("system fs.file-max=%v", fileMax) + return fileMax }