Fixing logic in detecting storage when storage is located on CSV (#348)
# Description Summary of changes: SDNDiagnostics checks for storage space when collecting logs. In HLK we always use a CSV. Module incorrectly checks c: for space. This fails on some HLK customers, who have insufficient storage space on c drive. # Change type - [X ] Bug fix (non-breaking change) - [ ] Code style update (formatting, local variables) - [ ] New Feature (non-breaking change that adds new functionality without impacting existing) - [ ] Breaking change (fix or feature that may cause functionality impact) - [ ] Other # Checklist: - [ ] My code follows the style and contribution guidelines of this project. - [ ] I have tested and validated my code changes.
This commit is contained in:
Родитель
6698df2375
Коммит
c829af0d08
|
@ -3,7 +3,7 @@ function Confirm-DiskSpace {
|
|||
param (
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'GB')]
|
||||
[Parameter(Mandatory = $false, ParameterSetName = 'MB')]
|
||||
[System.Char]$DriveLetter,
|
||||
[System.String]$FilePath,
|
||||
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'GB')]
|
||||
$MinimumGB,
|
||||
|
@ -12,6 +12,30 @@ function Confirm-DiskSpace {
|
|||
$MinimumMB
|
||||
)
|
||||
|
||||
# try cluster first, then local machine
|
||||
try
|
||||
{
|
||||
|
||||
$csvs = Get-ClusterSharedVolume | Select-Object SharedVolumeInfo
|
||||
if ($null -ne $csvs) {
|
||||
foreach($csv in $csvs)
|
||||
{
|
||||
if(-not [string]::IsNullOrEmpty(($csv.SharedVolumeInfo.FriendlyVolumeName)) -and `
|
||||
$null -ne $csv.SharedVolumeInfo.Partition -and `
|
||||
$FilePath.StartsWith($csv.SharedVolumeInfo.FriendlyVolumeName, [System.StringComparison]::OrdinalIgnoreCase) -and `
|
||||
(($csv.SharedVolumeInfo.Partition.FreeSpace/1GB -gt $MinimumGB) -and ($csv.SharedVolumeInfo.Partition.FreeSpace/1MB -gt $MinimumMB)))
|
||||
{
|
||||
"Required: {0} GB | Available: {1} GB" -f ([float]$MinimumGB).ToString(), $($csv.SharedVolumeInfo.Partition.FreeSpace/1GB) | Trace-Output -Level:Verbose
|
||||
return $true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
[System.Char]$driveLetter = (Split-Path -Path $FilePath -Qualifier).Replace(':','')
|
||||
|
||||
$drive = Get-PSDrive $DriveLetter -ErrorAction Stop
|
||||
if ($null -eq $drive) {
|
||||
throw New-Object System.NullReferenceException("Unable to retrieve PSDrive information")
|
||||
|
|
|
@ -44,13 +44,12 @@ function Initialize-DataCollection {
|
|||
}
|
||||
|
||||
# confirm sufficient disk space
|
||||
[System.Char]$driveLetter = (Split-Path -Path $FilePath.FullName -Qualifier).Replace(':','')
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'GB' {
|
||||
$diskSpace = Confirm-DiskSpace -DriveLetter $driveLetter -MinimumGB $MinimumGB
|
||||
$diskSpace = Confirm-DiskSpace -FilePath $FilePath.FullName -MinimumGB $MinimumGB
|
||||
}
|
||||
'MB' {
|
||||
$diskSpace = Confirm-DiskSpace -DriveLetter $driveLetter -MinimumMB $MinimumMB
|
||||
$diskSpace = Confirm-DiskSpace -FilePath $FilePath.FullName -MinimumMB $MinimumMB
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче