mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Be more agressive acquiring the iptables lock
iptables has two options to modify the behaviour trying to
acquire the lock.
--wait -w [seconds] maximum wait to acquire xtables lock
before give up
--wait-interval -W [usecs] wait time to try to acquire xtables
lock
interval to wait for xtables lock
default is 1 second
Kubernetes uses -w 5 that means that wait 5 seconds to try to
acquire the lock. If we are not able to acquire it, kube-proxy
fails and retries in 30 seconds, that is an important penalty
on sensitive applications.
We can be a bit more aggresive and try to acquire the lock every
100 msec, that means that we have to fail 50 times to not being
able to succeed.
This commit is contained in:
@@ -163,6 +163,9 @@ var RandomFullyMinVersion = utilversion.MustParseGeneric("1.6.2")
|
||||
// WaitMinVersion a minimum iptables versions supporting the -w and -w<seconds> flags
|
||||
var WaitMinVersion = utilversion.MustParseGeneric("1.4.20")
|
||||
|
||||
// WaitIntervalMinVersion a minimum iptables versions supporting the wait interval useconds
|
||||
var WaitIntervalMinVersion = utilversion.MustParseGeneric("1.6.1")
|
||||
|
||||
// WaitSecondsMinVersion a minimum iptables versions supporting the wait seconds
|
||||
var WaitSecondsMinVersion = utilversion.MustParseGeneric("1.4.22")
|
||||
|
||||
@@ -175,6 +178,12 @@ const WaitString = "-w"
|
||||
// WaitSecondsValue a constant for specifying the default wait seconds
|
||||
const WaitSecondsValue = "5"
|
||||
|
||||
// WaitIntervalString a constant for specifying the wait interval flag
|
||||
const WaitIntervalString = "-W"
|
||||
|
||||
// WaitIntervalUsecondsValue a constant for specifying the default wait interval useconds
|
||||
const WaitIntervalUsecondsValue = "100000"
|
||||
|
||||
// LockfilePath16x is the iptables lock file acquired by any process that's making any change in the iptable rule
|
||||
const LockfilePath16x = "/run/xtables.lock"
|
||||
|
||||
@@ -638,6 +647,8 @@ func getIPTablesVersion(exec utilexec.Interface, protocol Protocol) (*utilversio
|
||||
// Checks if iptables version has a "wait" flag
|
||||
func getIPTablesWaitFlag(version *utilversion.Version) []string {
|
||||
switch {
|
||||
case version.AtLeast(WaitIntervalMinVersion):
|
||||
return []string{WaitString, WaitSecondsValue, WaitIntervalString, WaitIntervalUsecondsValue}
|
||||
case version.AtLeast(WaitSecondsMinVersion):
|
||||
return []string{WaitString, WaitSecondsValue}
|
||||
case version.AtLeast(WaitMinVersion):
|
||||
@@ -650,7 +661,7 @@ func getIPTablesWaitFlag(version *utilversion.Version) []string {
|
||||
// Checks if iptables-restore has a "wait" flag
|
||||
func getIPTablesRestoreWaitFlag(version *utilversion.Version, exec utilexec.Interface, protocol Protocol) []string {
|
||||
if version.AtLeast(WaitRestoreMinVersion) {
|
||||
return []string{WaitString, WaitSecondsValue}
|
||||
return []string{WaitString, WaitSecondsValue, WaitIntervalString, WaitIntervalUsecondsValue}
|
||||
}
|
||||
|
||||
// Older versions may have backported features; if iptables-restore supports
|
||||
|
||||
Reference in New Issue
Block a user