From 530ea0215fcf8842a402a6fc4f62113671036c59 Mon Sep 17 00:00:00 2001 From: Konstantinos Angelopoulos Date: Thu, 29 Aug 2024 14:25:31 +0300 Subject: [PATCH] [release-v1.57] Automated cherry pick of #1038: Fix issues with the AWS flow after last update (#1042) * add infra webhook to manager * correctly calculate subnets in infra status by using exportAsFlatmap * add integration test check --- pkg/cmd/options.go | 2 ++ pkg/controller/infrastructure/infraflow/context.go | 2 +- test/integration/infrastructure/infrastructure_test.go | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/options.go b/pkg/cmd/options.go index 148e03dfa..03e6390f6 100644 --- a/pkg/cmd/options.go +++ b/pkg/cmd/options.go @@ -36,6 +36,7 @@ import ( cloudproviderwebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/cloudprovider" controlplanewebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/controlplane" controlplaneexposurewebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/controlplaneexposure" + "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/infrastructure" shootwebhook "github.com/gardener/gardener-extension-provider-aws/pkg/webhook/shoot" ) @@ -70,6 +71,7 @@ func WebhookSwitchOptions(gardenerVersion *string) *webhookcmd.SwitchOptions { webhookcmd.Switch(extensioncontrolplanewebhook.ExposureWebhookName, controlplaneexposurewebhook.AddToManager), webhookcmd.Switch(extensionshootwebhook.WebhookName, shootwebhook.AddToManager), webhookcmd.Switch(extensionscloudproviderwebhook.WebhookName, cloudproviderwebhook.AddToManager), + webhookcmd.Switch(infrastructure.WebhookName, infrastructure.AddToManager), ) } diff --git a/pkg/controller/infrastructure/infraflow/context.go b/pkg/controller/infrastructure/infraflow/context.go index 67a8b63f4..7af28ade3 100644 --- a/pkg/controller/infrastructure/infraflow/context.go +++ b/pkg/controller/infrastructure/infraflow/context.go @@ -218,7 +218,7 @@ func (c *FlowContext) computeInfrastructureStatus() *awsv1alpha1.InfrastructureS if vpcID != "" { var subnets []awsv1alpha1.Subnet prefix := ChildIdZones + shared.Separator - for k, v := range c.state.AsMap() { + for k, v := range c.state.ExportAsFlatMap() { if !shared.IsValidValue(v) { continue } diff --git a/test/integration/infrastructure/infrastructure_test.go b/test/integration/infrastructure/infrastructure_test.go index ccc839d4b..c8033fd86 100644 --- a/test/integration/infrastructure/infrastructure_test.go +++ b/test/integration/infrastructure/infrastructure_test.go @@ -971,6 +971,11 @@ func verifyCreation( }, )) infrastructureIdentifier.subnetIDs = append(infrastructureIdentifier.subnetIDs, subnet.SubnetId) + Expect(infraStatus.VPC.Subnets).To(ContainElement(Equal(awsv1alpha1.Subnet{ + Purpose: awsv1alpha1.PurposeNodes, + ID: ptr.Deref(subnet.SubnetId, ""), + Zone: availabilityZone, + }))) } if reflect.DeepEqual(tag.Key, awssdk.String("Name")) && reflect.DeepEqual(tag.Value, awssdk.String(infra.Namespace+publicUtilitySuffix)) { foundExpectedSubnets++