Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-RubrikDatabase takes a long time to parse a large number( > 20,000) of databases #763

Open
dewbrik opened this issue May 21, 2021 · 1 comment

Comments

@dewbrik
Copy link

dewbrik commented May 21, 2021

Is your feature request related to a problem? Please describe.
When making a request to get a list of database through using Get-RubrikDatabase, the command can take a long time(~20 minutes) to complete.

Describe the solution you'd like
I'd like for the cmdlet to complete faster.

Describe alternatives you've considered
Replacing the cmdlet with a native cmdet and converting the output JSON proved to be faster. For example, I made the equivalent request with:
$request = Invoke-WebRequest -URI "https://some_ip/api/v1/mssql/db" -method Get -header $someheaderinfo -useBasicParsing

and then convert the output with
$db_list = ($request.content | Convertfrom-Json).data

This gives me the same output as:
$db_list = Get-RubrikDatabase

Additional context

This is Windows PowerShell version 5.1, with the Rubrik PS module at 5.2.0. I set psdebug trace level to 2 and watched Get-RubrikDatabase execute, and if I had to guess, I think almost all of the time is being spent in Format-JSON.ps1 to parse the output as the scrolling text looked like this the entire time:
`EBUG: ! CALL function 'ParseItem' (defined in file 'C:\Program Files\WindowsPowerShell\Modules\Rubrik\5.2.0\Private\Format-JSON.ps1')
DEBUG: 23+ if( >>>> $jsonItem.PSObject.TypeNames -match 'Array') {

DEBUG: 25+ } elseif( >>>> $jsonItem.PSObject.TypeNames -match 'Dictionary') {

DEBUG: 28+ return >>>> $jsonItem

DEBUG: 30+ >>>> }

DEBUG: ! SET $parsedItem = 'a56467d8-471e-4a3c-935c-b091ce1d19fa'.
DEBUG: 48+ >>>> $result | Add-Member -MemberType NoteProperty -Name $key -Value $parsedItem

DEBUG: 38+ foreach ( >>>> $key in $jsonObj.Keys)

DEBUG: ! SET $key = 'effectiveSlaDomainId'.
DEBUG: 40+ >>>> $item = $jsonObj[$key]

DEBUG: ! SET $item = 'UNPROTECTED'.
DEBUG: 42+ if ( >>>> $null -ne $item) {

DEBUG: 43+ >>>> $parsedItem = ParseItem -jsonItem $item

DEBUG: 18+ function ParseItem($jsonItem) >>>> {

DEBUG: ! CALL function 'ParseItem' (defined in file 'C:\Program Files\WindowsPowerShell\Modules\Rubrik\5.2.0\Private\Format-JSON.ps1')`

I'm not sure if this problem is reproducible in PowerShell 6 or newer.

@jaapbrasser
Copy link
Contributor

Hey Dewbrik,

Just noticed this was still in the backlog, this is indeed fixed when using a new PowerShell version, but I've added support for two new scenarios:

  • Set-RubrikModuleOption -OptionName LegacyJSONConversion -OptionValue AlwaysConvertToJson to fall back to, on Windows PowerShell 5.1 occasionally buggy, ConvertTo-Json cmdlet
  • Set-RubrikModuleOption -OptionName LegacyJSONConversion -OptionValue Experimental to use the improved ParseItemExp function, should be a 40~50% speed improvement

The code is available in the following branch:
https://github.com/rubrikinc/rubrik-sdk-for-powershell/tree/jaap-newpr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants