Skip to content

Add Microsoft.Windows.Action/RestartService action - #1796

Open
Steve Lee (SteveL-MSFT) wants to merge 3 commits into
mainfrom
stevel-msft-restart-service-action
Open

Steve Lee (SteveL-MSFT) wants to merge 3 commits into
mainfrom
stevel-msft-restart-service-action

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Setting a service's desired status to Running does not restart an already running service. This adds Microsoft.Windows.Action/RestartService for configurations that need an explicit restart on every set operation.

  • Stop the service, wait for it to stop, then start it and wait for Running. Start an already stopped service without changing its configuration or forcing dependent services to stop.
  • Require elevation and support non-mutating what-if previews with projected state and _metadata.whatIf.
  • Replace windows_service.dsc.resource.json with windows_service.dsc.manifests.json, preserving the existing Service resource and adding the action. Update build/package references and documentation.
  • Add Spooler coverage for repeated restarts, stopped and disabled services, input validation, discovery, and previews, with original state restoration. Scope existing CLI/MCP action-list assertions to test actions so built-in actions do not break their counts.

Validation

  • build.ps1 -Project windows_service -Clippy succeeded.
  • Targeted windows_service Pester suite: 49 passed, 24 skipped.
  • New restart tests with Pester 5.7.1: 11 passed, 8 skipped.
  • CLI/MCP action-list regression tests: 2 passed.
  • Confirmed the existing resource manifest is unchanged semantically and restart preview output matches the action output schema.

Limitation: Elevated restart scenarios could not be exercised because the local session is not running as administrator. Spooler remained stopped and disabled.

Add native service restart handling and combine the Service resource and RestartService action in a manifest list. Include Spooler coverage, what-if support, packaging updates, and action discovery regression adjustments.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The elevated preview test asserts metadata in the wrong location, and incremental builds retain an obsolete manifest that causes duplicate service discovery and fails the count assertion.

2 open issues
What changed in this PR

Adds Microsoft.Windows.Actions/RestartService for configurations that need an explicit restart on every set operation, rather than only ensuring a service is running.

Changes:

  • Implements elevated restart execution and non-mutating what-if previews.
  • Combines the existing Service resource and new action in one manifest list, updating build, packaging, and documentation references.
  • Adds restart coverage and scopes CLI/MCP action-list assertions to test actions.
File Description
resources/​windows_service/​windows_service.dsc.resource.json Removes the standalone resource manifest.
resources/​windows_service/​windows_service.dsc.manifests.json Preserves Service and registers RestartService with input/output schemas.
resources/​windows_service/​tests/​windows_service_restart.tests.ps1 Adds discovery, validation, preview, and restart tests with state restoration.
resources/​windows_service/​src/​types.rs Adds restart input and result types.
resources/​windows_service/​src/​service.rs Implements restart behavior and shares pending-status handling.
resources/​windows_service/​src/​main.rs Dispatches restart requests and generalizes input deserialization.
resources/​windows_service/​locales/​en-us.toml Adds restart messages and updates usage text.
resources/​windows_service/​.project.data.json Copies the combined manifest during project builds.
dsc/​tests/​other/​dsc_server.tests.ps1 Filters MCP action-list assertions to test actions.
dsc/​tests/​other/​dsc_actions.tests.ps1 Limits CLI action-list queries to test actions.
docs/​reference/​resources/​Microsoft/​Windows/​Service/​index.md Documents restart usage, limitations, and previews.
data.build.json Updates build and package manifest references.
.github/​skills/​create-dsc-resource/​SKILL.md Points resource-creation guidance to the combined manifest’s resource entry.

Review effort: Balanced

Comment thread data.build.json Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@SteveL-MSFT Steve Lee (SteveL-MSFT) changed the title Add Microsoft.Windows.Actions/RestartService action Add Microsoft.Windows.Action/RestartService action Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

😁 Code Coverage Report

Changed Code Coverage

90% (90%+ coverage)

Metric Value
Changed lines analyzed 62
Lines covered by tests 56
Coverage percentage 90%

🔵 Full Codebase Coverage

83% (good)

Metric Value
Total executable lines 21053
Lines covered by tests 17524
Coverage percentage 83%

Changed code coverage measures only Rust lines added/modified in this PR.
Full codebase coverage measures all instrumented Rust lines across the project.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The documentation incorrectly locates the configuration preview message at _metadata.whatIf instead of results[0].metadata.whatIf, preventing consumers from finding it at the documented path.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Low severity Document the configuration preview at the correct result path

docs/​reference/​resources/​Microsoft/​Windows/​Service/​index.md:102

For the documented dsc config set --what-if command, the preview message is exposed at results[0].metadata.whatIf, not _metadata.whatIf: configuration processing moves _metadata out of afterState (lib/dsc-lib/src/configure/mod.rs:400–475). Please distinguish the configuration result path from the raw action output so consumers can locate the preview message.

2 resolved since last review

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants