Skip to content

Commit

Permalink
SqlAGReplica: Fix read-only routing lists and some defaults (dsccommu…
Browse files Browse the repository at this point in the history
…nity#1302)

- Changes to SqlAG
  - Updated documentation on the behavior of defaults as they only apply when
    creating a group.
- Changes to SqlAGReplica
  - AvailabilityMode, BackupPriority, and FailoverMode defaults only apply when
    creating a replica not when making changes to an existing replica. Explicit
    parameters will still change existing replicas (issue dsccommunity#1244).
  - ReadOnlyRoutingList now gets updated without throwing an error on the first
    run (issue dsccommunity#518).
  • Loading branch information
codykonior authored and johlju committed Mar 10, 2019
1 parent 40e746c commit d36a171
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 67 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
- New-TerminatingError error text for a missing localized message now matches
the output even if the "missing localized message" localized message is
also missing.
- Changes to SqlAG
- Updated documentation on the behaviour of defaults as they only apply when
creating a group.
- Changes to SqlAGReplica
- AvailabilityMode, BackupPriority, and FailoverMode defaults only apply when
creating a replica not when making changes to an existing replica. Explicit
parameters will still change existing replicas ([issue #1244](https://github.com/PowerShell/SqlServerDsc/issues/1244)).
- ReadOnlyRoutingList now gets updated without throwing an error on the first
run ([issue #518](https://github.com/PowerShell/SqlServerDsc/issues/518)).

## 12.3.0.0

Expand Down
36 changes: 21 additions & 15 deletions DSCResources/MSFT_SqlAG/MSFT_SqlAG.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ function Get-TargetResource
Specifies if the availability group should be present or absent. Default is Present.
.PARAMETER AutomatedBackupPreference
Specifies the automated backup preference for the availability group.
Specifies the automated backup preference for the availability group. When creating a group the default is 'None'.
.PARAMETER AvailabilityMode
Specifies the replica availability mode. Default is 'AsynchronousCommit'.
Specifies the replica availability mode. When creating a group the default is 'AsynchronousCommit'.
.PARAMETER BackupPriority
Specifies the desired priority of the replicas in performing backups. The acceptable values for this parameter are integers from 0 through 100. Of the set of replicas which are online and available, the replica that has the highest priority performs the backup. Default is 50.
Specifies the desired priority of the replicas in performing backups. The acceptable values for this parameter are integers from 0 through 100. Of the set of replicas which are online and available, the replica that has the highest priority performs the backup. When creating a group the efault is 50.
.PARAMETER BasicAvailabilityGroup
Specifies the type of availability group is Basic. This is only available is SQL Server 2016 and later and is ignored when applied to previous versions.
Expand All @@ -132,13 +132,16 @@ function Get-TargetResource
Specifies how the availability replica handles connections when in the secondary role.
.PARAMETER EndpointHostName
Specifies the hostname or IP address of the availability group replica endpoint. Default is the instance network name.
Specifies the hostname or IP address of the availability group replica endpoint. When creating a group the default is the instance network name.
.PARAMETER FailureConditionLevel
Specifies the automatic failover behavior of the availability group.
.PARAMETER FailoverMode
Specifies the failover mode. When creating a group the default is 'Manual'.
.PARAMETER HealthCheckTimeout
Specifies the length of time, in milliseconds, after which AlwaysOn availability groups declare an unresponsive server to be unhealthy. Default is 30,000.
Specifies the length of time, in milliseconds, after which AlwaysOn availability groups declare an unresponsive server to be unhealthy. When creating a group the default is 30,000.
.PARAMETER ProcessOnlyOnActiveNode
Specifies that the resource will only determine if a change is needed if the target node is the active host of the SQL Server Instance.
Expand Down Expand Up @@ -285,14 +288,14 @@ function Set-TargetResource
throw New-TerminatingError -ErrorType DatabaseMirroringEndpointNotFound -FormatArgs $ServerName, $InstanceName -ErrorCategory ObjectNotFound
}

if ( -not $EndpointHostName )
{
$EndpointHostName = $serverObject.NetName
}

# If the availability group does not exist, create it
if ( -not $availabilityGroup )
{
if ( -not $EndpointHostName )
{
$EndpointHostName = $serverObject.NetName
}

# Set up the parameters to create the AG Replica
$newReplicaParams = @{
Name = $serverObject.DomainInstanceName
Expand Down Expand Up @@ -485,13 +488,13 @@ function Set-TargetResource
Specifies if the availability group should be present or absent. Default is Present.
.PARAMETER AutomatedBackupPreference
Specifies the automated backup preference for the availability group.
Specifies the automated backup preference for the availability group. When creating a group the default is 'None'.
.PARAMETER AvailabilityMode
Specifies the replica availability mode. Default is 'AsynchronousCommit'.
Specifies the replica availability mode. When creating a group the default is 'AsynchronousCommit'.
.PARAMETER BackupPriority
Specifies the desired priority of the replicas in performing backups. The acceptable values for this parameter are integers from 0 through 100. Of the set of replicas which are online and available, the replica that has the highest priority performs the backup. Default is 50.
Specifies the desired priority of the replicas in performing backups. The acceptable values for this parameter are integers from 0 through 100. Of the set of replicas which are online and available, the replica that has the highest priority performs the backup. When creating a group the default is 50.
.PARAMETER BasicAvailabilityGroup
Specifies the type of availability group is Basic. This is only available is SQL Server 2016 and later and is ignored when applied to previous versions.
Expand All @@ -509,13 +512,16 @@ function Set-TargetResource
Specifies how the availability replica handles connections when in the secondary role.
.PARAMETER EndpointHostName
Specifies the hostname or IP address of the availability group replica endpoint. Default is the instance network name.
Specifies the hostname or IP address of the availability group replica endpoint. When creating a group the default is the instance network name.
.PARAMETER FailureConditionLevel
Specifies the automatic failover behavior of the availability group.
.PARAMETER FailoverMode
Specifies the failover mode. When creating a group the default is 'Manual'.
.PARAMETER HealthCheckTimeout
Specifies the length of time, in milliseconds, after which AlwaysOn availability groups declare an unresponsive server to be unhealthy. Default is 30,000.
Specifies the length of time, in milliseconds, after which AlwaysOn availability groups declare an unresponsive server to be unhealthy. When creating a group the default is 30,000.
.PARAMETER ProcessOnlyOnActiveNode
Specifies that the resource will only determine if a change is needed if the target node is the active host of the SQL Server Instance.
Expand Down
12 changes: 6 additions & 6 deletions DSCResources/MSFT_SqlAG/MSFT_SqlAG.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ class MSFT_SqlAG : OMI_BaseResource
[Required, Description("Hostname of the SQL Server to be configured.")] String ServerName;
[Key, Description("Name of the SQL instance to be configured.")] String InstanceName;
[Write, Description("Specifies if the availability group should be present or absent. Default is Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
[Write, Description("Specifies the automated backup preference for the availability group. Default is None"), ValueMap{"Primary","SecondaryOnly","Secondary","None"}, Values{"Primary","SecondaryOnly","Secondary","None"}] String AutomatedBackupPreference;
[Write, Description("Specifies the replica availability mode. Default is 'AsynchronousCommit'."), ValueMap{"AsynchronousCommit","SynchronousCommit"}, Values{"AsynchronousCommit","SynchronousCommit"}] String AvailabilityMode;
[Write, Description("Specifies the desired priority of the replicas in performing backups. The acceptable values for this parameter are: integers from 0 through 100. Of the set of replicas which are online and available, the replica that has the highest priority performs the backup. Default is 50.")] UInt32 BackupPriority;
[Write, Description("Specifies the automated backup preference for the availability group. When creating a group the default is None"), ValueMap{"Primary","SecondaryOnly","Secondary","None"}, Values{"Primary","SecondaryOnly","Secondary","None"}] String AutomatedBackupPreference;
[Write, Description("Specifies the replica availability mode. When creating a group the default is 'AsynchronousCommit'."), ValueMap{"AsynchronousCommit","SynchronousCommit"}, Values{"AsynchronousCommit","SynchronousCommit"}] String AvailabilityMode;
[Write, Description("Specifies the desired priority of the replicas in performing backups. The acceptable values for this parameter are: integers from 0 through 100. Of the set of replicas which are online and available, the replica that has the highest priority performs the backup. When creating a group the default is 50.")] UInt32 BackupPriority;
[Write, Description("Specifies the type of availability group is Basic. This is only available is SQL Server 2016 and later and is ignored when applied to previous versions.")] Boolean BasicAvailabilityGroup;
[Write, Description("Specifies if the option Database Level Health Detection is enabled. This is only available is SQL Server 2016 and later and is ignored when applied to previous versions.")] Boolean DatabaseHealthTrigger;
[Write, Description("Specifies if the option Database DTC Support is enabled. This is only available is SQL Server 2016 and later and is ignored when applied to previous versions. This can't be altered once the Availability Group is created and is ignored if it is the case.")] Boolean DtcSupportEnabled;
[Write, Description("Specifies how the availability replica handles connections when in the primary role."), ValueMap{"AllowAllConnections","AllowReadWriteConnections"}, Values{"AllowAllConnections","AllowReadWriteConnections"}] String ConnectionModeInPrimaryRole;
[Write, Description("Specifies how the availability replica handles connections when in the secondary role."), ValueMap{"AllowNoConnections","AllowReadIntentConnectionsOnly","AllowAllConnections"}, Values{"AllowNoConnections","AllowReadIntentConnectionsOnly","AllowAllConnections"}] String ConnectionModeInSecondaryRole;
[Write, Description("Specifies the hostname or IP address of the availability group replica endpoint. Default is the instance network name.")] String EndpointHostName;
[Write, Description("Specifies the hostname or IP address of the availability group replica endpoint. When creating a group the default is the instance network name.")] String EndpointHostName;
[Write, Description("Specifies the automatic failover behavior of the availability group."), ValueMap{"OnServerDown","OnServerUnresponsive","OnCriticalServerErrors","OnModerateServerErrors","OnAnyQualifiedFailureCondition"}, Values{"OnServerDown","OnServerUnresponsive","OnCriticalServerErrors","OnModerateServerErrors","OnAnyQualifiedFailureCondition"}] String FailureConditionLevel;
[Write, Description("Specifies the failover mode. Default is 'Manual'."), ValueMap{"Automatic","Manual"}, Values{"Automatic","Manual"}] String FailoverMode;
[Write, Description("Specifies the length of time, in milliseconds, after which AlwaysOn availability groups declare an unresponsive server to be unhealthy. Default is 30000.")] UInt32 HealthCheckTimeout;
[Write, Description("Specifies the failover mode. When creating a group the default is 'Manual'."), ValueMap{"Automatic","Manual"}, Values{"Automatic","Manual"}] String FailoverMode;
[Write, Description("Specifies the length of time, in milliseconds, after which AlwaysOn availability groups declare an unresponsive server to be unhealthy. When creating a group the default is 30000.")] UInt32 HealthCheckTimeout;
[Write, Description("Specifies that the resource will only determine if a change is needed if the target node is the active host of the SQL Server Instance.")] Boolean ProcessOnlyOnActiveNode;
[Read, Description("Gets the Endpoint URL of the availability group replica endpoint.")] String EndpointUrl;
[Read, Description("Gets the port the database mirroring endpoint is listening on.")] UInt32 EndpointPort;
Expand Down
Loading

0 comments on commit d36a171

Please sign in to comment.