Skip to content

Commit

Permalink
Enable native support for Failover Cluster NC (#287)
Browse files Browse the repository at this point in the history
This pull request includes changes to enhance the functionality of the
SDN Diagnostics module, particularly for Service Fabric and Failover
Cluster configurations. The most significant changes are the addition of
new commands, modifications to existing commands, and the introduction
of new modules for different cluster configurations.

Additions and modifications to commands:

*
[`src/SdnDiagnostics.Helper.psm1`](diffhunk://#diff-c298d582fd8e12a03b0e7b1dc9c562c58cc978d2e9044757d73f1a00f840c6b5L72-R78):
Removed 'Test-SdnKnownIssue' and added new commands to the
`$networkControllerParamCommands` array.
*
[`src/modules/SdnDiag.Common/private/Export-RegistryKeyConfigDetails.ps1`](diffhunk://#diff-2bc0c28b695611157ad4de8a232e841315642b136775d2bf32f8f74acd670b19L18-R21):
Changed the logging level and improved the registry key path
enumeration. Added a security measure to redact the AESKey for cluster
network controller registry keys.
[[1]](diffhunk://#diff-2bc0c28b695611157ad4de8a232e841315642b136775d2bf32f8f74acd670b19L18-R21)
[[2]](diffhunk://#diff-2bc0c28b695611157ad4de8a232e841315642b136775d2bf32f8f74acd670b19R30-R34)
*
[`src/modules/SdnDiag.Common/private/Get-CommonConfigState.ps1`](diffhunk://#diff-835b08b8e1c0bce0a59f0c589152e1a7e9a6e24bfb443ad00669c63f3924d881L58-R58):
Modified the `Get-NetAdapterAdvancedProperty` command to handle errors
according to the `$ErrorActionPreference` variable.
*
[`src/modules/SdnDiag.Common/public/Repair-SdnDiagnosticsScheduledTask.ps1`](diffhunk://#diff-a69fd2713e1d24fef7f12349ac339925ef11a4e9a80269f3c5abe39f02632788R10-R18):
Added a switch statement to handle different `ClusterConfigType` values.
*
[`src/modules/SdnDiag.Health/private/Test-NcUrlNameResolution.ps1`](diffhunk://#diff-53875d037e2095362d1f4d2ebce09ba56c67e194efbb31a4155b7fc6a28b3a43L30-R32):
Changed the `Get-SdnNetworkController` command to
`Get-SdnNetworkControllerSF`.
*
[`src/modules/SdnDiag.Health/public/Debug-SdnFabricInfrastructure.ps1`](diffhunk://#diff-324c08d6d20cb9d37d1a5b9756303f40024eb3d5c4008d8b210c8e7295ea1151R47-R50):
Added a condition to throw an exception if the `ClusterConfigType` is
not 'ServiceFabric'.

New modules for different cluster configurations:

*
[`src/modules/SdnDiag.NetworkController.FC/SdnDiag.NetworkController.FC.Config.psd1`](diffhunk://#diff-656db7b7942a5c8bebb655094f4e112758a27267910335e9c06d6575c280b295R1-R70):
Created a new configuration file for the NetworkControllerFC module.
*
[`src/modules/SdnDiag.NetworkController.FC/SdnDiag.NetworkController.FC.psm1`](diffhunk://#diff-141e8a7963d2aa6f51b5851094e11e0287b3c8793904094c9840ed25816c2a2aR1-R13):
Created a new module file for the NetworkControllerFC module.
*
[`src/modules/SdnDiag.NetworkController.FC/private/Get-NetworkControllerFCConfigState.ps1`](diffhunk://#diff-a101ed5e85ead9ca9371fad33a94311da92c52d3812fd2f1b23fbb6ca7af6ee9R1-R43):
Created a new function to output a set of configuration state files for
the network controller role.
*
[`src/modules/SdnDiag.NetworkController.FC/private/Get-SdnClusterName.ps1`](diffhunk://#diff-5c8dc2849956c598e30fbe1008e22689493be806df2cf5f403958cdb2e86d99cR1-R27):
Created a new function to get the cluster name.
*
[`src/modules/SdnDiag.NetworkController.FC/private/Get-SdnNetworkControllerFC.ps1`](diffhunk://#diff-a2156b35c839b8eaf62a5ada1c1a34d7bd04c2fdf44f317d4231ef9162ec610fR1-R45):
Created a new function to get network controller application settings.
*
[`src/modules/SdnDiag.NetworkController.FC/private/Get-SdnNetworkControllerFCClusterInfo.ps1`](diffhunk://#diff-45acf2c028d64150f072773cb338f9ba97cec5a221c3679a15546e47281ce796R1-R63):
Created a new function to gather the Network Controller cluster wide
info.
*
[`src/modules/SdnDiag.NetworkController.FC/private/Get-SdnNetworkControllerFCNode.ps1`](diffhunk://#diff-07e5e85f95431cfe04c99dc1bc32352f6850f798d97dcac0cb582d4d193b47e0R1-R85):
Created a new function to return a list of servers from network
controller.
*
[`src/modules/SdnDiag.NetworkController.SF/SdnDiag.NetworkController.SF.Config.psd1`](diffhunk://#diff-fcf4a3d34ad27665c7140f0762b97036cdc06820518e3ef8d5cf04ea80279c22R1-R34):
Created a new configuration file for the NetworkControllerSF module.

File additions:

*
[`src/SdnDiagnostics.psd1`](diffhunk://#diff-17aaaa968cc894449c79b449c228b28d8a8990bde4000e59bcf24d8189671ee1R38-R39):
Added new module files to the list of files.
  • Loading branch information
arudell committed Jul 15, 2024
1 parent 1186100 commit b061fd4
Show file tree
Hide file tree
Showing 76 changed files with 2,035 additions and 1,187 deletions.
5 changes: 4 additions & 1 deletion src/SdnDiagnostics.Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ Register-ArgumentCompleter -CommandName $fabricNodeParamCommands -ParameterName

$networkControllerParamCommands = (
'Debug-SdnFabricInfrastructure',
'Test-SdnKnownIssue',
'Start-SdnDataCollection',
'Get-SdnNetworkController',
'Get-SdnNetworkControllerNode',
'Get-SdnNetworkControllerFC',
'Get-SdnNetworkControllerFCNode',
'Get-SdnNetworkControllerSF',
'Get-SdnNetworkControllerSFNode',
'Get-SdnNetworkControllerClusterInfo',
'Get-SdnNetworkControllerState',
'Get-SdnServiceFabricApplicationHealth',
Expand Down
2 changes: 2 additions & 0 deletions src/SdnDiagnostics.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
'modules\SdnDiag.Health\SdnDiag.Health.psm1'
'modules\SdnDiag.LoadBalancerMux\SdnDiag.LoadBalancerMux.psm1'
'modules\SdnDiag.NetworkController\SdnDiag.NetworkController.psm1'
'modules\SdnDiag.NetworkController.FC\SdnDiag.NetworkController.FC.psm1'
'modules\SdnDiag.NetworkController.SF\SdnDiag.NetworkController.SF.psm1'
'modules\SdnDiag.Server\SdnDiag.Server.psm1'
'modules\SdnDiag.Utilities\SdnDiag.Utilities.psm1'
'modules\Test-SdnExpressBgp.psm1'
Expand Down
972 changes: 971 additions & 1 deletion src/SdnDiagnostics.psm1

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function Export-RegistryKeyConfigDetails {
}

foreach($regKeyPath in $Path){
"Enumerating the registry key paths for {0}" -f $regkeyPath | Trace-Output -Level:Verbose
"Enumerating the registry key paths for {0}" -f $regkeyPath | Trace-Output

$regKeyDirectories = @()
$regKeyDirectories += Get-ChildItem -Path $regKeyPath -ErrorAction SilentlyContinue
$regKeyDirectories += Get-Item -Path $regKeyPath -ErrorAction SilentlyContinue
$regKeyDirectories += Get-ChildItem -Path $regKeyPath -Recurse -ErrorAction SilentlyContinue
$regKeyDirectories = $regKeyDirectories | Sort-Object -Unique

Expand All @@ -27,6 +27,11 @@ function Export-RegistryKeyConfigDetails {
"Scanning {0}" -f $obj.PsPath | Trace-Output -Level:Verbose
try {
$properties = Get-ItemProperty -Path $obj.PSPath -ErrorAction Stop

# check to see if we are lookiing at cluster network controller registry key, if so, then redact the AESKey
if ($obj.PSPath -ilike "*Cluster\NetworkController*") {
$properties.'GlobalConfiguration.AESKey' = "removed_for_security_reasons"
}
}
catch {
"Unable to return results from {0}`n`t{1}" -f $obj.PSPath, $_.Exception | Trace-Output -Level:Warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Get-CommonConfigState {
$netAdapter | Export-ObjectToFile -FilePath $OutputDirectory.FullName -Name 'Get-NetAdapter' -FileType json
$netAdapter | ForEach-Object {
$prefix = $_.Name.ToString().Replace(' ','_').Trim()
$_ | Get-NetAdapterAdvancedProperty | Export-ObjectToFile -FilePath $netAdapterRootDir.FullName -Prefix $prefix -Name 'Get-NetAdapterAdvancedProperty' -FileType json
$_ | Get-NetAdapterAdvancedProperty -ErrorAction $ErrorActionPreference | Export-ObjectToFile -FilePath $netAdapterRootDir.FullName -Prefix $prefix -Name 'Get-NetAdapterAdvancedProperty' -FileType json
$_ | Get-NetAdapterBinding | Export-ObjectToFile -FilePath $netAdapterRootDir.FullName -Prefix $prefix -Name 'Get-NetAdapterBinding' -FileType json
$_ | Get-NetAdapterChecksumOffload -ErrorAction $ErrorActionPreference | Export-ObjectToFile -FilePath $netAdapterRootDir.FullName -Prefix $prefix -Name 'Get-NetAdapterChecksumOffload' -FileType json
$_ | Get-NetAdapterHardwareInfo -ErrorAction $ErrorActionPreference | Export-ObjectToFile -FilePath $netAdapterRootDir.FullName -Prefix $prefix -Name 'Get-NetAdapterHardwareInfo' -FileType json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ function Repair-SdnDiagnosticsScheduledTask {
[CmdletBinding()]
param()

$taskName = "SDN Diagnostics Task"
switch ($Global:SdnDiagnostics.EnvironmentInfo.ClusterConfigType) {
'FailoverCluster' {
$taskName = "FcDiagnostics"
}
'ServiceFabric' {
$taskName = "SDN Diagnostics Task"
}
}

try {
$isLoggingEnabled = Get-ItemPropertyValue -Path "HKLM:\Software\Microsoft\NetworkController\Sdn\Diagnostics\Parameters" -Name 'IsLoggingEnabled'
if (-NOT $isLoggingEnabled ) {
Expand Down
477 changes: 0 additions & 477 deletions src/modules/SdnDiag.Common/public/Start-SdnDataCollection.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function Test-NcUrlNameResolution {
return $sdnHealthObject
}

$networkController = Get-SdnNetworkController -NetworkController $SdnEnvironmentObject.ComputerName[0] -Credential $Credential
$networkController = Get-SdnNetworkControllerSF -NetworkController $SdnEnvironmentObject.ComputerName[0] -Credential $Credential
if ($null -eq $networkController) {
"Unable to retrieve results from Get-SdnNetworkController" | Trace-Output -Level:Warning
"Unable to retrieve results from Get-SdnNetworkControllerSF" | Trace-Output -Level:Warning
return $sdnHealthObject
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function Debug-SdnFabricInfrastructure {
$NcRestCredential = [System.Management.Automation.PSCredential]::Empty
)

if ($Global:SdnDiagnostics.EnvironmentInfo.ClusterConfigType -ine 'ServiceFabric') {
throw New-Object System.NotSupportedException("This function is only supported on Service Fabric clusters.")
}

$script:SdnDiagnostics_Health.Cache = $null
$aggregateHealthReport = @()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ function Start-SdnMuxCertificateRotation {

[System.IO.FileSystemInfo]$CertPath = Get-Item -Path $CertPath -ErrorAction Stop
$sdnFabricDetails = Get-SdnInfrastructureInfo -NetworkController $NetworkController -Credential $Credential -NcRestCredential $NcRestCredential -ErrorAction Stop
if ($Global:SdnDiagnostics.EnvironmentInfo.ClusterConfigType -ine 'ServiceFabric') {
throw New-Object System.NotSupportedException("This function is only supported on Service Fabric clusters.")
}

$loadBalancerMuxes = Get-SdnLoadBalancerMux -NcUri $sdnFabricDetails.NcUrl -Credential $NcRestCredential -ErrorAction Stop

# before we proceed with anything else, we want to make sure that all the Network Controllers and MUXes within the SDN fabric are running the current version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

@{
Name = "NetworkControllerFC"
WindowsFeature = @(
"NetworkController"
)
RequiredModules = @(
"NetworkController"
)
Properties = @{
CommonPaths = @{}
EventLogProviders = @(
'Microsoft-Windows-FailoverClustering*',
'Microsoft-Windows-FailoverClustering-Manager*',
'NetworkControllerFc'
)
RegKeyPaths = @(
'HKLM:\Cluster\NetworkController'
)
Services = @{
SDNApiService = @{
Properties = @{
DisplayName = "SDNApiService"
}
}
SDNControllerService = @{
Properties = @{
DisplayName = "SDNControllerService"
}
}
SDNFirewallService = @{
Properties = @{
DisplayName = "SDNFirewallService"
}
}
SDNFnmService = @{
Properties = @{
DisplayName = "SDNFnmService"
}
}
SDNGatewayManager = @{
Properties = @{
DisplayName = "SDNGatewayManager"
}
}
SDNHelperService = @{
Properties = @{
DisplayName = "SDNHelperService"
}
}
SDNServiceInsertion = @{
Properties = @{
DisplayName = "SDNServiceInsertion"
}
}
SDNSlbManagerService = @{
Properties = @{
DisplayName = "SDNSlbManagerService"
}
}
SDNVSwitchService = @{
Properties = @{
DisplayName = "SDNVSwitchService"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

Import-Module $PSScriptRoot\..\SdnDiag.Common\SdnDiag.Common.psm1
Import-Module $PSScriptRoot\..\SdnDiag.Utilities\SdnDiag.Utilities.psm1

# create local variable to store configuration data
$configurationData = Import-PowerShellDataFile -Path $PSScriptRoot\SdnDiag.NetworkController.FC.Config.psd1
New-Variable -Name 'SdnDiagnostics_NC_FC' -Scope 'Script' -Force -Value @{
Config = $configurationData
}

##### FUNCTIONS AUTO-POPULATED BELOW THIS LINE DURING BUILD #####
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function Get-NetworkControllerFCConfigState {
<#
.SYNOPSIS
Outputs a set of configuration state files for the network controller role.
.PARAMETER OutputDirectory
Specifies a specific path and folder in which to save the files.
.EXAMPLE
PS> Get-NetworkControllerFCConfigState -OutputDirectory "C:\Temp\CSS_SDN"
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[System.IO.FileInfo]$OutputDirectory
)

$currentErrorActionPreference = $ErrorActionPreference
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'SilentlyContinue'

try {
$config = Get-SdnModuleConfiguration -Role 'NetworkController_FC'
[string]$outDir = Join-Path -Path $OutputDirectory.FullName -ChildPath "ConfigState"
[string]$regDir = Join-Path -Path $OutputDirectory.FullName -ChildPath "Registry"

if (-NOT (Initialize-DataCollection -Role $config.Name -FilePath $outDir -MinimumMB 10)) {
"Unable to initialize environment for data collection for {0}" -f $config.Name | Trace-Output -Level:Error
return
}

"Collect configuration state details for role {0}" -f $config.Name | Trace-Output

# collect registry configuration information
Export-RegistryKeyConfigDetails -Path $config.properties.regKeyPaths -OutputDirectory $regDir
}
catch {
$_ | Trace-Exception
$_ | Write-Error
}

$ProgressPreference = 'Continue'
$ErrorActionPreference = $currentErrorActionPreference
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function Get-SdnClusterName {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[System.String]$NetworkController,

[Parameter(Mandatory = $false)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty
)

if (Test-ComputerNameIsLocal -ComputerName $NetworkController) {
$clusterName = Get-Cluster | Select-Object -ExpandProperty Name
}
else {
if ($null -ieq $Credential -or $Credential -eq [System.Management.Automation.PSCredential]::Empty) {
$clusterName = Invoke-PSRemoteCommand -ComputerName $NetworkController -ScriptBlock { Get-Cluster } | Select-Object -ExpandProperty Name
}
else {
$clusterName = Invoke-PSRemoteCommand -ComputerName $NetworkController -ScriptBlock { Get-Cluster } -Credential $Credential | Select-Object -ExpandProperty Name
}
}

"Cluster Name: $clusterName" | Trace-Output -Level:Verbose
return $clusterName
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function Get-SdnNetworkControllerFC {
<#
.SYNOPSIS
Gets network controller application settings from the network controller node leveraging Failover Cluster.
.PARAMETER NetworkController
Specifies the name or IP address of the network controller node on which this cmdlet operates. The parameter is optional if running on network controller node.
.PARAMETER Credential
Specifies a user account that has permission to perform this action. The default is the current user.
.EXAMPLE
PS> Get-SdnNetworkControllerFC
.EXAMPLE
PS> Get-SdnNetworkControllerFC -NetworkController 'NC01' -Credential (Get-Credential)
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[System.String]$NetworkController = $env:COMPUTERNAME,

[Parameter(Mandatory = $false)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty
)

$networkControllerSB = {
Get-NetworkControllerOnFailoverCluster
}

try {
if (Test-ComputerNameIsLocal -ComputerName $NetworkController) {
Confirm-IsNetworkController
$result = Invoke-Command -ScriptBlock $networkControllerSB
}
else {
$result = Invoke-PSRemoteCommand -ComputerName $NetworkController -ScriptBlock $networkControllerSB -Credential $Credential
}

return $result
}
catch {
$_ | Trace-Exception
$_ | Write-Error
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
function Get-SdnNetworkControllerFCClusterInfo {
<#
.SYNOPSIS
Gather the Network Controller cluster wide info from one of the Network Controller
.PARAMETER NetworkController
Specifies the name of the network controller node on which this cmdlet operates.
.PARAMETER Credential
Specifies a user account that has permission to perform this action. The default is the current user.
.PARAMETER OutputDirectory
Directory location to save results. It will create a new sub-folder called NetworkControllerClusterInfo_FC that the files will be saved to
.EXAMPLE
PS> Get-SdnNetworkControllerFCClusterInfo
.EXAMPLE
PS> Get-SdnNetworkControllerFCClusterInfo -NetworkController 'NC01' -Credential (Get-Credential)
#>

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[System.String]$NetworkController,

[Parameter(Mandatory = $false)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty,

[Parameter(Mandatory = $true)]
[System.IO.FileInfo]$OutputDirectory
)

$currentErrorActionPreference = $ErrorActionPreference
$ProgressPreference = 'SilentlyContinue'
$ErrorActionPreference = 'Ignore'

try {
$outputDir = Join-Path -Path $OutputDirectory.FullName -ChildPath 'NetworkControllerClusterInfo_FC'
if (!(Test-Path -Path $outputDir -PathType Container)) {
$null = New-Item -Path $outputDir -ItemType Directory -Force
}

$clusterName = $Global:SdnDiagnostics.EnvironmentInfo.FailoverClusterConfig.Name
if ($null -ieq $clusterName) {
$clusterName = Get-SdnClusterName -NetworkController $NetworkController -Credential $Credential -ErrorAction Stop
}

Get-Cluster -Name $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-Cluster' -FileType json
Get-ClusterFaultDomain -CimSession $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterFaultDomain' -FileType json
Get-ClusterNode -Cluster $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterNode' -FileType json
Get-ClusterGroup -Cluster $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterGroup' -FileType json
Get-ClusterNetwork -Cluster $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterNetwork' -FileType json
Get-ClusterNetworkInterface -Cluster $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterNetworkInterface' -FileType json
Get-ClusterResource -Cluster $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterResource' -FileType json
Get-ClusterResourceType -Cluster $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterResourceType' -FileType txt -Format Table
Get-ClusterSharedVolume -Cluster $clusterName | Export-ObjectToFile -FilePath $outputDir -Name 'Get-ClusterSharedVolume' -FileType json
}
catch {
$_ | Trace-Exception
$_ | Write-Error
}

$ProgressPreference = 'Continue'
$ErrorActionPreference = $currentErrorActionPreference
}
Loading

0 comments on commit b061fd4

Please sign in to comment.