Skip to content

Commit 0a22ad5

Browse files
committed
fix: Remove providerName from defaultStorage config
This commit removes the `providerName` from `defaultStorage` configuration, just requiring that the `defaultStorageClassConfigName` exists for one of the configured providers. This commit also adds validation to ensure that the storage class configs have unique names across providers, current behaviour could have led to conflicts if the storage class name was used in multiple provider configurations. When adding the `local-path` CSI provisioner for Docker clusters, I found that the `providerName` in default storage class config was redundant and led to unnecessary duplication of values. Removing this unnecessary field reduces the duplication from: ``` defaultStorage: providerName: local-path storageClassConfigName: local-path providers: - name: local-path storageClassConfig: - name: local-path strategy: HelmAddon ``` To: ``` defaultStorageClassConfigName: local-path providers: - name: local-path storageClassConfig: - name: local-path strategy: HelmAddon ``` While this may seem like only a small change, a single line removed, it is always good to keep APIs as terse as possible while still retaining strict behaviour. I think this commit achieves that.
1 parent 511785f commit 0a22ad5

28 files changed

+125
-257
lines changed

api/v1alpha1/addon_types.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,15 @@ type ClusterAutoscaler struct {
109109
Strategy AddonStrategy `json:"strategy"`
110110
}
111111

112-
type DefaultStorage struct {
113-
// Name of the CSI Provider for the default storage class.
114-
// +kubebuilder:validation:Required
115-
// +kubebuilder:validation:Enum=aws-ebs;nutanix;local-path
116-
ProviderName string `json:"providerName"`
117-
118-
// Name of storage class config in any of the provider objects.
119-
// +kubebuilder:validation:Required
120-
// +kubebuilder:validation:MinLength=1
121-
StorageClassConfigName string `json:"storageClassConfigName"`
122-
}
123-
124112
type CSI struct {
125113
// +kubebuilder:validation:MinItems=1
126114
// +kubebuilder:validation:Required
127115
Providers []CSIProvider `json:"providers"`
128116

117+
// Name of the default storage class config in any of the provider objects.
129118
// +kubebuilder:validation:Required
130-
DefaultStorage DefaultStorage `json:"defaultStorage"`
119+
// +kubebuilder:validation:MinLength=1
120+
DefaultStorageClassConfigName string `json:"defaultStorageClassConfigName"`
131121
}
132122

