Skip to content

Commit 19267e1

Browse files
authored
Show Arc error on 20H2 only if Arc intent is specified (Azure#15550)
* Show warning only if Arc intent is specified Show warning only if Arc intent is specified on 20H2 OS. * Updated Change Log Updated Change Log on Arc error update logic
1 parent e074950 commit 19267e1

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

src/StackHCI/Az.StackHCI.psm1

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,43 +2367,49 @@ param(
23672367

23682368
if($ArcCmdletsAbsentOnNodes.Count -ge 1)
23692369
{
2370-
$ArcCmdletsNotAvailableErrorMsg = $ArcCmdletsNotAvailableError -f ($ArcCmdletsAbsentOnNodes -join ",")
2371-
Write-Error -Message $ArcCmdletsNotAvailableErrorMsg
2372-
$registrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyResult -Value [OperationStatus]::Failed
2373-
Write-Output $registrationOutput
2374-
return
2375-
}
2376-
2377-
$arcResourceId = $resourceId + $HCIArcInstanceName
2378-
$arcResourceGroupName = $ResourceGroupName
2379-
2380-
$arcres = Get-AzResource -ResourceId $arcResourceId -ApiVersion $HCIArcAPIVersion -ErrorAction Ignore
2381-
2382-
if($arcres -eq $null)
2383-
{
2384-
$arcres = New-AzResource -ResourceId $arcResourceId -ApiVersion $HCIArcAPIVersion -Force
2385-
}
2386-
else
2387-
{
2388-
if ($arcres.Properties.aggregateState -eq $ArcSettingsDisableInProgressState)
2370+
# Show Arc error on 20h2 only if -EnableAzureArcServer:$true is explicity passed by user
2371+
if($PSBoundParameters.ContainsKey('EnableAzureArcServer'))
23892372
{
2390-
Write-Error -Message $ArcRegistrationDisableInProgressError
2373+
$ArcCmdletsNotAvailableErrorMsg = $ArcCmdletsNotAvailableError -f ($ArcCmdletsAbsentOnNodes -join ",")
2374+
Write-Error -Message $ArcCmdletsNotAvailableErrorMsg
23912375
$registrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyResult -Value [OperationStatus]::Failed
23922376
Write-Output $registrationOutput
23932377
return
23942378
}
23952379
}
2380+
else
2381+
{
2382+
$arcResourceId = $resourceId + $HCIArcInstanceName
2383+
$arcResourceGroupName = $ResourceGroupName
23962384

2397-
$arcResourceGroupName = $arcres.Properties.arcInstanceResourceGroup
2398-
$arcAppName = $ResourceName + ".arc"
2385+
$arcres = Get-AzResource -ResourceId $arcResourceId -ApiVersion $HCIArcAPIVersion -ErrorAction Ignore
23992386

2400-
Write-Verbose "Register-AzStackHCI: Arc registration triggered. ArcResourceGroupName: $arcResourceGroupName"
2401-
$arcResult = Register-ArcForServers -IsManagementNode $IsManagementNode -ComputerName $ComputerName -Credential $Credential -TenantId $TenantId -SubscriptionId $SubscriptionId -ResourceGroup $arcResourceGroupName -Region $Region -AppName $arcAppName -ClusterDNSSuffix $clusterDNSSuffix -IsWAC:$IsWAC
2387+
if($arcres -eq $null)
2388+
{
2389+
$arcres = New-AzResource -ResourceId $arcResourceId -ApiVersion $HCIArcAPIVersion -Force
2390+
}
2391+
else
2392+
{
2393+
if ($arcres.Properties.aggregateState -eq $ArcSettingsDisableInProgressState)
2394+
{
2395+
Write-Error -Message $ArcRegistrationDisableInProgressError
2396+
$registrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyResult -Value [OperationStatus]::Failed
2397+
Write-Output $registrationOutput
2398+
return
2399+
}
2400+
}
24022401

2403-
if($arcResult -ne [ErrorDetail]::Success)
2404-
{
2405-
$operationStatus = [OperationStatus]::RegisterSucceededButArcFailed
2406-
$registrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyErrorDetail -Value $arcResult
2402+
$arcResourceGroupName = $arcres.Properties.arcInstanceResourceGroup
2403+
$arcAppName = $ResourceName + ".arc"
2404+
2405+
Write-Verbose "Register-AzStackHCI: Arc registration triggered. ArcResourceGroupName: $arcResourceGroupName"
2406+
$arcResult = Register-ArcForServers -IsManagementNode $IsManagementNode -ComputerName $ComputerName -Credential $Credential -TenantId $TenantId -SubscriptionId $SubscriptionId -ResourceGroup $arcResourceGroupName -Region $Region -AppName $arcAppName -ClusterDNSSuffix $clusterDNSSuffix -IsWAC:$IsWAC
2407+
2408+
if($arcResult -ne [ErrorDetail]::Success)
2409+
{
2410+
$operationStatus = [OperationStatus]::RegisterSucceededButArcFailed
2411+
$registrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyErrorDetail -Value $arcResult
2412+
}
24072413
}
24082414
}
24092415

src/StackHCI/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Made changes to show Arc not supported error on 20H2 only if intent to enable Arc is specified by user.
22+
- Show Arc not supported error on 20H2 only if -EnableAzureArc:$true is specified in registration Cmdlet.
2123

2224
## Version 0.8.0
2325
* Made changes to use FQDN while connecting to nodes and the cluster.

0 commit comments

Comments
 (0)