Skip to content

NPM doesn't work with Patched Kubernetes #494

@robbiezhang

Description

@robbiezhang

Is this a request for help?:
Yes

Is this an ISSUE or FEATURE REQUEST? (choose one):
Issue

Which release version?:
1.0.29 or above

Which component (CNI/IPAM/CNM/CNS):
NPM

Which Operating System (Linux/Windows):
Linux

For Linux: Include Distro and kernel version using "uname -a"
Any

For windows: provide output of "$(Get-ItemProperty -Path "C:\windows\system32\hal.dll").VersionInfo.FileVersion"


Which Orchestrator and version (e.g. Kubernetes, Docker)
Kubernetes

What happened:
Bug in parsing the k8s version:

v1, err := semver.NewVersion(firstVer.Major+firstVer.Minor)
if err != nil {
return -2
}
v2, err := semver.NewVersion(secondVer.Major+secondVer.Minor)

In a patched k8s, the version.Info apiserver returns looks like

version.Info{
Major: "1",
Minor: "14+",
GitVersion: "1.14.8-hotfix.20200127",
}

While "14+" is not a valid semver, since it only allows number identifier in the minor. https://semver.org/#spec-item-11
The current code to semver.NewVersion(Major+Minor) will get a semantic error.
https://play.golang.org/p/7j2Dcx5_fpH

Further, Major+Minor comes up with "111" for 1.11, which has potential issue if k8s start to bump up the Major version (111 > 21).


What you expected to happen:
NPM should work with patched kubernetes apiserver.

How to reproduce it (as minimally and precisely as possible):
Build k8s cluster (AKS-Engine)
Replace the apiserver image by mcr.microsoft.com/oss/kubernetes/hyperkube:v1.14.8_f0.0.3
Install the NPM 1.0.30
You will find NPM pod crash with the following error message:

log.Logf("Error: failed to set IsNewNwPolicyVerFlag")

If you run kubectl version, you will get the following version information.
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.8-hotfix.20200127", GitCommit:"c52f59bbba5fbf21fbb18e9a06f96e563fe4c20a", GitTreeState:"clean", BuildDate:"2020-01-28T02:47:05Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}


Anything else we need to know:
I'd propose to use the GitVersion to get the k8s version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions