Skip to content

Commit b7cae76

Browse files
committed
Remove failure domain from AWSMachineSpec
1 parent 6df68e2 commit b7cae76

File tree

18 files changed

+37
-120
lines changed

18 files changed

+37
-120
lines changed

api/v1beta1/conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ func Convert_v1beta2_AWSClusterSpec_To_v1beta1_AWSClusterSpec(in *v1beta2.AWSClu
2828
func Convert_v1beta1_AWSResourceReference_To_v1beta2_AWSResourceReference(in *AWSResourceReference, out *v1beta2.AWSResourceReference, s conversion.Scope) error {
2929
return autoConvert_v1beta1_AWSResourceReference_To_v1beta2_AWSResourceReference(in, out, s)
3030
}
31+
32+
func Convert_v1beta1_AWSMachineSpec_To_v1beta2_AWSMachineSpec(in *AWSMachineSpec, out *v1beta2.AWSMachineSpec, s conversion.Scope) error {
33+
return autoConvert_v1beta1_AWSMachineSpec_To_v1beta2_AWSMachineSpec(in, out, s)
34+
}

api/v1beta1/conversion_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func fuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
3939
func AWSMachineFuzzer(obj *AWSMachine, c fuzz.Continue) {
4040
c.FuzzNoCustom(obj)
4141

42-
// AWSMachine.Spec.Subnet.ARN and AWSMachine.Spec.AdditionalSecurityGroups.ARN has been removed in v1beta2, so setting it to nil in order to avoid v1beta1 --> v1beta2 --> v1beta1 round trip errors.
42+
// AWSMachine.Spec.FailureDomain, AWSMachine.Spec.Subnet.ARN and AWSMachine.Spec.AdditionalSecurityGroups.ARN has been removed in v1beta2, so setting it to nil in order to avoid v1beta1 --> v1beta2 --> v1beta1 round trip errors.
4343
if obj.Spec.Subnet != nil {
4444
obj.Spec.Subnet.ARN = nil
4545
}
@@ -49,6 +49,7 @@ func AWSMachineFuzzer(obj *AWSMachine, c fuzz.Continue) {
4949
restored = append(restored, sg)
5050
}
5151
obj.Spec.AdditionalSecurityGroups = restored
52+
obj.Spec.FailureDomain = nil
5253
}
5354

5455
func AWSMachineTemplateFuzzer(obj *AWSMachineTemplate, c fuzz.Continue) {
@@ -64,6 +65,7 @@ func AWSMachineTemplateFuzzer(obj *AWSMachineTemplate, c fuzz.Continue) {
6465
restored = append(restored, sg)
6566
}
6667
obj.Spec.Template.Spec.AdditionalSecurityGroups = restored
68+
obj.Spec.Template.Spec.FailureDomain = nil
6769
}
6870

6971
func TestFuzzyConversion(t *testing.T) {

api/v1beta1/zz_generated.conversion.go

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

api/v1beta2/awsmachine_types.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ type AWSMachineSpec struct {
105105
// +optional
106106
AdditionalSecurityGroups []AWSResourceReference `json:"additionalSecurityGroups,omitempty"`
107107

108-
// FailureDomain is the failure domain unique identifier this Machine should be attached to, as defined in Cluster API.
109-
// For this infrastructure provider, the ID is equivalent to an AWS Availability Zone.
110-
// If multiple subnets are matched for the availability zone, the first one returned is picked.
111-
FailureDomain *string `json:"failureDomain,omitempty"`
112-
113108
// Subnet is a reference to the subnet to use for this instance. If not specified,
114109
// the cluster subnet will be used.
115110
// +optional

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
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_awsmachines.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -625,13 +625,6 @@ spec:
625625
- ssm-parameter-store
626626
type: string
627627
type: object
628-
failureDomain:
629-
description: FailureDomain is the failure domain unique identifier
630-
this Machine should be attached to, as defined in Cluster API. For
631-
this infrastructure provider, the ID is equivalent to an AWS Availability
632-
Zone. If multiple subnets are matched for the availability zone,
633-
the first one returned is picked.
634-
type: string
635628
iamInstanceProfile:
636629
description: IAMInstanceProfile is a name of an IAM instance profile
637630
to assign to the instance

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,6 @@ spec:
571571
- ssm-parameter-store
572572
type: string
573573
type: object
574-
failureDomain:
575-
description: FailureDomain is the failure domain unique identifier
576-
this Machine should be attached to, as defined in Cluster
577-
API. For this infrastructure provider, the ID is equivalent
578-
to an AWS Availability Zone. If multiple subnets are matched
579-
for the availability zone, the first one returned is picked.
580-
type: string
581574
iamInstanceProfile:
582575
description: IAMInstanceProfile is a name of an IAM instance
583576
profile to assign to the instance

pkg/cloud/services/ec2/instances.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,6 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use
261261
func (s *Service) findSubnet(scope *scope.MachineScope) (string, error) {
262262
// Check Machine.Spec.FailureDomain first as it's used by KubeadmControlPlane to spread machines across failure domains.
263263
failureDomain := scope.Machine.Spec.FailureDomain
264-
if failureDomain == nil {
265-
failureDomain = scope.AWSMachine.Spec.FailureDomain
266-
}
267264

268265
// We basically have 2 sources for subnets:
269266
// 1. If subnet.id or subnet.filters are specified, we directly query AWS

pkg/cloud/services/ec2/instances_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,14 @@ func TestCreateInstance(t *testing.T) {
404404
Bootstrap: clusterv1.Bootstrap{
405405
DataSecretName: pointer.StringPtr("bootstrap-data"),
406406
},
407+
FailureDomain: aws.String("us-east-1c"),
407408
},
408409
},
409410
machineConfig: &infrav1.AWSMachineSpec{
410411
AMI: infrav1.AMIReference{
411412
ID: aws.String("abc"),
412413
},
413-
InstanceType: "m5.2xlarge",
414-
FailureDomain: aws.String("us-east-1c"),
414+
InstanceType: "m5.2xlarge",
415415
},
416416
awsCluster: &infrav1.AWSCluster{
417417
ObjectMeta: metav1.ObjectMeta{Name: "test"},
@@ -906,6 +906,7 @@ func TestCreateInstance(t *testing.T) {
906906
Bootstrap: clusterv1.Bootstrap{
907907
DataSecretName: pointer.StringPtr("bootstrap-data"),
908908
},
909+
FailureDomain: aws.String("us-east-1b"),
909910
},
910911
},
911912
machineConfig: &infrav1.AWSMachineSpec{
@@ -919,7 +920,6 @@ func TestCreateInstance(t *testing.T) {
919920
Values: []string{"some-value"},
920921
}},
921922
},
922-
FailureDomain: aws.String("us-east-1b"),
923923
},
924924
awsCluster: &infrav1.AWSCluster{
925925
ObjectMeta: metav1.ObjectMeta{Name: "test"},
@@ -1300,6 +1300,7 @@ func TestCreateInstance(t *testing.T) {
13001300
Bootstrap: clusterv1.Bootstrap{
13011301
DataSecretName: pointer.StringPtr("bootstrap-data"),
13021302
},
1303+
FailureDomain: aws.String("us-east-1b"),
13031304
},
13041305
},
13051306
machineConfig: &infrav1.AWSMachineSpec{
@@ -1310,7 +1311,6 @@ func TestCreateInstance(t *testing.T) {
13101311
Subnet: &infrav1.AWSResourceReference{
13111312
ID: aws.String("subnet-1"),
13121313
},
1313-
FailureDomain: aws.String("us-east-1b"),
13141314
},
13151315
awsCluster: &infrav1.AWSCluster{
13161316
ObjectMeta: metav1.ObjectMeta{Name: "test"},
@@ -1381,15 +1381,15 @@ func TestCreateInstance(t *testing.T) {
13811381
Bootstrap: clusterv1.Bootstrap{
13821382
DataSecretName: pointer.StringPtr("bootstrap-data"),
13831383
},
1384+
FailureDomain: aws.String("us-east-1b"),
13841385
},
13851386
},
13861387
machineConfig: &infrav1.AWSMachineSpec{
13871388
AMI: infrav1.AMIReference{
13881389
ID: aws.String("abc"),
13891390
},
1390-
InstanceType: "m5.large",
1391-
FailureDomain: aws.String("us-east-1b"),
1392-
PublicIP: aws.Bool(true),
1391+
InstanceType: "m5.large",
1392+
PublicIP: aws.Bool(true),
13931393
},
13941394
awsCluster: &infrav1.AWSCluster{
13951395
ObjectMeta: metav1.ObjectMeta{Name: "test"},

test/e2e/data/infrastructure-aws/withclusterclass/clusterclassbase/clusterclass-ci-default.yaml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -262,35 +262,9 @@ spec:
262262
valueFrom:
263263
template: |
264264
- id: "{{ .publicSubnetID }}"
265+
availabilityZone: "{{ .fdForBYOSubnets }}"
265266
- id: "{{ .privateSubnetID }}"
266-
- name: awsMachineTemplateControlPlaneForBYO
267-
enabledIf: '{{ eq .byoInfra "true" }}'
268-
definitions:
269-
- selector:
270-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
271-
kind: AWSMachineTemplate
272-
matchResources:
273-
controlPlane: true
274-
jsonPatches:
275-
- op: add
276-
path: "/spec/template/spec/failureDomain"
277-
valueFrom:
278-
variable: fdForBYOSubnets
279-
- name: awsMachineTemplateWorkerForBYO
280-
enabledIf: '{{ eq .byoInfra "true" }}'
281-
definitions:
282-
- selector:
283-
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
284-
kind: AWSMachineTemplate
285-
matchResources:
286-
machineDeploymentClass:
287-
names:
288-
- default-worker
289-
jsonPatches:
290-
- op: add
291-
path: "/spec/template/spec/failureDomain"
292-
valueFrom:
293-
variable: fdForBYOSubnets
267+
availabilityZone: "{{ .fdForBYOSubnets }}"
294268
---
295269
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
296270
kind: AWSClusterTemplate

0 commit comments

Comments
 (0)