Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b397e166
Commit
b397e166
authored
Apr 25, 2017
by
Robert Günzler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip resize of nf_conntrack/parameters/hashsize if not necessary
parent
d46983f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
conntrack.go
cmd/kube-proxy/app/conntrack.go
+25
-0
No files found.
cmd/kube-proxy/app/conntrack.go
View file @
b397e166
...
...
@@ -20,6 +20,7 @@ import (
"errors"
"io/ioutil"
"strconv"
"strings"
"github.com/golang/glog"
...
...
@@ -48,6 +49,22 @@ func (rct realConntracker) SetMax(max int) error {
if
err
:=
rct
.
setIntSysCtl
(
"nf_conntrack_max"
,
max
);
err
!=
nil
{
return
err
}
glog
.
Infof
(
"Setting nf_conntrack_max to %d"
,
max
)
// Linux does not support writing to /sys/module/nf_conntrack/parameters/hashsize
// when the writer process is not in the initial network namespace
// (https://github.com/torvalds/linux/blob/v4.10/net/netfilter/nf_conntrack_core.c#L1795-L1796).
// Usually that's fine. But in some configurations such as with github.com/kinvolk/kubeadm-nspawn,
// kube-proxy is in another netns.
// Therefore, check if writing in hashsize is necessary and skip the writing if not.
hashsize
,
err
:=
readIntStringFile
(
"/sys/module/nf_conntrack/parameters/hashsize"
)
if
err
!=
nil
{
return
err
}
if
hashsize
>=
(
max
/
4
)
{
return
nil
}
// sysfs is expected to be mounted as 'rw'. However, it may be
// unexpectedly mounted as 'ro' by docker because of a known docker
// issue (https://github.com/docker/docker/issues/24000). Setting
...
...
@@ -112,6 +129,14 @@ func isSysFSWritable() (bool, error) {
return
false
,
errors
.
New
(
"No sysfs mounted"
)
}
func
readIntStringFile
(
filename
string
)
(
int
,
error
)
{
b
,
err
:=
ioutil
.
ReadFile
(
filename
)
if
err
!=
nil
{
return
-
1
,
err
}
return
strconv
.
Atoi
(
strings
.
TrimSpace
(
string
(
b
)))
}
func
writeIntStringFile
(
filename
string
,
value
int
)
error
{
return
ioutil
.
WriteFile
(
filename
,
[]
byte
(
strconv
.
Itoa
(
value
)),
0640
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment