Panic when Kubernetes version is not supported yet
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 328
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 9
Description
When just trying an automatic Bottlerocket import with 1.25 when EKS Anywhere doesn't support the version officially yet, I get the following error:
```
[ec2-user@ip-172-31-8-141 ~]$ eks-anywhere/bin/eksctl-anywhere upgrade cluster -f demo2/demo2-eks-a-cluster.yaml
Performing setup and validations
✅ Connected to server
✅ Authenticated to vSphere
✅ Datacenter validated
✅ Network validated
panic: runtime error: slice bounds out of range [:7] with length 0
goroutine 1 [running]:
github.com/aws/eks-anywhere/pkg/providers/vsphere.(*Defaulter).setupDefaultTemplate(0xc000dcfd00, {0x3aed090, 0xc000056068}, 0x363dba6?, 0x4f?)
/home/ec2-user/eks-anywhere/pkg/providers/vsphere/defaults.go:88 +0x6af
github.com/aws/eks-anywhere/pkg/providers/vsphere.(*Defaulter).setDefaultTemplateIfMissing(0xc000554780?, {0x3aed090, 0xc000056068}, 0x8?, 0xc000554780)
/home/ec2-user/eks-anywhere/pkg/providers/vsphere/defaults.go:69 +0x9c
github.com/aws/eks-anywhere/pkg/providers/vsphere.(*Defaulter).setDefaultsForMachineConfig(0xc000dcfd00?, {0x3aed090, 0xc000056068}, 0xc0000356d0)
/home/ec2-user/eks-anywhere/pkg/providers/vsphere/defaults.go:29 +0x2b5
github.com/aws/eks-anywhere/pkg/providers/vsphere.(*vsphereProvider).SetupAndValidateUpgradeCluster(0xc000e12d20, {0x3aed090, 0xc000056068}, 0x1?, 0xc000116a00, 0x10?)
/home/ec2-user/eks-anywhere/pkg/providers/vsphere/vsphere.go:395 +0x1c6
github.com/aws/eks-anywhere/pkg/workflows.(*setupAndValidateTasks).validations.func1()
/home/ec2-user/eks-anywhere/pkg/workflows/upgrade.go:144 +0xc9
github.com/aws/eks-anywhere/pkg/validations.(*Runner).Run(0x2eafe40?)
/home/ec2-user/eks-anywhere/pkg/validations/runner.go:24 +0x42
github.com/aws/eks-anywhere/pkg/workflows.(*setupAndValidateTasks).Run(0xc000dcfd50?, {0x3aed090, 0xc000056068}, 0xc0000220f0)
/home/ec2-user/eks-anywhere/pkg/workflows/upgrade.go:130 +0x25d
github.com/aws/eks-anywhere/pkg/task.(*taskRunner).RunTask(0xc000dd5260, {0x3aed090, 0xc000056068}, 0xc0000220f0)
/home/ec2-user/eks-anywhere/pkg/task/task.go:155 +0x3e3
github.com/aws/eks-anywhere/pkg/workflows.(*Upgrade).Run(0xc0007e9c20, {0x3aed090, 0xc000056068}, 0xc000116a00, 0xc000dd5230, 0xc000dd5230, {0x3ab9f00?, 0xc0002d0a50}, 0x0?)
/home/ec2-user/eks-anywhere/pkg/workflows/upgrade.go:78 +0x435
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd.(*upgradeClusterOptions).upgradeCluster(0x53529a0, 0x5330420)
/home/ec2-user/eks-anywhere/cmd/eksctl-anywhere/cmd/upgradecluster.go:149 +0xa98
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd.glob..func26(0x5330420?, {0x3562f4d?, 0x2?, 0x2?})
/home/ec2-user/eks-anywhere/cmd/eksctl-anywhere/cmd/upgradecluster.go:37 +0x26
github.com/spf13/cobra.(*Command).execute(0x5330420, {0xc0001269e0, 0x2, 0x2})
/home/ec2-user/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x532f8a0)
/home/ec2-user/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
/home/ec2-user/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/spf13/cobra.(*Command).ExecuteContext(...)
/home/ec2-user/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:961
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd.Execute()
/home/ec2-user/eks-anywhere/cmd/eksctl-anywhere/cmd/root.go:59 +0x54
main.main()
/home/ec2-user/eks-anywhere/cmd/eksctl-anywhere/main.go:29 +0x125
```
The error occurs below when trying to reference one of the fields. We need to make sure we can handle this case where we throw an unsupported error instead.
https://github.com/aws/eks-anywhere/blob/main/pkg/providers/vsphere/defaults.go#L88
Contributor guide
Research direction
Start in pkg/providers/vsphere/defaults.go at line 88 and trace the default-template setup reached by the upgrade cluster command. Reproduce with the shown unsupported Kubernetes 1.25 scenario, then verify the command reports an unsupported-version error instead of panicking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, go, kubernetes
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100