dsccommunity / dsccommunity/SqlServerDsc

SqlAGListener: Fails Test-TargetResource when Listener already exists

Open
#992 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good first issue help wanted
Dominant language
PowerShell
Stars
385
Forks
224
PR merge metrics
No merged PRs in 30d

Description

Details of the scenario you tried and the problem that is occurring:

When applying DSC again to a SQL cluster that has been configured correctly with an AG Listener (eg. 192.168.0.1/255.255.255.0), DSC will fail the test as within the Get-TargetResource it looks at 'SubnetMask' which seems to always return 255.255.255.255 and does not compare 'SubnetIPv4Mask' which does hold the correct subnet mask.

Running the following PS on the primary node shows what I mean:
$sqlServerObject = Connect-SQL -SQLServer $env:COMPUTERNAME -SQLInstanceName 'SQL Instance Name'
$availabilityGroupListenerObject = $sqlServerObject.AvailabilityGroups['SQL Instance Name'].AvailabilityGroupListeners['SQL Instance Name']
$availabilityGroupListenerObject.AvailabilityGroupListenerIPAddresses

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

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
Windows 2016
SQL 2016 Enterprise
Powershell 5.1

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

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the SqlAGListener Get-TargetResource logic and inspect the AvailabilityGroupListenerIPAddresses properties shown in the reproduction. Re-run the provided PowerShell query against an existing listener, then verify that Test-TargetResource compares the correct subnet mask and no longer reports the configured listener as different.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, sql
Domain
databases, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.