mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #34385 from m1093782566/m109-kube-proxy-sys
Automatic merge from submit-queue Generify kube-proxy conntracker setmax() and refactor util/sysctl <!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md 2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md 3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes --> **What this PR does / why we need it**: Fix Kube-proxy `conntrack.go` **TODO** [here](https://github.com/kubernetes/kubernetes/blob/master/cmd/kube-proxy/app/conntrack.go#L56). This PR consists of two parts: * Generify kube-proxy `realConntracker.SetMax(int)` That is, change `ioutil.WriteFile("/sys/module/nf_conntrack/parameters/hashsize", []byte(strconv.Itoa(max/4)), 0640)` to `sysctl.New().WriteValue("/sys/module/nf_conntrack/parameters/hashsize", max/4)` * Refactor `sysctl.SetSysctl()` and `sysctl.GetSysctl()` to `WriteValue(path string, value string) error` and `GetValue(path value) (error, string)`
This commit is contained in:
commit
c07c73efbb
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user