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

xSQLServerAlwaysOnAvailabilityGroupReplica: Should Be Cluster Aware #870

Closed
randomnote1 opened this Issue Oct 13, 2017 · 3 comments

Comments

2 participants
@randomnote1
Contributor

randomnote1 commented Oct 13, 2017

Details of the scenario you tried and the problem that is occurring:
When the xSQLServerAlwaysOnAvailabilityGroupReplica resource is applied to all of the nodes in a Failover Cluster Instance (FCI), the nodes will "fight" with each other while trying to manage the database memberships in the availability group.

The DSC configuration that is using the resource (as detailed as possible):
When the following configuration is applied to two or more nodes in a FCI.

xSQLServerAlwaysOnAvailabilityGroupReplica AddReplica
{
    Ensure                        = 'Present'
    Name                          = $Node.NodeName
    AvailabilityGroupName         = $Node.AvailabilityGroupName
    SQLServer                     = $Node.NodeName
    SQLInstanceName               = $Node.SQLInstanceName
    PrimaryReplicaSQLServer       = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).NodeName
    PrimaryReplicaSQLInstanceName = ( $AllNodes | Where-Object { $_.Role -eq 'PrimaryReplica' } ).SQLInstanceName
}

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
Any

What module (SqlServer or SQLPS) and which version of the module the DSC Target Node is running:
Any

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

@randomnote1

This comment has been minimized.

Show comment
Hide comment
@randomnote1

randomnote1 Oct 13, 2017

Contributor

The resource should evaluate if the current node is actively hosting the SQL instance. If it is not hosting the instance, it should write a verbose message stating that it does not own the instance, and then silently exit.

Contributor

randomnote1 commented Oct 13, 2017

The resource should evaluate if the current node is actively hosting the SQL instance. If it is not hosting the instance, it should write a verbose message stating that it does not own the instance, and then silently exit.

@randomnote1

This comment has been minimized.

Show comment
Hide comment
@randomnote1

randomnote1 Oct 20, 2017

Contributor

To resolve this issue, a parameter called ProcessOnlyOnActiveNode should be created on the Set-TargetResource and Test-TargetResource functions.

The Get-TargetResource function will execute the helper function Test-ActiveNode to determine if the current node is actively hosting the SQL instance and return the result via the read-only property IsActiveNode.

The Test-TargetResource function will use the value of ProcessOnlyOnActiveNode and IsActiveNode to determine if it should continue. If ProcessOnlyOnActiveNode is $true and IsActiveNode is $false, Test-TargetResource will return $true.

I put together this gist as a guide to updating the resource.

Also, see the xSQLServerAlwaysOnAvailabilityGroup resource for a completed example.

Contributor

randomnote1 commented Oct 20, 2017

To resolve this issue, a parameter called ProcessOnlyOnActiveNode should be created on the Set-TargetResource and Test-TargetResource functions.

The Get-TargetResource function will execute the helper function Test-ActiveNode to determine if the current node is actively hosting the SQL instance and return the result via the read-only property IsActiveNode.

The Test-TargetResource function will use the value of ProcessOnlyOnActiveNode and IsActiveNode to determine if it should continue. If ProcessOnlyOnActiveNode is $true and IsActiveNode is $false, Test-TargetResource will return $true.

I put together this gist as a guide to updating the resource.

Also, see the xSQLServerAlwaysOnAvailabilityGroup resource for a completed example.

@randomnote1

This comment has been minimized.

Show comment
Hide comment
@randomnote1

randomnote1 Oct 20, 2017

Contributor

Starting on this one.

Contributor

randomnote1 commented Oct 20, 2017

Starting on this one.

@johlju johlju added in progress and removed help wanted labels Oct 20, 2017

@johlju johlju moved this from Backlog to In progress in Resources should be cluster aware Oct 20, 2017

@johlju johlju closed this in #892 Oct 25, 2017

johlju added a commit that referenced this issue Oct 25, 2017

xSQLServerAlwaysOnAvailabilityGroupReplica: Make Cluster Aware (#892)
- Changes to xSQLServerAlwaysOnAvailabilityGroupReplica
  - Made the resource cluster aware. When ProcessOnlyOnActiveNode is specified,
    the resource will only determine if a change is needed if the target node is
    the active host of the SQL Server instance (issue #870).

@johlju johlju moved this from In progress to Done in Resources should be cluster aware Oct 25, 2017

@johlju johlju removed the in progress label Oct 25, 2017

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