From ee567e1ea087faa91c0b5f5485fcc9c17e2d4081 Mon Sep 17 00:00:00 2001 From: PingWang Date: Thu, 28 Jul 2016 19:17:52 +0800 Subject: [PATCH] optimise the getConntrackMax function Signed-off-by: PingWang --- cmd/kube-proxy/app/server.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 609cc26cb39..353240ac70f 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -335,12 +335,13 @@ func (s *ProxyServer) Run() 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.ConntrackMaxPerCore > 0 { + return -1, fmt.Errorf("invalid config: ConntrackMax and ConntrackMaxPerCore are mutually exclusive") + } return int(config.ConntrackMax), nil - } else if config.ConntrackMaxPerCore > 0 { + } + if config.ConntrackMaxPerCore > 0 { return (int(config.ConntrackMaxPerCore) * runtime.NumCPU()), nil } return 0, nil