From a9a27a40decffbb6294859dff27b01192d4e09c4 Mon Sep 17 00:00:00 2001 From: Jon Huhn Date: Thu, 26 Oct 2023 16:09:10 -0500 Subject: [PATCH] use different rg for vnet in custom vnet e2e test --- azure/scope/cluster.go | 4 ++-- templates/test/ci/cluster-template-prow-custom-vnet.yaml | 2 +- templates/test/ci/cluster-template-prow-private.yaml | 2 +- templates/test/ci/prow-custom-vnet/patches/custom-vnet.yaml | 2 +- templates/test/ci/prow-private/patches/vnet-peerings.yaml | 2 +- test/e2e/azure_privatecluster.go | 2 +- test/e2e/azure_test.go | 2 ++ test/e2e/common.go | 1 + 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/azure/scope/cluster.go b/azure/scope/cluster.go index d03f73e0b18..08c43b2294d 100644 --- a/azure/scope/cluster.go +++ b/azure/scope/cluster.go @@ -310,7 +310,7 @@ func (s *ClusterScope) RouteTableSpecs() []azure.ResourceSpecGetter { specs = append(specs, &routetables.RouteTableSpec{ Name: subnet.RouteTable.Name, Location: s.Location(), - ResourceGroup: s.ResourceGroup(), + ResourceGroup: s.Vnet().ResourceGroup, ClusterName: s.ClusterName(), AdditionalTags: s.AdditionalTags(), }) @@ -358,7 +358,7 @@ func (s *ClusterScope) NSGSpecs() []azure.ResourceSpecGetter { nsgspecs[i] = &securitygroups.NSGSpec{ Name: subnet.SecurityGroup.Name, SecurityRules: subnet.SecurityGroup.SecurityRules, - ResourceGroup: s.ResourceGroup(), + ResourceGroup: s.Vnet().ResourceGroup, Location: s.Location(), ClusterName: s.ClusterName(), AdditionalTags: s.AdditionalTags(), diff --git a/templates/test/ci/cluster-template-prow-custom-vnet.yaml b/templates/test/ci/cluster-template-prow-custom-vnet.yaml index 368e2c611d3..55a06a87790 100644 --- a/templates/test/ci/cluster-template-prow-custom-vnet.yaml +++ b/templates/test/ci/cluster-template-prow-custom-vnet.yaml @@ -48,7 +48,7 @@ spec: name: node-nsg vnet: name: ${AZURE_CUSTOM_VNET_NAME} - resourceGroup: ${AZURE_RESOURCE_GROUP} + resourceGroup: ${AZURE_CUSTOM_VNET_RESOURCE_GROUP} resourceGroup: ${AZURE_RESOURCE_GROUP:=${CLUSTER_NAME}} subscriptionID: ${AZURE_SUBSCRIPTION_ID} --- diff --git a/templates/test/ci/cluster-template-prow-private.yaml b/templates/test/ci/cluster-template-prow-private.yaml index 439830865b6..9d7e03c2fb7 100644 --- a/templates/test/ci/cluster-template-prow-private.yaml +++ b/templates/test/ci/cluster-template-prow-private.yaml @@ -72,7 +72,7 @@ spec: name: ${AZURE_VNET_NAME} peerings: - remoteVnetName: ${AZURE_CUSTOM_VNET_NAME} - resourceGroup: ${AZURE_RESOURCE_GROUP} + resourceGroup: ${AZURE_CUSTOM_VNET_RESOURCE_GROUP} resourceGroup: ${AZURE_RESOURCE_GROUP:=${CLUSTER_NAME}} subscriptionID: ${AZURE_SUBSCRIPTION_ID} --- diff --git a/templates/test/ci/prow-custom-vnet/patches/custom-vnet.yaml b/templates/test/ci/prow-custom-vnet/patches/custom-vnet.yaml index 7ab60e71a92..d265d8ef201 100644 --- a/templates/test/ci/prow-custom-vnet/patches/custom-vnet.yaml +++ b/templates/test/ci/prow-custom-vnet/patches/custom-vnet.yaml @@ -5,7 +5,7 @@ metadata: spec: networkSpec: vnet: - resourceGroup: ${AZURE_RESOURCE_GROUP} + resourceGroup: ${AZURE_CUSTOM_VNET_RESOURCE_GROUP} name: ${AZURE_CUSTOM_VNET_NAME} subnets: - name: ${AZURE_CUSTOM_VNET_NAME}-controlplane-subnet diff --git a/templates/test/ci/prow-private/patches/vnet-peerings.yaml b/templates/test/ci/prow-private/patches/vnet-peerings.yaml index 7eb9ff1c6ea..fc51c6a5d5e 100644 --- a/templates/test/ci/prow-private/patches/vnet-peerings.yaml +++ b/templates/test/ci/prow-private/patches/vnet-peerings.yaml @@ -15,7 +15,7 @@ spec: cidrBlocks: - ${AZURE_PRIVATE_VNET_CIDR} peerings: - - resourceGroup: ${AZURE_RESOURCE_GROUP} + - resourceGroup: ${AZURE_CUSTOM_VNET_RESOURCE_GROUP} remoteVnetName: ${AZURE_CUSTOM_VNET_NAME} subnets: - name: private-cp-subnet diff --git a/test/e2e/azure_privatecluster.go b/test/e2e/azure_privatecluster.go index ffe359cb939..e761d408f30 100644 --- a/test/e2e/azure_privatecluster.go +++ b/test/e2e/azure_privatecluster.go @@ -228,7 +228,7 @@ func SetupExistingVNet(ctx context.Context, vnetCidr string, cpSubnetCidrs, node routetableClient.Authorizer = authorizer By("creating a resource group") - groupName := os.Getenv(AzureResourceGroup) + groupName := os.Getenv(AzureCustomVnetResourceGroup) _, err = groupClient.CreateOrUpdate(ctx, groupName, resources.Group{ Location: ptr.To(os.Getenv(AzureLocation)), Tags: map[string]*string{ diff --git a/test/e2e/azure_test.go b/test/e2e/azure_test.go index 1625f26b851..1150bd5fb7e 100644 --- a/test/e2e/azure_test.go +++ b/test/e2e/azure_test.go @@ -135,6 +135,7 @@ var _ = Describe("Workload cluster creation", func() { } dumpSpecResourcesAndCleanup(ctx, cleanInput) Expect(os.Unsetenv(AzureResourceGroup)).To(Succeed()) + Expect(os.Unsetenv(AzureCustomVnetResourceGroup)).To(Succeed()) Expect(os.Unsetenv(AzureVNetName)).To(Succeed()) Expect(os.Unsetenv(ClusterIdentityName)).To(Succeed()) Expect(os.Unsetenv(ClusterIdentityNamespace)).To(Succeed()) @@ -155,6 +156,7 @@ var _ = Describe("Workload cluster creation", func() { clusterName = getClusterName(clusterNamePrefix, "public-custom-vnet") By("Creating a custom virtual network", func() { Expect(os.Setenv(AzureCustomVNetName, "custom-vnet")).To(Succeed()) + Expect(os.Setenv(AzureCustomVnetResourceGroup, clusterName+"-vnetrg")).To(Succeed()) additionalCleanup = SetupExistingVNet(ctx, "10.0.0.0/16", map[string]string{fmt.Sprintf("%s-controlplane-subnet", os.Getenv(AzureCustomVNetName)): "10.0.0.0/24"}, diff --git a/test/e2e/common.go b/test/e2e/common.go index a21ea10a57f..579d8ed0657 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -57,6 +57,7 @@ const ( AzureExtendedLocationType = "AZURE_EXTENDEDLOCATION_TYPE" AzureExtendedLocationName = "AZURE_EXTENDEDLOCATION_NAME" AzureResourceGroup = "AZURE_RESOURCE_GROUP" + AzureCustomVnetResourceGroup = "AZURE_CUSTOM_VNET_RESOURCE_GROUP" AzureVNetName = "AZURE_VNET_NAME" AzureCustomVNetName = "AZURE_CUSTOM_VNET_NAME" AzureInternalLBIP = "AZURE_INTERNAL_LB_IP"