aws / aws/eks-anywhere

No Validation for Existence of VSphereDatacenterConfig ref

Open
#1,062 0 comments 0 reactions 0 assignees View on GitHub
kind/bug team/cli
Dominant language
Go
Stars
2.1k
Forks
328
Avg merge
1d 4h
Merged PRs (30d)
9

Description

**What happened**:
I had a cluster spec which referenced a non-existent `VSphereDatacenterConfig`. The cluster object referred to a `VSphereDatacenterConfig` `testcluster1`, but the only `VSphereDatacenterConfig` in the spec file was named `testscluster2`.

Something like the below:

```
datacenterRef:
kind: VSphereDatacenterConfig
name: testcluster1
```

and
```
---
apiVersion: anywhere.eks.amazonaws.com/v1alpha1
kind: VSphereDatacenterConfig
metadata:
name: testcluster2
```

When I ran `eksctl anywhere create cluster -f my_busted_spec_file.yaml -v 9`, no validations caught the fact that no `VSphereDatacenterConfig` of the name `testcluster1` existed in my spec file, and cluster creation proceeded; only during the `eks-components-install` task did this show up as a cryptic error in the debug logs, like so:

```
2022-01-26T22:28:11.443Z V6 Executing command {"cmd": "/usr/bin/docker exec -i eksa_1643235658132282900 kubectl apply -f - --kubeconfig wncluster03/wncluster03-eks-a-cluster.kubeconfig"}
2022-01-26T22:28:13.017Z V5 Retry execution successful {"retries": 1, "duration": "1.57487569s"}
2022-01-26T22:28:13.018Z V6 Executing command {"cmd": "/usr/bin/docker exec -i eksa_1643235658132282900 kubectl annotate vspheredatacenterconfigs.anywhere.eks.amazonaws.com testcluster1 anywhere.eks.amazonaws.com/paused- --kubeconfig wncluster03/wncluster03-eks-a-cluster.kubeconfig --namespace "}
Error from server (NotFound): vspheredatacenterconfigs.anywhere.eks.amazonaws.com "testcluster1" not found
2022-01-26T22:28:14.054Z V5 Error happened during retry {"error": "error removing annotation: exit status 1", "retries": 1}
2022-01-26T22:28:14.054Z V5 Sleeping before next retry {"time": "5s"}
```

**What you expected to happen**:
Validate that the referenced `VSphereDatacenterConfig` exists prior to proceeding with cluster creation/deletion/other.

**How to reproduce it (as minimally and precisely as possible)**:
Reference a non-existant `VSphereDatacenterConfig` in your cluster spec, but have a `VSphereDatacenterConfig` section with a different name.

Contributor guide

Open the contributing guide

Research direction

No source file or test is named in the issue. Start by tracing cluster-spec validation before create or delete operations, then add coverage for a cluster referencing a missing VSphereDatacenterConfig; done means the invalid reference is rejected before proceeding, with a clear error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.