dsccommunity / SqlServerDsc

This module contains DSC resources for deployment and configuration of Microsoft SQL Server.
MIT License
359 stars 224 forks source link

xSQLServerSetup: Unable to map disks when adding a feature to cluster install #433

Closed johlju closed 7 years ago

johlju commented 7 years ago

Details of the scenario you try and problem that is occurring: When adding SSAS to a already installed instance, and at the same time using the same disks for the paths for SSAS. Then the resource can not map the paths to the correct drives.

PowerShell DSC resource MSFT_xSQLServerSetup  failed to execute Set-TargetResource functionality with error message: Unable to map the specified paths to valid cluster storage. Drives mapped:  
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure

This is because it only looks at available storage, not storage already being used (if any). https://github.com/PowerShell/xSQLServer/blob/dev/DSCResources/MSFT_xSQLServerSetup/MSFT_xSQLServerSetup.psm1#L954

It should also evaluate at any existing disks in the cluster group $FailoverClusterNetworkName. For example using the below code.

if( Get-CimInstance -Namespace 'root/MSCluster' -ClassName 'MSCluster_ResourceGroup' -Filter "Name = '$FailoverClusterNetworkName'" )
{
    $availableStorage += Get-CimInstance -Namespace 'root/MSCluster' -ClassName 'MSCluster_ResourceGroup' -Filter "Name = 'TESTCLU01A'" | `
                            Get-CimAssociatedInstance -Association MSCluster_ResourceGroupToResource -ResultClassName MSCluster_Resource | Where-Object -FilterScript {$_.Type -eq 'Physical Disk'} | `
                            Add-Member -MemberType NoteProperty -Name 'IsPossibleOwner' -Value $false -PassThru
}

The DSC configuration that is using the resource (as detailed as possible):

xSQLServerSetup $resourceConfigName
{
    Action = 'InstallFailoverCluster'
    ForceReboot = $false

    SourcePath = $Node."SourcePath$($currentSqlInstance)"
    UpdateEnabled = 'False'

    SetupCredential = $SqlInstallCredential
    SourceCredential = $SqlInstallCredential

    InstanceName = $Node."$($currentSqlInstance)InstanceName"
    Features = 'SQLENGINE,AS,SSMS,ADV_SSMS'

    InstallSharedDir = 'C:\Program Files\Microsoft SQL Server'
    InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server'
    InstanceDir = 'C:\Program Files\Microsoft SQL Server'

    SQLCollation = 'Finnish_Swedish_CI_AS'
    SQLSvcAccount = $SqlServiceCredential
    AgtSvcAccount = $SqlAgentServiceCredential
    SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName

    InstallSQLDataDir = 'G:\MSSQL\Data'
    SQLUserDBDir = 'E:\MSSQL\Data'
    SQLUserDBLogDir = 'F:\MSSQL\Log'
    SQLTempDBDir = 'H:\MSSQL\Temp'
    SQLTempDBLogDir = 'H:\MSSQL\Temp'
    SQLBackupDir = 'I:\MSSQL\Backup'

    ASSvcAccount = $SqlServiceCredential
    ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName

    ASConfigDir = 'G:\AS\Config'
    ASDataDir = 'E:\AS\Data'
    ASLogDir = 'F:\AS\Log'
    ASBackupDir = 'I:\AS\Backup'
    ASTempDir = 'H:\AS\Temp'

    FailoverClusterNetworkName = $Node.SqlClusterGroupFailoverClusterNetworkName
    FailoverClusterIPAddress = $Node.SqlClusterGroupFailoverClusterIPAddress
    FailoverClusterGroupName = $Node.SqlClusterGroupFailoverClusterGroupName

    DependsOn = '[WindowsFeature]NetFramework35','[WindowsFeature]NetFramework45'
}

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running: Windows Server 2016, SQL Server 2014, WMF5.0

Version of the DSC module you're using, or 'dev' if you're using current dev branch: Dev

johlju commented 7 years ago

Okay, so I tried to fix the above, that did not work. Seems I need new disk for adding the SSAS feature. I thought I could leverage the same disks which are used by the same instance. Or does it think I want to install "a new instance" with the same name. 🤔

Exception type: Microsoft.SqlServer.Chainer.Infrastructure.InputSettingValidationException
    Message: 
        The specified disk resource 'SQL2016-DATA' cannot be used as a failover cluster disk.  Reason: The disk resource 'SQL2016-DATA' is already in use by resource 'SQL Server (SQL2014)'. To use a disk in a new SQL Server failover cluster instance, the disk must not have any dependencies that reference it.
    HResult : 0x84b40002
        FacilityCode : 1204 (4b4)
        ErrorCode : 2 (0002)
    Data: 
      SQL.Setup.FailureCategory = InputSettingValidationFailure
      DisableWatson = true
    Stack: 
        at Microsoft.SqlServer.Chainer.Infrastructure.InputSettingService.LogAllValidationErrorsAndThrowFirstOne(ValidationState vs)
        at Microsoft.SqlServer.Configuration.SetupExtension.ValidateFeatureSettingsAction.ExecuteAction(String actionId)
        at Microsoft.SqlServer.Chainer.Infrastructure.Action.Execute(String actionId, TextWriter errorStream)
        at Microsoft.SqlServer.Setup.Chainer.Workflow.ActionInvocation.<>c__DisplayClasse.<ExecuteActionWithRetryHelper>b__b()
        at Microsoft.SqlServer.Setup.Chainer.Workflow.ActionInvocation.ExecuteActionHelper(ActionWorker workerDelegate)
johlju commented 7 years ago

Well, this article answers the question... You cannot add or remove features to a SQL Server 2008, SQL Server 2008 R2, or SQL Server 2012 failover cluster

Guess that goes for SQL 2014 and 2016 as well.