From 4f618bf698bb485c98b8438f1eac4bb58202141c Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Tue, 26 Jan 2021 13:41:59 -0600 Subject: [PATCH] operator: allow NodePool to override default subnet filter --- .../controllers/nodepool_controller.go | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/hypershift-operator/controllers/nodepool_controller.go b/hypershift-operator/controllers/nodepool_controller.go index bb6eb7ca3fb8..bbaff3f01ba9 100644 --- a/hypershift-operator/controllers/nodepool_controller.go +++ b/hypershift-operator/controllers/nodepool_controller.go @@ -204,19 +204,7 @@ func generateScalableResources(client ctrlclient.Client, ctx context.Context, in return nil, nil, fmt.Errorf("error finding AMI. Found: %v. Error: %v", found, err) } - // TODO (alberto): remove hardcoded "a" zone and come up with a solution - // for automation across az - // e.g have a "locations" field in the nodeGroup or expose the subnet in the nodeGroup - subnet := &capiaws.AWSResourceReference{ - Filters: []capiaws.Filter{ - { - Name: "tag:Name", - Values: []string{ - fmt.Sprintf("%s-private-%sa", infraName, region), - }, - }, - }, - } + subnet := &capiaws.AWSResourceReference{} if nodePool.Spec.Platform.AWS.Subnet != nil { subnet.ID = nodePool.Spec.Platform.AWS.Subnet.ID subnet.ARN = nodePool.Spec.Platform.AWS.Subnet.ARN @@ -227,6 +215,20 @@ func generateScalableResources(client ctrlclient.Client, ctx context.Context, in } subnet.Filters = append(subnet.Filters, filter) } + } else { + // TODO (alberto): remove hardcoded "a" zone and come up with a solution + // for automation across az + // e.g have a "locations" field in the nodeGroup or expose the subnet in the nodeGroup + subnet = &capiaws.AWSResourceReference{ + Filters: []capiaws.Filter{ + { + Name: "tag:Name", + Values: []string{ + fmt.Sprintf("%s-private-%sa", infraName, region), + }, + }, + }, + } } instanceProfile := fmt.Sprintf("%s-worker-profile", infraName)