From 4fb073e799bbddad078c7bcb36de92f2f6417d7b Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Mon, 1 Mar 2021 04:12:25 -0800 Subject: [PATCH] Log clearer error on startup if NPC cannot be started Servers should always be upgraded before agents, but generally this isn't required because things are compatible between versions. In this case we're OK with failing closed if the user upgrades out of order, but we should give a clearer message about what steps are required to fix the issue. Signed-off-by: Brad Davidson --- pkg/agent/config/config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/agent/config/config.go b/pkg/agent/config/config.go index b8d59c1f53..cd653a1859 100644 --- a/pkg/agent/config/config.go +++ b/pkg/agent/config/config.go @@ -498,6 +498,13 @@ func get(envInfo *cmds.Agent, proxy proxy.Proxy) (*config.Node, error) { nodeConfig.AgentConfig.ServiceNodePortRange = *controlConfig.ServiceNodePortRange } + // Old versions of the server do not send enough information to correctly start the NPC. Users + // need to upgrade the server to at least the same version as the agent, or disable the NPC + // cluster-wide. + if controlConfig.DisableNPC == false && (controlConfig.ServiceIPRange == nil || controlConfig.ServiceNodePortRange == nil) { + return nil, fmt.Errorf("incompatible down-level server detected; servers must be upgraded to at least %s, or restarted with --disable-network-policy", version.Version) + } + nodeConfig.AgentConfig.ExtraKubeletArgs = envInfo.ExtraKubeletArgs nodeConfig.AgentConfig.ExtraKubeProxyArgs = envInfo.ExtraKubeProxyArgs