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

New-RubrikSnapshot, Protect-RubrikFileset - Cmdlets using -slaname w/identical Local/Remote SLA names are failing #720

Open
stevenctong opened this issue Jan 3, 2021 · 5 comments

Comments

@stevenctong
Copy link

Current Behavior:

Cmdlets where you pass in 'slaname' on a cluster with SLAs that have identically named Local and Remote SLAs are failing. In the example below the cluster has a Local and Remote SLA named '1d-30d-NoArchive'. The cmdlet finds both the Local and Remote SLA IDs and tries passing it to the REST API call where it should only be passing the Local SLA ID.

$req = New-RubrikSnapshot -id $i -SLA $slaName -confirm:$false -verbose
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for New-RubrikSnapshot
VERBOSE: Selected 1.0 API Data for New-RubrikSnapshot
VERBOSE: Load API data for New-RubrikSnapshot
VERBOSE: Description: Create an on-demand snapshot for the given object ID
VERBOSE: Performing the operation "Testing SLA" on target "1d-30d-NoArchive".
VERBOSE: Determining the SLA Domain id
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for Get-RubrikSLA
VERBOSE: Selected 5.0 API Data for Get-RubrikSLA
VERBOSE: Load API data for Get-RubrikSLA
VERBOSE: Description: Retrieve summary information for all SLA Domains
VERBOSE: Build the URI
VERBOSE: URI = https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain
VERBOSE: Build the query parameters for primary_cluster_id
VERBOSE: URI = https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 100 seconds
VERBOSE: GET https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain with 0-byte payload
VERBOSE: received 79485-byte response of content type application/json
VERBOSE: Received HTTP Status 200                                                                                                                                                             VERBOSE: Formatting return value                                                                                                                                                              VERBOSE: Filter the results                                                                                                                                                                   VERBOSE: Filter match = Name
VERBOSE: Getting SLA Domain frequency summary
VERBOSE: No advanced config found
VERBOSE: Getting SLA Domain frequency summary
VERBOSE: No advanced config found
VERBOSE: Applying Rubrik.SLADomain TypeName to results
VERBOSE: Multiple URIs detected. Selecting URI based on Fileset:::36ca4a05-8625-4595-983c-fcfef805997c
VERBOSE: Loading Fileset API data
VERBOSE: List of set parameters: [id, Fileset:::36ca4a05-8625-4595-983c-fcfef805997c] [SLA, 1d-30d-NoArchive] [Confirm, False] [Verbose, True] [SLAID, 4d37f114-6592-4899-912b-7d589f79108a 3edea4e7-6866-420f-aca1-cd083c5301d1]
VERBOSE: Build the body parameters
VERBOSE: Adding slaId...
VERBOSE: Adding forceFullSnapshot...
VERBOSE: Body = {
  "slaId": "4d37f114-6592-4899-912b-7d589f79108a 3edea4e7-6866-420f-aca1-cd083c5301d1"
}
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 100 seconds
VERBOSE: POST https://amer1-rbk01.rubrikdemo.com/api/v1/fileset/Fileset:::36ca4a05-8625-4595-983c-fcfef805997c/snapshot with 90-byte payload
VERBOSE: received 120-byte response of content type text/plain
WARNING: Could not find SlaDomain with id=4d37f114-6592-4899-912b-7d589f79108a 3edea4e7-6866-420f-aca1-cd083c5301d1
OperationStopped: /Users/steventong/.local/share/powershell/Modules/Rubrik/Private/Submit-Request.ps1:106
Line |
 106 |                      throw $_.Exception
     |                      ~~~~~~~~~~~~~~~~~~
     | Response status code does not indicate success: 404 (Not Found).

This also happened with the 'Protect-RubrikFileset' cmdlet so I assume it will happen to any cmdlet that uses 'slaname'.

Expected Behavior:

When passing a SLA Name we expect it to find and use the Local SLA and not any Remote ones.

Steps to Reproduce:

  1. Have a cluster with identically named SLAs for a Local and Remote SLA
  2. Attempt to use a cmdlet that uses 'slaname' as an argument, eg 'New-RubrikSnapshot'

Context:

  • Rubrik PowerShell v5.2.0
  • Powershell v7.0.1
  • OS Mac Catalina 10.15.7

