Skip to content

Commit 1219117

Browse files
authored
Fix move vmss backup to prep (#105)
* added migration graph query * Fix skipMigrateNATPoolsToNATRules parameter not found in VMSS upgrades * fix blank std lb name verification * move VMSS backup to prep stage
1 parent fd97e0d commit 1219117

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/AzureBasicLoadBalancerUpgrade.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'AzureBasicLoadBalancerUpgrade'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.4.2'
15+
ModuleVersion = '2.4.3'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -107,7 +107,7 @@
107107
# IconUri = ''
108108

109109
# ReleaseNotes of this module
110-
ReleaseNotes = 'Fix skipMigrateNATPoolsToNATRules parameter not found in VMSS upgrades'
110+
ReleaseNotes = 'Fix missed VMSS backups in -multiLBConfig mode'
111111

112112
# Prerelease string of this module
113113
# Prerelease = ''

AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/ScenariosMigration/ScenariosMigration.psm1

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ function PublicLBMigrationVmss {
112112
Write-Progress -Status "Public Load Balancer with VMSS backend detected. Initiating Public Load Balancer Migration" -PercentComplete 0 @progressParams
113113
log -Message "[PublicLBMigration] Public Load Balancer with VMSS backend found. Initiating Public Load Balancer Migration"
114114

115-
# Creating a vmss object before it gets changed as a reference for the backend pool migration
116-
Write-Progress -Status "Backing up VMSS" -ParentId 4 @progressParams
117-
118-
# Backup VMSS Configurations
119-
BackupVmss -BasicLoadBalancer $BasicLoadBalancer -RecoveryBackupPath $RecoveryBackupPath
120-
121115
# Remove Public IP Configurations from VMSS
122116
Write-Progress -Status "Removing Public IP Configurations from VMSS" -PercentComplete ((1 / 14) * 100) @progressParams
123117
RemoveVmssPublicIPConfig -BasicLoadBalancer $BasicLoadBalancer
@@ -201,13 +195,6 @@ function InternalLBMigrationVmss {
201195

202196
log -Message "[InternalLBMigration] Internal Load Balancer with VMSS backend detected. Initiating Internal Load Balancer Migration"
203197

204-
# Creating a vmss object before it gets changed as a reference for the backend pool migration
205-
Write-Progress -Status "Backing up VMSS" -PercentComplete ((1/14) * 100) @progressParams
206-
207-
# Backup VMSS Configurations
208-
Write-Progress -Status "Backing up VMSS Configurations" -PercentComplete ((2/14) * 100) @progressParams
209-
BackupVmss -BasicLoadBalancer $BasicLoadBalancer -RecoveryBackupPath $RecoveryBackupPath
210-
211198
# Remove Public IP Configurations from VMSS
212199
Write-Progress -Status "Removing Public IP Configurations from VMSS" -PercentComplete ((3/14) * 100) @progressParams
213200
RemoveVmssPublicIPConfig -BasicLoadBalancer $BasicLoadBalancer
@@ -961,11 +948,29 @@ function LBMigrationPrep {
961948
Activity = "Preparing load balancer '$($migrationConfig.BasicLoadBalancer.Name)' for migration"
962949
Parent = 3
963950
}
964-
Write-Progress -Status "Preparing load balancer '$($migrationConfig.BasicLoadBalancer.Name)' for migration" -PercentComplete ((1/4) * 100) @progressParams
951+
Write-Progress -Status "Preparing load balancer '$($migrationConfig.BasicLoadBalancer.Name)' for migration" -PercentComplete ((1/5) * 100) @progressParams
952+
953+
try {
954+
$errorActionPreference = 'Stop'
965955

966-
# Backup Basic Load Balancer Configurations
967-
Write-Progress -Status "Backing up Basic Load Balancer Configurations" -PercentComplete ((2/4) * 100) @progressParams
968-
BackupBasicLoadBalancer -BasicLoadBalancer $migrationConfig.BasicLoadBalancer -RecoveryBackupPath $RecoveryBackupPath
956+
# Backup Basic Load Balancer Configurations
957+
Write-Progress -Status "Backing up Basic Load Balancer Configurations" -PercentComplete ((2/5) * 100) @progressParams
958+
BackupBasicLoadBalancer -BasicLoadBalancer $migrationConfig.BasicLoadBalancer -RecoveryBackupPath $RecoveryBackupPath
959+
960+
# Backup VMSS Configurations
961+
# TO-DO will create a VMSS backup for each LB of the same VMSS but since -multiLBConfig is not restricted to shared backends, there may be different VMSSes anyway
962+
if ($migrationConfig.scenario.backendType -eq 'VMSS') {
963+
Write-Progress -Status "Backing up VMSS Configurations" -PercentComplete ((3/5) * 100) @progressParams
964+
BackupVmss -BasicLoadBalancer $migrationConfig.BasicLoadBalancer -RecoveryBackupPath $RecoveryBackupPath
965+
}
966+
}
967+
catch {
968+
log -message "[LBMigrationPrep] Failed backup preparation step for '$($migrationConfig.BasicLoadBalancer.Name)'"
969+
throw $_
970+
}
971+
}
972+
973+
ForEach ($migrationConfig in $migrationConfigs) {
969974

970975
# get a reference copy of the vmss prior to modifying it
971976
If ($migrationConfig.scenario.backendType -eq 'VMSS') {
@@ -974,12 +979,12 @@ function LBMigrationPrep {
974979

975980
If ($migrationConfig.scenario.ExternalOrInternal -eq 'External') {
976981
# Migrate public IP addresses on Basic LB to static (if dynamic)
977-
Write-Progress -Status "Migrating public IP addresses on Basic LB to static (if dynamic)" -PercentComplete ((3/4) * 100) @progressParams
982+
Write-Progress -Status "Migrating public IP addresses on Basic LB to static (if dynamic)" -PercentComplete ((4/5) * 100) @progressParams
978983
PublicIPToStatic -BasicLoadBalancer $migrationConfig.BasicLoadBalancer
979984
}
980985

981986
# Deletion of Basic Load Balancer and Delete Basic Load Balancer
982-
Write-Progress -Status "Deletion of Basic Load Balancer and Delete Basic Load Balancer" -PercentComplete ((4/4) * 100) -Completed @progressParams
987+
Write-Progress -Status "Deletion of Basic Load Balancer and Delete Basic Load Balancer" -PercentComplete ((5/5) * 100) -Completed @progressParams
983988
RemoveBasicLoadBalancer -BasicLoadBalancer $migrationConfig.BasicLoadBalancer -BackendType $migrationConfig.scenario.backendType
984989

985990
log -message "[LBMigrationPrep] Completed preparing load balancer '$($migrationConfig.BasicLoadBalancer.Name)' for migration"

AzureBasicLoadBalancerUpgrade/module/AzureBasicLoadBalancerUpgrade/modules/Start-AzBasicLoadBalancerUpgrade/Start-AzBasicLoadBalancerUpgrade.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ function Start-AzBasicLoadBalancerUpgrade {
293293
$StdLoadBalancerName = $LBConfig.standardLoadBalancerName
294294
}
295295
else {
296-
$LBConfig.standardLoadBalancerName = $BasicLoadBalancer.Name
297-
$StdLoadBalancerName = $BasicLoadBalancer.Name
296+
$LBConfig.standardLoadBalancerName = $LBConfig.basicLoadBalancer.Name
297+
$StdLoadBalancerName = $LBConfig.basicLoadBalancer.Name
298298
}
299299

300300
$BasicLoadBalancer = $LBConfig.basicLoadBalancer
@@ -325,7 +325,7 @@ function Start-AzBasicLoadBalancerUpgrade {
325325
Write-Progress -Activity "Preparing for Migration" -Status "Preparing for Migration" -Id 3 -PercentComplete 0
326326
log -Message "[Start-AzBasicLoadBalancerUpgrade] Preparing for migration by backing up and deleteing the basic LB(s)"
327327
$migrationConfigs = LBMigrationPrep -migrationConfigs $migrationConfigs -RecoveryBackupPath $RecoveryBackupPath
328-
Write-Progress -Activity "Preparing for Migration" -Status "Preparing for Migration" -Completed -Id 3
328+
Write-Progress -Activity "Preparing for Migration" -Status "Completed preparing for migration" -Completed -Id 3
329329

330330
# initiate the migration of each load balancer in the migration config array
331331
Write-Progress -Activity "Starting Migration" -Status "Starting Migration" -Id 4

0 commit comments

Comments
 (0)