mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
optimise the getConntrackMax function
Signed-off-by: PingWang <wang.ping5@zte.com.cn>
This commit is contained in:
parent
89651077b1
commit
ee567e1ea0
@ -335,12 +335,13 @@ func (s *ProxyServer) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getConntrackMax(config *options.ProxyServerConfig) (int, error) {
|
func getConntrackMax(config *options.ProxyServerConfig) (int, error) {
|
||||||
if config.ConntrackMax > 0 && config.ConntrackMaxPerCore > 0 {
|
|
||||||
return -1, fmt.Errorf("invalid config: ConntrackMax and ConntrackMaxPerCore are mutually exclusive")
|
|
||||||
}
|
|
||||||
if config.ConntrackMax > 0 {
|
if config.ConntrackMax > 0 {
|
||||||
|
if config.ConntrackMaxPerCore > 0 {
|
||||||
|
return -1, fmt.Errorf("invalid config: ConntrackMax and ConntrackMaxPerCore are mutually exclusive")
|
||||||
|
}
|
||||||
return int(config.ConntrackMax), nil
|
return int(config.ConntrackMax), nil
|
||||||
} else if config.ConntrackMaxPerCore > 0 {
|
}
|
||||||
|
if config.ConntrackMaxPerCore > 0 {
|
||||||
return (int(config.ConntrackMaxPerCore) * runtime.NumCPU()), nil
|
return (int(config.ConntrackMaxPerCore) * runtime.NumCPU()), nil
|
||||||
}
|
}
|
||||||
return 0, nil
|
return 0, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user