Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysctlFSFileMax not using fs.file-max #2048

Closed
gyliu513 opened this issue Feb 8, 2018 · 6 comments
Closed

sysctlFSFileMax not using fs.file-max #2048

gyliu513 opened this issue Feb 8, 2018 · 6 comments

Comments

@gyliu513
Copy link
Contributor

gyliu513 commented Feb 8, 2018

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see https://kubernetes.io/docs/tasks/debug-application-cluster/troubleshooting/.):

What keywords did you search in NGINX Ingress controller issues before filing this one? (If you have found any duplicates, you should instead reply there.):


Is this a BUG REPORT or FEATURE REQUEST? (choose one):

NGINX Ingress controller version:

I was using ingress 0.9.0.

I updated the initContainer in ingress controller by adding sysctl -w fs.file-max=1608170 as following:

  initContainers:
      - command:
        - sh
        - -c
        - sysctl -w fs.file-max=1608170; sysctl -w net.core.somaxconn=32768; sysctl
          -w net.ipv4.ip_local_port_range="1024 65535"

And restart the ingress controller, but in the log, I found that the file max was still 65536.

[root@gyliu-icp-1 ~]# cat ingress2.log | grep "maximum number of open file descriptors"
I0208 06:01:29.819389       7 nginx.go:557] maximum number of open file descriptors : 65536

Related source code here https://github.com/kubernetes/ingress-nginx/blob/nginx-0.9.0/internal/ingress/controller/nginx.go#L559:60

/cc @aledbf any comments for this? Thanks!

Kubernetes version (use kubectl version):

Environment:

  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:

What happened:

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know:

@gyliu513
Copy link
Contributor Author

gyliu513 commented Feb 8, 2018

I found that we are now using following logic to get maximum number of open file descriptors, is it possible to update it via sysctl command?

func sysctlFSFileMax() int {
	var rLimit syscall.Rlimit
	err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
	if err != nil {
		glog.Errorf("unexpected error reading system maximum number of open file descriptors (RLIMIT_NOFILE): %v", err)
		// returning 0 means don't render the value
		return 0
	}
	return int(rLimit.Max)
}

@gyliu513 gyliu513 changed the title sysctl -w fs.file-max=90000 does not take effect for initContainer sysctlFSFileMax not using fs.file-max Feb 8, 2018
@aledbf
Copy link
Member

aledbf commented Feb 8, 2018

I found that we are now using following logic to get maximum number of open file descriptors, is it possible to update it via sysctl command?

What do you mean? We read the value using the RLIMIT_NOFILE syscall (same thing than using sysctl)

@gyliu513
Copy link
Contributor Author

gyliu513 commented Feb 8, 2018

After talk with @aledbf , this PR ec67f83 made the update, will try to use original logic to see if it works.

@luckyfengyong
Copy link

@gyliu513 Do you run initContainer with privileged? fs.file-max is the OS level configuration. You could check in the host or inside ingress controller container, whether the configuration of fs.file-max takes effect.

@gyliu513
Copy link
Contributor Author

gyliu513 commented Feb 8, 2018

I did some test with revert ec67f83 , ingress works fine and can get fs.file-max.

For my case, I set the fs.file-max=90000, and ingress controller can get this value well I0208 16:04:53.698915 7 nginx.go:559] maximum number of open file descriptors : 90000

Will create a PR to revert ec67f83 @aledbf

@aledbf
Copy link
Member

aledbf commented Feb 8, 2018

Closing. Fixed in #2050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants