If SnowIPPool does not exist, eksa will throw NPE
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 328
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 9
Description
**What happened**:
If SnowIPPool doesn't exist, eksa will return nil pointer error
```
2023-07-02T20:26:34.251Z V6 Executing command {"cmd": "/usr/bin/docker rm -f -v eksa_1688329496323860104"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x110 pc=0x2addd6e]
goroutine 1 [running]:
github.com/aws/eks-anywhere/pkg/providers/snow.toAWSSnowIPPool(0x0)
github.com/aws/eks-anywhere/pkg/providers/snow/apibuilder.go:247 +0x2e
github.com/aws/eks-anywhere/pkg/providers/snow.CAPASIPPools.addPools(0x2f9f140?, {0xc00029abe0?, 0x4, 0xc?}, 0x203000?)
github.com/aws/eks-anywhere/pkg/providers/snow/apibuilder.go:232 +0x9a
github.com/aws/eks-anywhere/pkg/providers/snow.WorkersSpec({0x3b6fe10, 0xc000052098}, {{0x3b74970?, 0xc00072a3f0?}, 0x0?}, 0xc000b24dc0, {0x3b746e8, 0xc0007168d0})
github.com/aws/eks-anywhere/pkg/providers/snow/workers.go:51 +0x2d0
github.com/aws/eks-anywhere/pkg/providers/snow.WorkersObjects({0x3b6fe10?, 0xc000052098?}, {{0x3b74970?, 0xc00072a3f0?}, 0x1d?}, 0x0?, {0x3b746e8?, 0xc0007168d0?})
github.com/aws/eks-anywhere/pkg/providers/snow/objects.go:26 +0x5b
github.com/aws/eks-anywhere/pkg/providers/snow.CAPIObjects({0x3b6fe10, 0xc000052098}, {{0x3b74970?, 0xc00072a3f0?}, 0x0?}, 0x0?, {0x3b746e8, 0xc0007168d0})
github.com/aws/eks-anywhere/pkg/providers/snow/snow.go:128 +0x165
github.com/aws/eks-anywhere/pkg/providers/snow.(*SnowProvider).generateCAPISpec(0xc000cff770, {0x3b6fe10, 0xc000052098}, 0xc00014f980?, 0x2?)
github.com/aws/eks-anywhere/pkg/providers/snow/snow.go:152 +0x71
github.com/aws/eks-anywhere/pkg/providers/snow.(*SnowProvider).GenerateCAPISpecForCreate(0x203000?, {0x3b6fe10?, 0xc000052098?}, 0xc00014f980?, 0x0?)
github.com/aws/eks-anywhere/pkg/providers/snow/snow.go:156 +0x25
github.com/aws/eks-anywhere/pkg/clustermanager.(*ClusterManager).applyProviderManifests(0xc000a08b40, {0x3b6fe10, 0xc000052098}, 0xc000b24dc0, 0x3625a70?, {0x3b86ef8?, 0xc000cff770?})
github.com/aws/eks-anywhere/pkg/clustermanager/cluster_manager.go:463 +0x70
github.com/aws/eks-anywhere/pkg/clustermanager.(*ClusterManager).CreateWorkloadCluster(0xc000a08b40, {0x3b6fe10, 0xc000052098}, 0xc0005cbc50, 0xc000b24dc0, {0x3b86ef8, 0xc000cff770})
github.com/aws/eks-anywhere/pkg/clustermanager/cluster_manager.go:382 +0xf8
github.com/aws/eks-anywhere/pkg/workflows.(*CreateWorkloadClusterTask).Run(0xc000b81a20?, {0x3b6fe10, 0xc000052098}, 0xc000d1d8c0)
github.com/aws/eks-anywhere/pkg/workflows/create.go:212 +0x7c
github.com/aws/eks-anywhere/pkg/task.(*taskRunner).RunTask(0xc000d25260, {0x3b6fe10, 0xc000052098}, 0xc000d1d8c0)
github.com/aws/eks-anywhere/pkg/task/task.go:158 +0x463
github.com/aws/eks-anywhere/pkg/workflows.(*Create).Run(0xc000b0fc48, {0x3b6fe10, 0xc000052098}, 0xc000b24dc0, {0x3b3c480?, 0xc000d049f0}, 0x1?)
github.com/aws/eks-anywhere/pkg/workflows/create.go:69 +0x312
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd.(*createClusterOptions).createCluster(0x54100a0, 0x53e68c0, {0x0?, 0x0?, 0x0?})
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd/createcluster.go:190 +0xf0e
github.com/spf13/cobra.(*Command).execute(0x53e68c0, {0xc0007200c0, 0x4, 0x4})
github.com/spf13/cobra@v1.6.1/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x53ec7a0)
github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.6.1/command.go:968
github.com/spf13/cobra.(*Command).ExecuteContext(...)
github.com/spf13/cobra@v1.6.1/command.go:961
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd.Execute()
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/cmd/root.go:65 +0x54
main.main()
github.com/aws/eks-anywhere/cmd/eksctl-anywhere/main.go:29 +0x125
[ec2-user@ip-34-223-14-194 ~]$
```
**What you expected to happen**:
Run a preflight check and return proper errors.
**How to reproduce it (as minimally and precisely as possible)**:
Example cluster config:
```
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: SnowMachineConfig
metadata:
name: chy-eksa-poc-cp
spec:
devices:
- 192.168.1.55
instanceType: sbe-c.large
sshKeyName: default
network:
directNetworkInterfaces:
- ipPoolRef:
kind: SnowIPPool
name: pool1
index: 1
primary: true
osFamily: ubuntu
physicalNetworkConnector: SFP_PLUS
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: SnowIPPool
metadata:
name: pool2
spec:
pools:
- ipStart: 192.168.1.2
ipEnd: 192.168.1.40
subnet: 192.168.1.0/24
gateway: 192.168.1.1
---
```
In the above example, snow machine config uses SnowIPPool with mane pool1, but the pool doesn't exist in the SnowIPPool config
**Anything else we need to know?**:
n/a
**Environment**:
- EKS Anywhere Release: 0.15.4
- EKS Distro Release: 1.26
Contributor guide
Research direction
Start in pkg/providers/snow/apibuilder.go at CAPASIPPools.addPools and toAWSSnowIPPool, then trace the call from pkg/providers/snow/workers.go. Reproduce the missing pool1 reference with the example SnowMachineConfig and SnowIPPool configuration. Done means the configuration receives a proper preflight error instead of a nil pointer panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100