Skip to content

Comments

[fix] util stop_backend() should always try odemis-stop if nice request fails#3348

Open
pieleric wants to merge 1 commit intodelmic:masterfrom
pieleric:fix-util-stop_backend-should-always-try-odemis-stop-if-nice-request-fails
Open

[fix] util stop_backend() should always try odemis-stop if nice request fails#3348
pieleric wants to merge 1 commit intodelmic:masterfrom
pieleric:fix-util-stop_backend-should-always-try-odemis-stop-if-nice-request-fails

Conversation

@pieleric
Copy link
Member

@pieleric pieleric commented Feb 6, 2026

If the backend does stop in time, it would call odemis-stop... however
if the backend didn't even accept the request to stop, it would bail out
immediately.
=> also call odemis-stop in such case. That should help for some
automatic run of test cases

…st fails

If the backend does stop in time, it would call odemis-stop... however
if the backend didn't even accept the request to stop, it would bail out
immediately.
=> also call odemis-stop in such case. That should help for some
automatic run of test cases
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

The stop_backend function in the testing utility was modified to improve backend termination handling. Instead of raising an exception when the kill command returns a non-zero exit code, the function now treats this as a non-fatal error, marking the backend as DEAD and logging a warning. On successful kill (zero return code), the function implements a polling mechanism that waits up to 15 seconds for the backend to reach a stopped state, checking status repeatedly and logging progress. If the status remains in BUSY state after the timeout, a warning is issued and an optional fallback path attempts force-stop via sudo. Status initialization was added at the start of the success path, and the conditional branches were restructured with updated logging messages.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: ensuring stop_backend() calls odemis-stop even when the nice request fails.
Description check ✅ Passed The description explains the problem (backend not accepting stop request) and the solution (also calling odemis-stop in such cases), which aligns with the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the test utility stop_backend() to be more robust by attempting a force-stop (odemis-stop) even when the initial “polite” stop request fails, improving reliability for automated test runs.

Changes:

  • Change stop_backend() flow to only wait for shutdown when the initial odemisd --kill succeeds.
  • When the odemisd --kill command fails, proceed to the fallback path (instead of raising immediately).

Comment on lines 155 to +157
else:
logging.warning("Backend still stopping after 15 s")
status = driver.BACKEND_DEAD
logging.warning("Failed stopping backend with '%s' (returned %d)", cmd, ret)
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

On non-zero return from the odemisd --kill command, this sets status = driver.BACKEND_DEAD, which forces the later sudo odemis-stop path even when there is actually no backend running (e.g. odemisd --kill exits non-zero with "No running back-end to kill"). Consider setting status = driver.get_backend_status() (or at least checking for BACKEND_STOPPED) so sudo odemis-stop is only attempted when the backend is still running/unresponsive.

Copilot uses AI. Check for mistakes.
Comment on lines 155 to +157
else:
logging.warning("Backend still stopping after 15 s")
status = driver.BACKEND_DEAD
logging.warning("Failed stopping backend with '%s' (returned %d)", cmd, ret)
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The new behavior for the ret != 0 branch (falling back to sudo odemis-stop when the polite stop request fails) isn’t covered by a test. Adding a unit test that mocks subprocess.call to return non-zero and asserts the correct fallback behavior (and that it avoids calling sudo when get_backend_status() is already BACKEND_STOPPED) would help prevent regressions.

Copilot generated this review using guidance from repository custom instructions.
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.

3 participants