-
Notifications
You must be signed in to change notification settings - Fork 481
Skip writing somaxconn when running in containers
#939
Conversation
|
Hey alexjh! Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you've already signed the CLA. |
|
We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/116251345. |
|
@alexjh How does adding the property Thank you |
|
It should be wrapped in an if_p macro, and we would set it to null in our
|
|
Hi @shalako, in the change I'm proposing, the writing would be skipped because of the In a situation where you don't want to write to this |
|
Hello @alexjh You're running gorouter in Docker containers, and This file governs max inbound connections? What happens when this file doesn't exist, or we don't overwrite it? Are max connections then unlimited (65535) or is there a kernel default? http://linux.die.net/man/2/listen suggests the default is 128. Is this acceptable when deployed in Docker? Thank you |
|
Thanks for reviewing!
Correct.
Yes.
Yes, the kernel default is 128 and this will be acceptable in Docker. |
|
You would like to accomplish three use cases:
We don't believe depending on NULL for 2 is a viable option. If the operator provides NULL, then the job spec default (1024) will be used. Your condition "if max_connections is present" will always be true. Have you tested this works? How about choose another value, like I also considered suggesting a different property that addresses your problem more directly, e.g. |
Ah, sorry, I misspoke earlier, the config setting would be set to |
|
If the property were |
|
Ok, sounds good. I'll push and update the PR when I'm done testing. |
|
@alexjh thank you! Could you also please:
Thank you |
@shalako Can you elaborate on that? So far I've been testing via |
To support this, I believe you have to update this section: https://github.com/cloudfoundry/cf-release/blob/release-candidate/templates/cf.yml#L975. But I'll have someone from the team provide details. |
|
@shalako got it spot on really, you probably will need to update the |
|
@alexjh My team alerted me to issues with making this configurable. After the initial setting, a change would be ignored until the VM is restarted. As a restart only happens on a stemcell update, this will lead to unexpected behavior (your changes are not applied). In speaking with @ematpl (PM for Diego), it seems they've already been through similar changes with you. Their solution was not to write to the proc when running in a container. There are are already dynamic mechanisms to determine this in gorouter: https://github.com/cloudfoundry/cf-release/blob/master/jobs/gorouter/templates/gorouter_ctl.erb#L20-L47 Your goal is to prevent writing this proc when in a container. You've said you'd be fine with the kernel default when running in a container. I have no product requirements to make max_connections configurable at this time, and it appears that this isn't actually as configurable as we thought. I apologize for the back and forth, and appreciate your willingness to enhance your PR so far. We would like to change it one more time. We prefer not to make this configurable at all. Instead, we'd like to move the logic for writing the hardcoded 1024 into the existing conditional logic that detects we're not running in a container. If running in a container, you get the kernel default (128?), otherwise you get 1024. As you've already changed this several times at our request, we are willing to make this change for you. If instead you're willing to modify your PR again, we would certainly welcome the change. Please let us know your preference. Thank you |
|
@shalako No problem with the back-and-forth. I wasn't clear at the start that this only happens in a Docker container, not the bosh-lite containers (garden?). I didn't move it into the running_in_container() function because that would change the behaviour for the existing bosh-lite containers. How about a new function that checks if /proc/sys is mounted RO? diff --git jobs/gorouter/templates/gorouter_ctl.erb jobs/gorouter/templates/gorouter_ctl.erb
index a18e36a..04907b2 100644
--- jobs/gorouter/templates/gorouter_ctl.erb
+++ jobs/gorouter/templates/gorouter_ctl.erb
@@ -46,8 +46,10 @@ case $1 in
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
fi
- # Allow a few more queued connections than are allowed by default
- echo 1024 > /proc/sys/net/core/somaxconn
+ if is_proc_sys_writeable; then
+ # Allow a few more queued connections than are allowed by default
+ echo 1024 > /proc/sys/net/core/somaxconn
+ fi
# Allowed number of open file descriptors
ulimit -n 100000
diff --git src/common/utils.sh src/common/utils.sh
index 615e668..1d1adeb 100644
--- src/common/utils.sh
+++ src/common/utils.sh
@@ -86,3 +86,7 @@ kill_and_wait() {
running_in_container() {
grep -q -E '/instance|/docker/' /proc/self/cgroup
}
+
+is_proc_sys_writeable() {
+ ! { awk '$4 ~ "^ro[,$]" {print $2}' /proc/mounts | grep -q "/proc/sys"; }
+} |
|
Seems reasonable, I'll move the story into our backlog for the engineering team to review. |
|
Ok, great, I pushed the changes to add |
|
@alexjh I think it would make more sense to move the setting of My understanding is that if |
This file isn't writeable inside a Docker container, and this setting isn't needed when running in bosh-lite because it's not a production environment.
somaxconn when running in containers
|
@crhino Ok, sounds good. Just pushed the new version. |
/proc/sys/net/core/somaxconnisn't writeable in some container configurations, add a config value so it can be disabled.Modify running_in_containers() so it detects Docker containers.
See cloudfoundry/diego-release#146 for more details about the format of
/proc/self/cgroup