Skip to content

Commit 4a47522

Browse files
authored
Merge pull request #147 from rejoshed/feature/hash-failure-domain-naming
Feature/hash failure domain naming
2 parents a541d71 + 9f10f03 commit 4a47522

File tree

52 files changed

+77
-3113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+77
-3113
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ cluster-api
2929
# Ignore output of Makefile sed operations created when generating manifests.
3030
config/default/manager_image_patch_edited.yaml
3131

32+
# Ignore output of e2e kustomization of templates.
33+
test/e2e/data/infrastructure-cloudstack/v1beta*/*yaml
34+
3235
# Test binary, build with `go test -c`
3336
*.test
3437

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ clean: ## Clean.
188188
rm -rf $(RELEASE_DIR)
189189
rm -rf bin
190190
rm -rf cluster-api
191+
rm -rf test/e2e/data/infrastructure-cloudstack/*/*yaml
191192

192193
##@ Testing
193194

@@ -223,8 +224,7 @@ cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
223224
cp ./hack/tilt-settings.json cluster-api
224225

225226
##@ End-to-End Testing
226-
227-
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/v1beta2/*/cluster-template*/* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
227+
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/v1beta*/*/cluster-template* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
228228
CLUSTER_TEMPLATES_OUTPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack -type d -name "cluster-template*" -exec echo {}.yaml \;)
229229
.PHONY: e2e-cluster-templates
230230
e2e-cluster-templates: $(CLUSTER_TEMPLATES_OUTPUT_FILES) ## Generate cluster template files for e2e testing.

api/v1beta1/zz_generated.conversion.go

Lines changed: 1 addition & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/cloudstackfailuredomain_types.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,21 @@ limitations under the License.
1717
package v1beta2
1818

1919
import (
20+
"crypto/md5" // #nosec G501 -- weak cryptographic primitive doesn't matter here. Not security related.
21+
"fmt"
22+
2023
corev1 "k8s.io/api/core/v1"
2124
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2225
)
2326

27+
// FailureDomainHashedMetaName returns an MD5 name generated from the FailureDomain and Cluster name.
28+
// FailureDomains must have a unique name even when potentially sharing a namespace with other clusters.
29+
// In the future we may remove the ability to run multiple clusters in a single namespace, but today
30+
// this is a consequence of being upstream of EKS-A which does run multiple clusters in a single namepace.
31+
func FailureDomainHashedMetaName(fdName, clusterName string) string {
32+
return fmt.Sprintf("%x", md5.Sum([]byte(fdName+clusterName))) // #nosec G401 -- weak cryptographic primitive doesn't matter here. Not security related.
33+
}
34+
2435
const (
2536
FailureDomainFinalizer = "cloudstackfailuredomain.infrastructure.cluster.x-k8s.io"
2637
FailureDomainLabelName = "cloudstackfailuredomain.infrastructure.cluster.x-k8s.io/name"
@@ -70,8 +81,9 @@ type CloudStackFailureDomainSpec struct {
7081
// CloudStack domain.
7182
// +optional
7283
Domain string `json:"domain,omitempty"`
84+
7385
// Apache CloudStack Endpoint secret reference.
74-
ACSEndpoint corev1.SecretReference `json:"acsendpoint"`
86+
ACSEndpoint corev1.SecretReference `json:"acsEndpoint"`
7587
}
7688

7789
// CloudStackFailureDomainStatus defines the observed state of CloudStackFailureDomain

api/v1beta2/cloudstackisolatednetwork_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ type CloudStackIsolatedNetworkSpec struct {
4040
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
4141

4242
//+k8s:conversion-gen=false
43-
// FailureDomain -- the FailureDomain the network is placed in.
44-
FailureDomain CloudStackFailureDomainSpec `json:"failureDomain"`
43+
// FailureDomainName -- the FailureDomain the network is placed in.
44+
FailureDomainName string `json:"failureDomainName"`
4545
}
4646

4747
// CloudStackIsolatedNetworkStatus defines the observed state of CloudStackIsolatedNetwork

api/v1beta2/cloudstackmachine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type CloudStackMachineSpec struct {
6363

6464
// Optional affinitygroupids for deployVirtualMachine
6565
// +optional
66-
AffinityGroupIDs []string `json:"affinitygroupids,omitempty"`
66+
AffinityGroupIDs []string `json:"affinityGroupIDs,omitempty"`
6767

6868
// Mutually exclusive parameter with AffinityGroupIDs.
6969
// Defaults to `no`. Can be `pro` or `anti`. Will create an affinity group per machine set.
@@ -73,7 +73,7 @@ type CloudStackMachineSpec struct {
7373
// Mutually exclusive parameter with AffinityGroupIDs.
7474
// Is a reference to a CloudStack affinity group CRD.
7575
// +optional
76-
AffinityGroupRef *corev1.ObjectReference `json:"cloudstackaffinityref,omitempty"`
76+
AffinityGroupRef *corev1.ObjectReference `json:"cloudstackAffinityRef,omitempty"`
7777

7878
// The CS specific unique identifier. Of the form: fmt.Sprintf("cloudstack:///%s", CS Machine ID)
7979
// +optional

api/v1beta2/zz_generated.deepcopy.go

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

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackclusters.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ spec:
223223
account:
224224
description: CloudStack account.
225225
type: string
226-
acsendpoint:
226+
acsEndpoint:
227227
description: Apache CloudStack Endpoint secret reference.
228228
properties:
229229
name:
@@ -272,7 +272,7 @@ spec:
272272
- network
273273
type: object
274274
required:
275-
- acsendpoint
275+
- acsEndpoint
276276
- name
277277
- zone
278278
type: object

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackfailuredomains.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
account:
4242
description: CloudStack account.
4343
type: string
44-
acsendpoint:
44+
acsEndpoint:
4545
description: Apache CloudStack Endpoint secret reference.
4646
properties:
4747
name:
@@ -89,7 +89,7 @@ spec:
8989
- network
9090
type: object
9191
required:
92-
- acsendpoint
92+
- acsEndpoint
9393
- name
9494
- zone
9595
type: object

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackisolatednetworks.yaml

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -118,66 +118,10 @@ spec:
118118
- host
119119
- port
120120
type: object
121-
failureDomain:
122-
description: FailureDomain -- the FailureDomain the network is placed
123-
in.
124-
properties:
125-
account:
126-
description: CloudStack account.
127-
type: string
128-
acsendpoint:
129-
description: Apache CloudStack Endpoint secret reference.
130-
properties:
131-
name:
132-
description: Name is unique within a namespace to reference
133-
a secret resource.
134-
type: string
135-
namespace:
136-
description: Namespace defines the space within which the
137-
secret name must be unique.
138-
type: string
139-
type: object
140-
domain:
141-
description: CloudStack domain.
142-
type: string
143-
name:
144-
description: The failure domain unique name.
145-
type: string
146-
zone:
147-
description: The ACS Zone for this failure domain.
148-
properties:
149-
id:
150-
description: ID.
151-
type: string
152-
name:
153-
description: Name.
154-
type: string
155-
network:
156-
description: The network within the Zone to use.
157-
properties:
158-
id:
159-
description: Cloudstack Network ID the cluster is built
160-
in.
161-
type: string
162-
name:
163-
description: Cloudstack Network Name the cluster is built
164-
in.
165-
type: string
166-
type:
167-
description: Cloudstack Network Type the cluster is built
168-
in.
169-
type: string
170-
required:
171-
- name
172-
type: object
173-
required:
174-
- network
175-
type: object
176-
required:
177-
- acsendpoint
178-
- name
179-
- zone
180-
type: object
121+
failureDomainName:
122+
description: FailureDomainName -- the FailureDomain the network is
123+
placed in.
124+
type: string
181125
id:
182126
description: ID.
183127
type: string
@@ -186,7 +130,7 @@ spec:
186130
type: string
187131
required:
188132
- controlPlaneEndpoint
189-
- failureDomain
133+
- failureDomainName
190134
type: object
191135
status:
192136
description: CloudStackIsolatedNetworkStatus defines the observed state

0 commit comments

Comments
 (0)