From 9b828b16c4d9b08dbacebd201be31cbec4e0403a Mon Sep 17 00:00:00 2001 From: Matthew Bratschun <25390936+mbrat2005@users.noreply.github.com> Date: Mon, 6 Jan 2025 07:52:12 -0700 Subject: [PATCH] fix issue comparing empty lb backend pool list to NIC backend pool list (#131) --- .../AzureBasicLoadBalancerUpgrade.psd1 | 4 ++-- .../modules/ValidateScenario/ValidateScenario.psm1 | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/AzureBasicLoadBalancerUpgrade.psd1 b/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/AzureBasicLoadBalancerUpgrade.psd1 index 06535a12..fb795824 100644 --- a/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/AzureBasicLoadBalancerUpgrade.psd1 +++ b/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/AzureBasicLoadBalancerUpgrade.psd1 @@ -12,7 +12,7 @@ RootModule = 'AzureBasicLoadBalancerUpgrade' # Version number of this module. - ModuleVersion = '2.4.14' + ModuleVersion = '2.4.15' # Supported PSEditions # CompatiblePSEditions = @() @@ -107,7 +107,7 @@ # IconUri = '' # ReleaseNotes of this module - ReleaseNotes = 'Added support to retain AutomaticOSUpgrade setting when App Health extension is used instead of health probe.' + ReleaseNotes = 'Fix bug when comparing backend pool membership on empty LBs.' # Prerelease string of this module # Prerelease = 'beta' diff --git a/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/ValidateScenario/ValidateScenario.psm1 b/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/ValidateScenario/ValidateScenario.psm1 index 5950dc85..8afbab9b 100644 --- a/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/ValidateScenario/ValidateScenario.psm1 +++ b/AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/ValidateScenario/ValidateScenario.psm1 @@ -407,8 +407,16 @@ Function Test-SupportedMigrationScenario { ## compare nic backend pool memberships to basicLBBackendIds try { $nicBackendPoolMembershipsIds = @() + $nicBackendPoolMembershipsIds += $basicLBVMNics.IpConfigurations.loadBalancerBackendAddressPools.id | Sort-Object | Get-Unique - $differentMembership = Compare-Object $nicBackendPoolMembershipsIds $basicLBBackendIds + + If ([string]::IsNullOrEmpty($basicLBBackendIds)) { + # handle LBs with no backend pools + log -Message "[Test-SupportedMigrationScenario] No Basic Load Balancer backend pool IDs provided, so all NIC backend pool IDs must be on another LB (if any)." -Severity Debug + } + Else { + $differentMembership = Compare-Object -ReferenceObject $nicBackendPoolMembershipsIds -DifferenceObject $basicLBBackendIds + } } catch { $message = "[Test-SupportedMigrationScenario] Error comparing NIC backend pool memberships ($($nicBackendPoolMembershipsIds -join ',')) to basicLBBackendIds ($($basicLBBackendIds -join ',')). Error: $($_.Exception.Message)"