From ad89825065278c5d3c3d86bed008dfebffb94058 Mon Sep 17 00:00:00 2001 From: m1093782566 Date: Thu, 20 Oct 2016 14:17:52 +0800 Subject: [PATCH] build util function for write sys file Change-Id: I8f122b4314c1d983e7ba1ce1d66ce876bef0dca9 --- cmd/kube-proxy/app/conntrack.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/kube-proxy/app/conntrack.go b/cmd/kube-proxy/app/conntrack.go index cbd0f6297b0..fabec9e62c4 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) +}