d2iq-archive/marathon-lb

How to pass sysctl param containing a space

Closed this issue · 2 comments

I'd like to set a sysctl param containing space using HAPROXY_SYSCTL_PARAMS, eg:

sysctl -w net.ipv4.ip_local_port_range="1000 65535"

But I cannot achieve this, no matter how I escape the environment variable, it ends with an error at startup like:

[/marathon-lb /marathon-lb/run] setting sysctl params to: net.ipv4.ip_local_port_range="1000 65535" fs.file-max=10000000 fs.nr_open=10000000 net.ipv4.tcp_tw_reuse=1 net.ipv4.tcp_fin_timeout=30 net.ipv4.tcp_max_syn_backlog=10240 net.ipv4.tcp_max_tw_buckets=400000 net.ipv4.tcp_max_orphans=60000 net.core.somaxconn=65535 net.core.netdev_max_backlog=65536
net.ipv4.ip_local_port_range = \"1000
sysctl: setting key "net.ipv4.ip_local_port_range": Invalid argument
sysctl: "65535\"" must be of the form name=value

It seems that the quote are badly escaped at runtime, already tried the following:

net.ipv4.ip_local_port_range=1000 65535
net.ipv4.ip_local_port_range="1000 65535"
net.ipv4.ip_local_port_range=\"1000 65535\"
net.ipv4.ip_local_port_range=\\\"1000 65535\\\"

Is it possible to pass such parameters through environment variable or should I customize the docker image to execute this script at startup?

Many thanks in advance.

The best way at the moment is to customize the image. The issue is that the env var is passed as a whole to sysctl in the run script, ideally it would write out a conf file and then use that to get around the bash mangling.

Thanks!