I just upgraded to Rubrik Powershell v5.2 from v5.0 and I don't believe this issue was occurring previously.

@jaapbrasser jaapbrasser self-assigned this Jan 4, 2021
@jaapbrasser
Copy link
Contributor

Hello Steven,

That is an interesting situation, I'll take a look at how we can best handle this. A fix that comes to mind would be adding a -SLAPrimaryClusterId parameter that is set to local by default. Would that be a solution that works for you, then you could run it in three separate ways:

Run against local cluster

$req = New-RubrikSnapshot -id $i -SLA $slaName -confirm:$false -verbose

To run against a specific cluster ID

$req = New-RubrikSnapshot -id $i -SLA $slaName -confirm:$false -verbose -SLAPrimaryClusterId 57bbd327-477d-40d8-a1d8-5820a37f88e5

Run against local and remote

$req = New-RubrikSnapshot -id $i -SLA $slaName -confirm:$false -verbose -SLAQueryAll

Would that be a workable solution for you?

@stevenctong
Copy link
Author

I think that is a good solution for cmdlets that take a '-sla' parameter to default to only using Local SLAs. These should be all cmdlets that assign/modify a SLA to an object or take a snapshot of an object associated with a SLA.
For adding the additional parameter options, I don't think it is valid in most cases. You aren't able to assign/modify SLAs using Remote SLAs or take snapshots using Remote SLAs, nor can you trigger those actions with multiple SLAs.
For cmdlets where you might want to do things to Remote SLAs, eg 'Get-RubrikSLA', there is already a parameter to filter by 'PrimaryClusterID'.
'Set-RubrikSLA' may need 'PrimaryClusterID' in order to edit Remote SLAs, but that option needs to be scoped to the applicable Remote SLA edits, ie only modifying the archive settings.

@jaapbrasser
Copy link
Contributor

Hello @stevenctong,

I have updated both Protect-RubrikFileset & New-RubrikSnapshot with the new parameter, you can download the code from this branch:
https://github.com/rubrikinc/rubrik-sdk-for-powershell/tree/devel-jaap-fixalot

@stevenctong
Copy link
Author

Hi @jaapbrasser - thanks for the quick fix! I confirmed that Protect-RubrikFileset and New-RubrikSnapshot are now working. Would you be able to apply the same fix to the remaining Protect-* cmdlets:

  • Protect-RubrikDatabase
  • Protect-RubrikHyperVVM
  • Protect-RubrikNutanixVM
  • Protect-RubrikTag
  • Protect-RubrikVApp
  • Protect-RubrikVolumeGroup
  • Protect-RubrikVM

I didn't test all but I did notice a slight difference in error between Protect-RubrikDatabase and Protect-RubrikVM so there are two examples below:

# This SLA has Local and Remote SLAs with identical names
$slaWithDuplicate = '1d-30d-NoArchive'

# This SLA only has a Local SLA
$slaUnique = 'st-sla'

Protect-RubrikDatabase
This one is similar to the issue you fixed where it returns an array of SLAs and then tries to pass it but fails.

