ONTAP Discussions

Netapp ONTAP Powershell toolkit BUG when upgrading from 9.13.1.2306 to 9.15.1.2410 (not the cert)

WhollyJoe
220 Views

I am having an issue in many production scripts that are taking advantage of the 'Connect-NcController -Transient:$true' functionality to not set the global variable when connecting to a controller, and instead assign that connection to my own custom variable. 

It all works fine, except the first time I try to do ANYTHING with that connection it will fail with a generic error coming from the module commandlets. The same action will work fine the second and every other time after that first failure. 

 

 

Get-NcAggr : Object reference not set to an instance of an object.
At line:35 char:27
+                 $ncAggr = Get-NcAggr -Controller $ncController
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-NcAggr], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,DataONTAP.C.PowerShell.SDK.Cmdlets.Aggr.GetNcAggr

 


Here is a simple script to reproduce the issue:

 

 

# Set this to $true to use the $global:CurrentNcController in the Get-NcAggr command 
# Set to $false to use the controller stored in a variable as an object $ncController
$useNcGlobal = $false

# update to your actual controller
$controllerIP = "xxx.xxx.xxx.xxx"


Import-Module NetApp.ONTAP
$global:CurrentNcController = $null

try {
    $ncCredential = Get-Credential -Message "Add Admin password" -UserName admin


    if ( -not ($useNcGlobal) ) {
    # Store controller in variable and use transient to NOT set the global 
        $ncController = Connect-NcController -Name $controllerIP -Credential $ncCredential -Transient:$true -ErrorAction Stop
        Write-Host "Controller varaible '`$ncController' type is '$($nccontroller.GetType())'"
    }
    else {
    # Store controller in the global 
        Connect-NcController -Name $controllerIP -Credential $ncCredential -ErrorAction Stop
        Write-Host "Controller varaible '`$global:CurrentNcController' type is '$($global:CurrentNcController.GetType())'"
    }

    [int]$i = 0
    $ints = 1..10
    foreach ($int in $ints) {
        try {
            $i++
            if ( $nccontroller ) {
                $ncAggr = Get-NcAggr -Controller $ncController
            }
            else {
                $ncAggr = Get-NcAggr
            }
            Write-Host "This time, '$i' and subsequent times will always succeed"
            if ( $int -eq $($ints | Select-Object -Last 1) ) {
                $ncAggr
            }
        }
        catch {
            $error[0]
            Write-Host "This time, '$i' always fails when using -controller and passing in a controller variable object"
        }
    }
}
catch {
    $error[0]
    Write-Host "Uncaught error" 
}

 

 

 

 

1 REPLY 1

Sanaman
49 Views

I am seeing the same issue with my toolkit version 9.15.x

 

1st time:

Scripts> Get-NcVol
Get-NcVol: The remote server returned an error: (400) Bad Request.

 

Second time

Scripts> Get-NcVol

Name State TotalSize Used Available Dedupe Aggregate Vserver
---- ----- --------- ---- --------- ------ --------- -------
prod_store1_v… online 13.1 TB 1.6 TB node_a_nlsas_aggr1 vserver61
svm61_rootvol online 1.0 GB 963.3 MB node_a_nlsas_aggr1 svm61

......................

Public