dsccommunity / dsccommunity/SqlServerDsc

SqlSetup: Test-TargetResource should test whether service is running

Open
#1,256 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
PowerShell
Stars
385
Forks
224
PR merge metrics
No merged PRs in 30d

Description

Scenario:
I am using SQLServerDSC 12.1.0.0 to install SQL Server 2016 SP2 on a Windows 2016 Server Datacenter Core VM on an A2 size plan in the ASDK for Microsoft Azure Stack (MAS). I am using this as a test and to play around with DSC and the azure DSC Extension.

The error:
When the deployment process is finished, the MAS deployment gives me the following error.

Error message: DSC Configuration 'SQLConfiguration' completed with error(s). Following are the first few: PowerShell DSC resource MSFT_SqlSetup failed to execute Test-TargetResource functionality with error message: System.InvalidOperationException: Failed to connect to SQL instance 'MYSQLVM'.

Troubleshooting:
Checking the SQL installation log, I find that the setup itself was successful. I followed this up by checking whether the MSSQLSERVER service was running. It turns out, it was not. I manually started the service; running the Start-DscConfiguration in verbose gave me a pass on all tests.

Cause:
After checking the event log, I found out that the services time-out during start-up. In all likelihood, my VM is not powerful enough to handle the start-up of all services in a timely manner even though the server runs on the core edition and the VM size meets the minimum requirements for SQL Server 2016.

Quick solution:
As this is a test case and it doesn't need to be pretty, I solved this problem by changing the default servicepipetimeout to 4 minutes. My deployment now passes. I chose not to increase the VM size as space on our ASDK is very limited. I also chose not to use the service resource to make sure the required services are running, because the resulting IF statement proved a bit too difficult to make with my current understanding of DSC.

Suggestion:
In order to facilitate troubleshooting, I suggest the Test-TargetResource performs a test to see if the required services, such as MSSQLSERVER, are running before it tries to test the connection.

Code for those interested:

Registry Sevicespipetimeout {
Key = "hklm:\system\currentcontrolset\control"
ValueName = "servicespipetimeout"
ValueData = "240000"
ValueType = "Dword"
Ensure = "Present"

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 at the SqlSetup Test-TargetResource entry point and trace how it checks the SQL connection and required services, especially MSSQLSERVER. Confirm the expected behavior with the existing resource tests; done means a stopped required service is detected before connection testing and running configurations continue to pass.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.