133123
type CSIProvider struct {

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,10 @@ spec:
100100
type: object
101101
csi:
102102
properties:
103-
defaultStorage:
104-
properties:
105-
providerName:
106-
description: Name of the CSI Provider for the default storage class.
107-
enum:
108-
- aws-ebs
109-
type: string
110-
storageClassConfigName:
111-
description: Name of storage class config in any of the provider objects.
112-
minLength: 1
113-
type: string
114-
required:
115-
- providerName
116-
- storageClassConfigName
117-
type: object
103+
defaultStorageClassConfigName:
104+
description: Name of the default storage class config in any of the provider objects.
105+
minLength: 1
106+
type: string
118107
providers:
119108
items:
120109
properties:
@@ -190,7 +179,7 @@ spec:
190179
minItems: 1
191180
type: array
192181
required:
193-
- defaultStorage
182+
- defaultStorageClassConfigName
194183
- providers
195184
type: object
196185
nfd:

api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,10 @@ spec:
100100
type: object
101101
csi:
102102
properties:
103-
defaultStorage:
104-
properties:
105-
providerName:
106-
description: Name of the CSI Provider for the default storage class.
107-
enum:
108-
- local-path
109-
type: string
110-
storageClassConfigName:
111-
description: Name of storage class config in any of the provider objects.
112-
minLength: 1
113-
type: string
114-
required:
115-
- providerName
116-
- storageClassConfigName
117-
type: object
103+
defaultStorageClassConfigName:
104+
description: Name of the default storage class config in any of the provider objects.
105+
minLength: 1
106+
type: string
118107
providers:
119108
items:
120109
properties:
@@ -190,7 +179,7 @@ spec:
190179
minItems: 1
191180
type: array
192181
required:
193-
- defaultStorage
182+
- defaultStorageClassConfigName
194183
- providers
195184
type: object
196185
nfd:

api/v1alpha1/crds/caren.nutanix.com_genericclusterconfigs.yaml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,11 @@ spec:
114114
type: object
115115
csi:
116116
properties:
117-
defaultStorage:
118-
properties:
119-
providerName:
120-
description: Name of the CSI Provider for the default
121-
storage class.
122-
enum:
123-
- aws-ebs
124-
- nutanix
125-
- local-path
126-
type: string
127-
storageClassConfigName:
128-
description: Name of storage class config in any of the
129-
provider objects.
130-
minLength: 1
131-
type: string
132-
required:
133-
- providerName
134-
- storageClassConfigName
135-
type: object
117+
defaultStorageClassConfigName:
118+
description: Name of the default storage class config in any
119+
of the provider objects.
120+
minLength: 1
121+
type: string
136122
providers:
137123
items:
138124
properties:
@@ -219,7 +205,7 @@ spec:
219205
minItems: 1
220206
type: array
221207
required:
222-
- defaultStorage
208+
- defaultStorageClassConfigName
223209
- providers
224210
type: object
225211
nfd:

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,10 @@ spec:
100100
type: object
101101
csi:
102102
properties:
103-
defaultStorage:
104-
properties:
105-
providerName:
106-
description: Name of the CSI Provider for the default storage class.
107-
enum:
108-
- nutanix
109-
type: string
110-
storageClassConfigName:
111-
description: Name of storage class config in any of the provider objects.
112-
minLength: 1
113-
type: string
114-
required:
115-
- providerName
116-
- storageClassConfigName
117-
type: object
103+
defaultStorageClassConfigName:
104+
description: Name of the default storage class config in any of the provider objects.
105+
minLength: 1
106+
type: string
118107
providers:
119108
items:
120109
properties:
@@ -190,7 +179,7 @@ spec:
190179
minItems: 1
191180
type: array
192181
required:
193-
- defaultStorage
182+
- defaultStorageClassConfigName
194183
- providers
195184
type: object
196185
nfd:

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/capi-quick-start/aws-cluster-calico-crs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Calico
2929
strategy: ClusterResourceSet
3030
csi:
31-
defaultStorage:
32-
providerName: aws-ebs
33-
storageClassConfigName: aws-ebs
31+
defaultStorageClassConfigName: aws-ebs
3432
providers:
3533
- name: aws-ebs
3634
storageClassConfig:

examples/capi-quick-start/aws-cluster-calico-helm-addon.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Calico
2929
strategy: HelmAddon
3030
csi:
31-
defaultStorage:
32-
providerName: aws-ebs
33-
storageClassConfigName: aws-ebs
31+
defaultStorageClassConfigName: aws-ebs
3432
providers:
3533
- name: aws-ebs
3634
storageClassConfig:

examples/capi-quick-start/aws-cluster-cilium-crs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Cilium
2929
strategy: ClusterResourceSet
3030
csi:
31-
defaultStorage:
32-
providerName: aws-ebs
33-
storageClassConfigName: aws-ebs
31+
defaultStorageClassConfigName: aws-ebs
3432
providers:
3533
- name: aws-ebs
3634
storageClassConfig:

examples/capi-quick-start/aws-cluster-cilium-helm-addon.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Cilium
2929
strategy: HelmAddon
3030
csi:
31-
defaultStorage:
32-
providerName: aws-ebs
33-
storageClassConfigName: aws-ebs
31+
defaultStorageClassConfigName: aws-ebs
3432
providers:
3533
- name: aws-ebs
3634
storageClassConfig:

examples/capi-quick-start/docker-cluster-calico-crs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Calico
2929
strategy: ClusterResourceSet
3030
csi:
31-
defaultStorage:
32-
providerName: local-path
33-
storageClassConfigName: local-path
31+
defaultStorageClassConfigName: local-path
3432
providers:
3533
- name: local-path
3634
storageClassConfig:

examples/capi-quick-start/docker-cluster-calico-helm-addon.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Calico
2929
strategy: HelmAddon
3030
csi:
31-
defaultStorage:
32-
providerName: local-path
33-
storageClassConfigName: local-path
31+
defaultStorageClassConfigName: local-path
3432
providers:
3533
- name: local-path
3634
storageClassConfig:

examples/capi-quick-start/docker-cluster-cilium-crs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Cilium
2929
strategy: ClusterResourceSet
3030
csi:
31-
defaultStorage:
32-
providerName: local-path
33-
storageClassConfigName: local-path
31+
defaultStorageClassConfigName: local-path
3432
providers:
3533
- name: local-path
3634
storageClassConfig:

examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ spec:
2828
provider: Cilium
2929
strategy: HelmAddon
3030
csi:
31-
defaultStorage:
32-
providerName: local-path
33-
storageClassConfigName: local-path
31+
defaultStorageClassConfigName: local-path
3432
providers:
3533
- name: local-path
3634
storageClassConfig:

examples/capi-quick-start/nutanix-cluster-calico-crs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ spec:
7373
provider: Calico
7474
strategy: ClusterResourceSet
7575
csi:
76-
defaultStorage:
77-
providerName: nutanix
78-
storageClassConfigName: nutanix-volume
76+
defaultStorageClassConfigName: nutanix-volume
7977
providers:
8078
- credentials:
8179
secretRef:

examples/capi-quick-start/nutanix-cluster-calico-helm-addon.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ spec:
7373
provider: Calico
7474
strategy: HelmAddon
7575
csi:
76-
defaultStorage:
77-
providerName: nutanix
78-
storageClassConfigName: nutanix-volume
76+
defaultStorageClassConfigName: nutanix-volume
7977
providers:
8078
- credentials:
8179
secretRef:

examples/capi-quick-start/nutanix-cluster-cilium-crs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ spec:
7373
provider: Cilium
7474
strategy: ClusterResourceSet
7575
csi:
76-
defaultStorage:
77-
providerName: nutanix
78-
storageClassConfigName: nutanix-volume
76+
defaultStorageClassConfigName: nutanix-volume
7977
providers:
8078
- credentials:
8179
secretRef:

examples/capi-quick-start/nutanix-cluster-cilium-helm-addon.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ spec:
7373
provider: Cilium
7474
strategy: HelmAddon
7575
csi:
76-
defaultStorage:
77-
providerName: nutanix
78-
storageClassConfigName: nutanix-volume
76+
defaultStorageClassConfigName: nutanix-volume
7977
providers:
8078
- credentials:
8179
secretRef:

hack/examples/patches/aws/csi.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
- op: "add"
55
path: "/spec/topology/variables/0/value/addons/csi"
66
value:
7-
defaultStorage:
8-
providerName: aws-ebs
9-
storageClassConfigName: aws-ebs
7+
defaultStorageClassConfigName: aws-ebs
108
providers:
119
- name: aws-ebs
1210
storageClassConfig:

hack/examples/patches/docker/csi.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
- op: "add"
55
path: "/spec/topology/variables/0/value/addons/csi"
66
value:
7-
defaultStorage:
8-
providerName: local-path
9-
storageClassConfigName: local-path
7+
defaultStorageClassConfigName: local-path
108
providers:
119
- name: local-path
1210
storageClassConfig:

hack/examples/patches/nutanix/csi.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
- op: "add"
55
path: "/spec/topology/variables/0/value/addons/csi"
66
value:
7-
defaultStorage:
8-
providerName: nutanix
9-
storageClassConfigName: nutanix-volume
7+
defaultStorageClassConfigName: nutanix-volume
108
providers:
119
- name: nutanix
1210
storageClassConfig:

make/addons.mk

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ export KUBE_VIP_VERSION := v0.8.0
2424

2525
export METALLB_CHART_VERSION := v0.14.5
2626

27-
# Below are the lists of CSI Providers allowed for a specific infrastructure.
28-
# - When we support a new infrastructure, we need to a create a new list using the same convention.
29-
# - When we support a new CSI Provider, we need to add it to one or more of these lists
30-
CSI_PROVIDERS_aws := ["aws-ebs"]
31-
CSI_PROVIDERS_nutanix := ["nutanix"]
32-
CSI_PROVIDERS_docker := ["local-path"]
33-
3427
.PHONY: addons.sync
3528
addons.sync: $(addprefix update-addon.,calico cilium nfd cluster-autoscaler aws-ebs-csi aws-ccm.127 aws-ccm.128 aws-ccm.129 kube-vip)
3629

@@ -64,7 +57,8 @@ update-addon.kube-vip: ; $(info $(M) updating kube-vip manifests)
6457

6558
.PHONY: generate-helm-configmap
6659
generate-helm-configmap:
67-
go run hack/tools/helm-cm/main.go -kustomize-directory="./hack/addons/kustomize" -output-file="./charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml"
60+
go run hack/tools/helm-cm/main.go -kustomize-directory="./hack/addons/kustomize" \
61+
-output-file="./charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml"
6862
./hack/addons/add-warning-helm-configmap.sh
6963

7064
# Set only the supported CSI providers for each provider.

0 commit comments

Comments
 (0)