From 448fa359191aac9097a258ad09b182da784e95d4 Mon Sep 17 00:00:00 2001 From: Britania Rodriguez Reyes Date: Wed, 13 Nov 2024 13:28:14 -0800 Subject: [PATCH] VnetName check only on fleet-member-agent --- pkg/utils/cloudconfig/azure/config.go | 4 ++-- pkg/utils/cloudconfig/azure/config_test.go | 8 +++++--- pkg/utils/cloudconfig/azure/test/azure_valid_config.json | 1 + test/e2e/azure_valid_config.yaml | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/utils/cloudconfig/azure/config.go b/pkg/utils/cloudconfig/azure/config.go index d37f5bffe..b7e302ac0 100644 --- a/pkg/utils/cloudconfig/azure/config.go +++ b/pkg/utils/cloudconfig/azure/config.go @@ -88,8 +88,8 @@ func (cfg *CloudConfig) validate() error { return fmt.Errorf("resource group is empty") } - if cfg.VnetName == "" { - return fmt.Errorf("virtual network name is empty") + if cfg.UserAgent == "fleet-member-agent" && cfg.VnetName == "" { + return fmt.Errorf("vnet name is empty") } if cfg.VnetResourceGroup == "" { diff --git a/pkg/utils/cloudconfig/azure/config_test.go b/pkg/utils/cloudconfig/azure/config_test.go index 8c094a128..5f3da0f6c 100644 --- a/pkg/utils/cloudconfig/azure/config_test.go +++ b/pkg/utils/cloudconfig/azure/config_test.go @@ -136,7 +136,8 @@ func TestValidate(t *testing.T) { "VnetName empty": { config: &CloudConfig{ ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "c", + Cloud: "c", + UserAgent: "fleet-member-agent", }, AzureAuthConfig: azclient.AzureAuthConfig{ UseManagedIdentityExtension: true, @@ -559,8 +560,9 @@ func TestNewCloudConfigFromFile(t *testing.T) { filePath: "./test/azure_valid_config.json", wantConfig: &CloudConfig{ ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzurePublicCloud", - TenantID: "00000000-0000-0000-0000-000000000000", + Cloud: "AzurePublicCloud", + TenantID: "00000000-0000-0000-0000-000000000000", + UserAgent: "fleet-member-agent", }, AzureAuthConfig: azclient.AzureAuthConfig{ UseManagedIdentityExtension: true, diff --git a/pkg/utils/cloudconfig/azure/test/azure_valid_config.json b/pkg/utils/cloudconfig/azure/test/azure_valid_config.json index 4c938e78c..e9cd2a593 100644 --- a/pkg/utils/cloudconfig/azure/test/azure_valid_config.json +++ b/pkg/utils/cloudconfig/azure/test/azure_valid_config.json @@ -1,5 +1,6 @@ { "cloud": "AzurePublicCloud", + "userAgent": "fleet-member-agent", "tenantId": "00000000-0000-0000-0000-000000000000", "subscriptionId": "00000000-0000-0000-0000-000000000000", "useManagedIdentityExtension": true, diff --git a/test/e2e/azure_valid_config.yaml b/test/e2e/azure_valid_config.yaml index 38d7b5f2c..c16b45aa4 100644 --- a/test/e2e/azure_valid_config.yaml +++ b/test/e2e/azure_valid_config.yaml @@ -1,6 +1,7 @@ config: azureCloudConfig: cloud: "AzurePublicCloud" + userAgent: "fleet-member-agent" tenantId: "00000000-0000-0000-0000-000000000000" subscriptionId: "00000000-0000-0000-0000-000000000000" useManagedIdentityExtension: true