-
Notifications
You must be signed in to change notification settings - Fork 260
Description
Is this a request for help?:
When we deploy azure npm in a k8s alpha or beta version cluster, azure-npm is always in failing state, k8s version parsing is failing, and there are even on logs showing why it's failing:
azure-container-networking/npm/util/util.go
Lines 97 to 161 in 36f188c
| // CompareK8sVer compares two k8s versions. | |
| // returns -1, 0, 1 if firstVer smaller, equals, bigger than secondVer respectively. | |
| // returns -2 for error. | |
| func CompareK8sVer(firstVer *version.Info, secondVer *version.Info) int { | |
| firstMajor, err := strconv.Atoi(firstVer.Major) | |
| if err != nil { | |
| return -2 | |
| } | |
| firstMinor, err := strconv.Atoi(firstVer.Minor) | |
| if err != nil { | |
| return -2 | |
| } | |
| secondMajor, err := strconv.Atoi(secondVer.Major) | |
| if err != nil { | |
| return -2 | |
| } | |
| secondMinor, err := strconv.Atoi(secondVer.Minor) | |
| if err != nil { | |
| return -2 | |
| } | |
| if firstMajor < secondMajor { | |
| return -1 | |
| } | |
| if firstMajor > secondMajor { | |
| return 1 | |
| } | |
| if firstMinor < secondMinor { | |
| return -1 | |
| } | |
| if firstMinor > secondMinor { | |
| return 1 | |
| } | |
| return 0 | |
| } | |
| // IsNewNwPolicyVer checks if the current k8s version >= 1.11, | |
| // if so, then the networkPolicy should support 'AND' between namespaceSelector & podSelector. | |
| func IsNewNwPolicyVer(ver *version.Info) (bool, error) { | |
| newVer := &version.Info{ | |
| Major: k8sMajorVerForNewPolicyDef, | |
| Minor: k8sMinorVerForNewPolicyDef, | |
| } | |
| isNew := CompareK8sVer(ver, newVer) | |
| switch isNew { | |
| case -2: | |
| return false, fmt.Errorf("invalid Kubernetes version") | |
| case -1: | |
| return false, nil | |
| case 0: | |
| return true, nil | |
| case 1: | |
| return true, nil | |
| default: | |
| return false, nil | |
| } | |
| } |
failing k8s version could be like this: 1.17.0-beta.1
Is this an ISSUE or FEATURE REQUEST? (choose one):
Which release version?:
Which component (CNI/IPAM/CNM/CNS):
Which Operating System (Linux/Windows):
For Linux: Include Distro and kernel version using "uname -a"
For windows: provide output of "$(Get-ItemProperty -Path "C:\windows\system32\hal.dll").VersionInfo.FileVersion"
Which Orchestrator and version (e.g. Kubernetes, Docker)
What happened:
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know: