aws / aws-node-termination-handler

Gracefully handle EC2 instance shutdown within Kubernetes
https://aws.amazon.com/ec2
Apache License 2.0
1.64k stars 268 forks source link

Invalid semantic version #193

Closed itssimon closed 4 years ago

itssimon commented 4 years ago

Error: Failed to render chart: exit status 1: Error: template: aws-node-termination-handler/templates/daemonset.linux.yaml:23:9: executing "aws-node-termination-handler/templates/daemonset.linux.yaml" at <include "aws-node-termination-handler.nodeSelectorTermsOs" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:96:40: executing "aws-node-termination-handler.nodeSelectorTermsOs" at <include "aws-node-termination-handler.defaultNodeSelectorTermsOs" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:82:14: executing "aws-node-termination-handler.defaultNodeSelectorTermsOs" at <include "aws-node-termination-handler.defaultNodeSelectorTermsPrefix" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:75:8: executing "aws-node-termination-handler.defaultNodeSelectorTermsPrefix" at <semverCompare "<1.14" $k8sVersion>: error calling semverCompare: Invalid Semantic Version

This was introduced in #190.

bwagner5 commented 4 years ago

will look into this ASAP

bwagner5 commented 4 years ago

Can you share details about your environment? I'm trying to reproduce, but all e2e tests are passing and they use helm to install. I was able to manually install to an EKS cluster w/ the following version using helm3:

kubectl version
Client Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.6-beta.0", GitCommit:"e7f962ba86f4ce7033828210ca3556393c377bcc", GitTreeState:"clean", BuildDate:"2020-01-15T08:26:26Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.11-eks-af3caf", GitCommit:"af3caf6136cd355f467083651cc1010a499f59b1", GitTreeState:"clean", BuildDate:"2020-03-27T21:51:36Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}
itssimon commented 4 years ago

The error occurs during a helmfile apply operation, which internally uses the helm diff plugin. It's just in the latest chart version, the previous version 0.8.0 works fine.

kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.9", GitCommit:"a17149e1a189050796ced469dbd78d380f2ed5ef", GitTreeState:"clean", BuildDate:"2020-04-16T11:44:51Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.8-eks-e16311", GitCommit:"e163110a04dcb2f39c3325af96d019b4925419eb", GitTreeState:"clean", BuildDate:"2020-03-27T22:37:12Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
helm version       
version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}
helmfile --version
helmfile version v0.120.0
fert-f commented 4 years ago

Workaround is to use old chart version: helm upgrade ... --set image.tag=v1.5.0 --version 0.8.0

bwagner5 commented 4 years ago

Thanks for the info, I was able to reproduce with the helm diff plugin:

$ helm diff upgrade aws-node-termination-handler ~/git/aws-node-termination-handler/config/helm/aws-node-termination-handler -n kube-system --debug

...
Error: template: aws-node-termination-handler/templates/daemonset.linux.yaml:23:9: executing "aws-node-termination-handler/templates/daemonset.linux.yaml" at <include "aws-node-termination-handler.nodeSelectorTermsOs" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:96:40: executing "aws-node-termination-handler.nodeSelectorTermsOs" at <include "aws-node-termination-handler.defaultNodeSelectorTermsOs" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:82:14: executing "aws-node-termination-handler.defaultNodeSelectorTermsOs" at <include "aws-node-termination-handler.defaultNodeSelectorTermsPrefix" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:75:8: executing "aws-node-termination-handler.defaultNodeSelectorTermsPrefix" at <semverCompare "<1.14" $k8sVersion>: error calling semverCompare: Invalid Semantic Version
helm.go:84: [debug] template: aws-node-termination-handler/templates/daemonset.linux.yaml:23:9: executing "aws-node-termination-handler/templates/daemonset.linux.yaml" at <include "aws-node-termination-handler.nodeSelectorTermsOs" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:96:40: executing "aws-node-termination-handler.nodeSelectorTermsOs" at <include "aws-node-termination-handler.defaultNodeSelectorTermsOs" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:82:14: executing "aws-node-termination-handler.defaultNodeSelectorTermsOs" at <include "aws-node-termination-handler.defaultNodeSelectorTermsPrefix" .>: error calling include: template: aws-node-termination-handler/templates/_helpers.tpl:75:8: executing "aws-node-termination-handler.defaultNodeSelectorTermsPrefix" at <semverCompare "<1.14" $k8sVersion>: error calling semverCompare: Invalid Semantic Version
bwagner5 commented 4 years ago

PR is up for a patch. Turns out EKS Minor versions have a "+" in them.

bwagner5 commented 4 years ago

eks-charts has been released

TBBle commented 4 years ago

I just saw this. Kubernetes Major/Minor versions are not SemVer, so semverCompare is the wrong function to use here.

The correct field to check with semverCompare is .Capabilities.KubeVersion.Version (GitVersion upstream, and formerly known as .Capabilities.KubeVersion.GitVersion in Helm v2), although you have to check against 1.14.0-0 (i.e. accept any 1.14 pre-release) because EKS claims to be a prerelease itself.

You can see exactly this use-case in Helm's own default template.

And I've just noticed that #190 introduced this by moving away from that format. I think it was the wrong change, it should have just switched Version to be GitVersion.