> Protect-RubrikDatabase -id $sqlid -sla $slaWithDuplicate -verbose
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for Protect-RubrikDatabase
VERBOSE: Selected 1.0 API Data for Protect-RubrikDatabase
VERBOSE: Load API data for Protect-RubrikDatabase
VERBOSE: Description: Update a Microsoft SQL database with the specified SLA Domain.
VERBOSE: Determining the SLA Domain id
VERBOSE: Validate the Rubrik token exists
VERBOSE: Found a Rubrik token for authentication
VERBOSE: Gather API Data for Get-RubrikSLA
VERBOSE: Selected 5.0 API Data for Get-RubrikSLA
VERBOSE: Load API data for Get-RubrikSLA
VERBOSE: Description: Retrieve summary information for all SLA Domains
VERBOSE: Build the URI
VERBOSE: URI = https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain
VERBOSE: Build the query parameters for primary_cluster_id
VERBOSE: URI = https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 100 seconds
VERBOSE: GET https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain with 0-byte payload
VERBOSE: received 80202-byte response of content type application/json
VERBOSE: Received HTTP Status 200                                                                                                                                                    VERBOSE: Formatting return value                                                                                                                                                     VERBOSE: Filter the results                                                                                                                                                          VERBOSE: Filter match = Name
VERBOSE: Getting SLA Domain frequency summary
VERBOSE: No advanced config found
VERBOSE: Getting SLA Domain frequency summary
VERBOSE: No advanced config found
VERBOSE: Applying Rubrik.SLADomain TypeName to results
VERBOSE: Build the URI
VERBOSE: URI = https://amer1-rbk01.rubrikdemo.com/api/v1/mssql/db/MssqlDatabase:::9746567f-dc14-4996-af39-636c15056d25
VERBOSE: Build the query parameters for <null>
VERBOSE: URI = https://amer1-rbk01.rubrikdemo.com/api/v1/mssql/db/MssqlDatabase:::9746567f-dc14-4996-af39-636c15056d25
VERBOSE: List of set parameters: [id, MssqlDatabase:::9746567f-dc14-4996-af39-636c15056d25] [SLA, 1d-30d-NoArchive] [Verbose, True] [SLAID, 4d37f114-6592-4899-912b-7d589f79108a 3edea4e7-6866-420f-aca1-cd083c5301d1]
VERBOSE: Build the body parameters
VERBOSE: Adding maxDataStreams...
VERBOSE: Adding copyOnly...
VERBOSE: Adding logRetentionHours...
VERBOSE: Adding logBackupFrequencyInSeconds...
VERBOSE: Adding configuredSlaDomainId...
VERBOSE: Body = {
  "configuredSlaDomainId": "4d37f114-6592-4899-912b-7d589f79108a 3edea4e7-6866-420f-aca1-cd083c5301d1"
}
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 100 seconds
VERBOSE: PATCH https://amer1-rbk01.rubrikdemo.com/api/v1/mssql/db/MssqlDatabase:::9746567f-dc14-4996-af39-636c15056d25 with 106-byte payload
VERBOSE: received 120-byte response of content type text/plain
WARNING: Could not find SlaDomain with id=4d37f114-6592-4899-912b-7d589f79108a 3edea4e7-6866-420f-aca1-cd083c5301d1

Protect-RubrikVM
This fails with a different error. It looks like an array of SLAs is returned but fails to pass downstream.

downstream
> Protect-RubrikVM -id $vmid -sla $slaWithDuplicate -verbose
Protect-RubrikVM: Cannot process argument transformation on parameter 'SLAID'. Cannot convert value to type System.String.                                                           

> Protect-RubrikVM -id $vmid -sla $slaUnique -verbose                                                                
VERBOSE: Validate the Rubrik token exists                                                                                                                                            VERBOSE: Found a Rubrik token for authentication                                                                                                                                     VERBOSE: Gather API Data for Protect-RubrikVM                                                                                                                                        VERBOSE: Selected 5.2 API Data for Protect-RubrikVM
VERBOSE: Load API data for Protect-RubrikVM
VERBOSE: Description: Update a VM with the specified SLA Domain.
VERBOSE: Build the URI
VERBOSE: URI = https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain/836fc932-dc01-4572-9130-fc7a849ae940/assign
VERBOSE: Body = {
  "managedIds": [
    "VirtualMachine:::5ed1b046-0bd9-4468-a67c-3293f15f27ed-vm-1348935"
  ],
  "existingSnapshotRetention": "RetainSnapshots"
}
VERBOSE: Submitting the request
VERBOSE: Invoking request with a custom timeout of 100 seconds
VERBOSE: POST https://amer1-rbk01.rubrikdemo.com/api/v2/sla_domain/836fc932-dc01-4572-9130-fc7a849ae940/assign with 146-byte payload
VERBOSE: received 215-byte response of content type application/json
VERBOSE: Received HTTP Status 200                                                                                                                                                    VERBOSE: Formatting return value

Thanks again!

@jaapbrasser
Copy link
Contributor

Thanks Stephen,

I have pushed out a prerelease build with the current changes to the PowerShell gallery so you can start using that one now by installing it using the following command:

Install-Module Rubrik -AllowPrerelease -Scope CurrentUser

I'll take a look at what is happening in Protect-RubrikDatabase and Protect-RubrikVM, as for the other Protect-* cmdlets, those will be addressed in the upcoming PR, they are overdue for an overhaul as some SLA specific parameters are currently also missing as reported in #697

Thanks for posting the extensive information and verbose logging, this makes it a lot easier and understandable for me to address the issue you mentioned.

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