Skip to content

Fix Service.Restart double-restart and waitState busy loop - #337

Merged
kke merged 2 commits into
mainfrom
fix/service-restart-polling
May 7, 2026
Merged

kke merged 2 commits into
mainfrom
fix/service-restart-polling

Conversation

@kke

@kke kke commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Service.Restart fell through to Stop+Start even when RestartService succeeded, causing the service to be restarted twice. Add return after waitState to stop the fallthrough.

Service.waitState spun in a tight busy loop with no delay between ServiceIsRunning checks. Add a 100..1000ms (backoff) poll interval so the loop yields between probes; context cancellation is still immediate via select.

Also adds tests for Start, Stop, and Restart lifecycle methods, which previously had no coverage.

@kke kke added the bug Something isn't working label May 7, 2026
@kke
kke requested a review from Copilot May 7, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes Service.Restart behavior to avoid a second Stop+Start cycle after a successful native restart, and updates Service.waitState to avoid a tight busy loop by introducing a polling interval. Adds unit tests covering the service Start/Stop/Restart lifecycle methods.

Changes:

  • Prevent Service.Restart from falling through to Stop+Start when RestartService succeeds (and wait for started state after native restart).
  • Add a fixed poll interval to waitState so state checks yield between probes.
  • Add tests for Start, Stop, and Restart, including native-restart and cancellation/error cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
service.go Fix restart fallthrough; add polling interval to waitState.
service_test.go Add lifecycle tests and supporting mocks for Start/Stop/Restart.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread service.go Resolved
@kke
kke force-pushed the fix/service-restart-polling branch from dc60581 to 45bbe94 Compare May 7, 2026 07:59
@kke
kke requested a review from Copilot May 7, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread service_test.go Resolved
Comment thread service_test.go Resolved
Service.Restart fell through to Stop+Start even when RestartService
succeeded, causing the service to be restarted twice. Add return after
waitState to stop the fallthrough.

Service.waitState spun in a tight busy loop with no delay between
ServiceIsRunning checks. Add a 500ms fixed poll interval so the loop
yields between probes; context cancellation is still immediate via select.

Also adds tests for Start, Stop, and Restart lifecycle methods, which
previously had no coverage.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
@kke
kke force-pushed the fix/service-restart-polling branch from 45bbe94 to aeea217 Compare May 7, 2026 08:05
@kke
kke requested a review from Copilot May 7, 2026 08:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread service.go Resolved
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread service.go Resolved
@kke
kke marked this pull request as ready for review May 7, 2026 08:20
@kke
kke merged commit 9bf8556 into main May 7, 2026
15 checks passed
@kke
kke deleted the fix/service-restart-polling branch May 7, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants