diff --git a/cmd/kube-proxy/app/conntrack.go b/cmd/kube-proxy/app/conntrack.go index d65adab9580..6865af91349 100644 --- a/cmd/kube-proxy/app/conntrack.go +++ b/cmd/kube-proxy/app/conntrack.go @@ -55,7 +55,7 @@ func (realConntracker) SetMax(max int) error { } // TODO: generify this and sysctl to a new sysfs.WriteInt() glog.Infof("Setting conntrack hashsize to %d", max/4) - return ioutil.WriteFile("/sys/module/nf_conntrack/parameters/hashsize", []byte(strconv.Itoa(max/4)), 0640) + return writeIntStringFile("/sys/module/nf_conntrack/parameters/hashsize", max/4) } func (realConntracker) SetTCPEstablishedTimeout(seconds int) error { @@ -86,3 +86,7 @@ func isSysFSWritable() (bool, error) { } return false, nil } + +func writeIntStringFile(filename string, value int) error { + return ioutil.WriteFile(filename, []byte(strconv.Itoa(value)), 0640) +}