dsccommunity / SqlServerDsc

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

[SqlAGListeners]SqlAGListeners] The character length of the 16 argument is too long #2005

Closed steffenengelhamburg closed 7 months ago

steffenengelhamburg commented 7 months ago

Problem description

Problem: Using a AG Listenername with maximum 16 Chars (Netbios Maximum) the Mof will be build, but not applied on the Target.

Verbose logs

VERBOSE: [Target]: LCM:  [ End    Test     ]  [[SqlAGListener]MSSQLSERVER_AGName_MyListener16char::[SqlAGListeners]SqlAGListeners]  in 0.3000 seconds.
PowerShell DSC resource DSC_SqlAGListener  failed to execute Test-TargetResource functionality with error message:
Cannot validate argument on parameter 'Name'. The character length of the 16 argument is too long.
Shorten the character length of the argument so it is fewer than or equal to "15" characters, and then try the command again.
+ CategoryInfo          : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName        : MyPrimaryNode

DSC configuration

---- Cluster.yml
SQLAGConfig:
- AGName: AGName
  AGListenerName: MyListener16char
  AGListenerIP: 10.0.0.111/255.255.255.0
  PrimaryReplicaServerName: MyPrimaryNode
  AGListenerPort: 1433

-- Primary.yml
# Create all AG Listener defined in Cluster Credential
SqlAGListeners:
  DependsOn: "[SqlAGs]SqlAGs"
  PSDSCRunAsCredential: '[x={$Datum.Credentials.$($Node.Environment).ADAccounts.DSCAccount}=]'
  Values: '[x={[hashtable[]]($Datum.Credentials.$($Node.ClusterName).SQLAGConfig | Foreach {@{Name = $_.AGListenerName;ServerName = $($Node.NodeName);InstanceName = "MSSQLSERVER";AvailabilityGroup = $_.AGName;Port= $($_.AGListenerPort); IpAddress= $($_.AGListenerIP)}})}=]'

Suggested solution

Change ValidateLenght for $Name of AVG Listener in DSC_SqlAGListener.psm1

[Parameter(Mandatory = $true)] -[ValidateLength(1, 15)] +[ValidateLength(1, 15)] [System.String] $Name,

SQL Server edition and version

Microsoft SQL Server 2022 (RTM-CU11) (KB5032679) - 16.0.4105.2 (X64)   Nov 14 2023 18:33:19   Copyright (C) 2022 Microsoft Corporation  Developer Edition (64-bit) on Windows Server 2022 Standard 10.0 <X64> (Build 20348: ) (Hypervisor)

SQL Server PowerShell modules

SqlServer 22.1.1

Operating system

OsName               : Microsoft Windows Server 2022 Standard
OsOperatingSystemSKU : StandardServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version

Name                           Value
----                           -----
PSVersion                      5.1.20348.2227
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.20348.2227
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

SqlServerDsc version

SqlServerDsc 16.5.0  D:\DSCAnsible\output\RequiredModules\SqlServerDsc\16.5.0\SqlServerDsc.psd1
johlju commented 7 months ago

Is this the same as discussed in issue #513?

steffenengelhamburg commented 7 months ago

Hi Johlju, of course, it‘s the same issue / Change Request. I searched around the issue list with the error above but didn‘t found this issue.

I think this one can be closed if the change will be commited. I don‘t need more than 16 chars as listenername like in #513 but support a no length limit.

Thank you! Greetings from Hamburg Steffen

johlju commented 7 months ago

The NETBOIS-compatible host names has a limit of 15 chars, that is why the resource has that limit.

The limit is simply from the NETBIOS protocol, which has a limit of 16 bytes for the computername. The last byte in Windows networking is used for a service ID, hence the 15 byte (characters) limit on NETBIOS-compatible hostnames. https://techcommunity.microsoft.com/t5/windows-server-for-it-pro/hostname-character-limit/m-p/1068231

But the issue #513 suggest to remove the length entirely so then it is up to the user to make the correct choice depending on use-case.

So happy to see a PR that removes the limit and also updates the documentation that the user must be aware the choice it must make.

johlju commented 7 months ago

Closing this in favor of #513.