Skip to content

Commit

Permalink
Merge pull request #3666 from Shopify/change-legacy-func-name
Browse files Browse the repository at this point in the history
rename sysctlFSFileMax to rlimitMaxNumFiles to reflect what it actually does
  • Loading branch information
k8s-ci-robot authored Jan 16, 2019
2 parents f7c42b7 + bdf6e47 commit d968ee9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
if err != nil {
wp = 1
}
maxOpenFiles := (sysctlFSFileMax() / wp) - 1024
maxOpenFiles := (rlimitMaxNumFiles() / wp) - 1024
klog.V(3).Infof("Maximum number of open file descriptors: %d", maxOpenFiles)
if maxOpenFiles < 1024 {
// this means the value of RLIMIT_NOFILE is too low.
Expand Down
5 changes: 2 additions & 3 deletions internal/ingress/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ func sysctlSomaxconn() int {
return maxConns
}

// sysctlFSFileMax returns the maximum number of open file descriptors (value
// of fs.file-max) or 0 in case of error.
func sysctlFSFileMax() int {
// rlimitMaxNumFiles returns hard limit for RLIMIT_NOFILE
func rlimitMaxNumFiles() int {
var rLimit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/ingress/controller/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"testing"
)

func TestSysctlFSFileMax(t *testing.T) {
i := sysctlFSFileMax()
func TestRlimitMaxNumFiles(t *testing.T) {
i := rlimitMaxNumFiles()
if i < 1 {
t.Errorf("returned %v but expected > 0", i)
}
Expand Down

0 comments on commit d968ee9

Please sign in to comment.