Skip to content

refactor(actor)!: Improve actor shutdown and supervisor lifecycle handling - #945

Merged
gfieni merged 5 commits into
masterfrom
refactor/actor-shutdown-flow
Oct 5, 2026
Merged

gfieni merged 5 commits into
masterfrom
refactor/actor-shutdown-flow

Conversation

@gfieni

@gfieni gfieni commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

PR overview:

  • Centralize actor teardown, including cleanup after setup and processing failures.
  • Always drain pending messages on poison-pill shutdown and remove shutdown mode flags.
  • Clean up failed initialization without registering the actor.
  • Stop and join backend stages in upstream-to-downstream order.
  • Make Kubernetes and OpenStack actors inherit from PreProcessorActor.
  • Simplify socket serialization and use the platform temporary directory for IPC paths.
  • Add regression tests for cleanup, failed launches, shutdown ordering, and timeouts.

Breaking changes:

  • Remove Actor.low_exception; processing errors propagate after cleanup.
  • Remove start_message from Supervisor.launch_actor().
  • Remove soft from PoisonPillMessage and graceful from shutdown and state teardown methods.
  • BackendSupervisor.kill_actors() now blocks until stages stop.
  • BackendSupervisor.launch_actor() rejects unsupported actor types.
  • SIGTERM now performs forced termination without cooperative teardown; SIGINT retains cleanup.

Make `KubernetesPreProcessorActor` and `OpenStackPreProcessorActor` inherit
from `PreProcessorActor` instead of the generic `ProcessorActor`.
Finalize actor state after shutdown, setup failures, and processing errors.
Preserve graceful shutdown intent and skip unstarted pollers and monitors.

BREAKING CHANGE: Remove `Actor.low_exception`; processing errors now
propagate after cleanup.
@gfieni gfieni self-assigned this Oct 5, 2026
@gfieni
gfieni requested a review from a team as a code owner October 5, 2026 13:13
@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.08738% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.73%. Comparing base (b017d46) to head (9bab91a).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
src/powerapi/actor/actor.py 87.50% 2 Missing ⚠️
.../powerapi/backend_supervisor/backend_supervisor.py 96.96% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #945      +/-   ##
==========================================
+ Coverage   84.28%   86.73%   +2.44%     
==========================================
  Files          81       81              
  Lines        2826     2820       -6     
==========================================
+ Hits         2382     2446      +64     
+ Misses        444      374      -70     
Files with missing lines Coverage Δ
src/powerapi/actor/handler.py 83.33% <100.00%> (ø)
src/powerapi/actor/message.py 100.00% <ø> (ø)
src/powerapi/actor/socket_interface.py 100.00% <100.00%> (ø)
src/powerapi/actor/state.py 89.28% <100.00%> (ø)
src/powerapi/actor/supervisor.py 100.00% <100.00%> (ø)
src/powerapi/dispatcher/dispatcher_actor.py 81.39% <100.00%> (ø)
src/powerapi/formula/formula_actor.py 100.00% <100.00%> (ø)
src/powerapi/processor/pre/k8s/actor.py 100.00% <100.00%> (ø)
src/powerapi/processor/pre/openstack/actor.py 100.00% <100.00%> (ø)
src/powerapi/puller/puller_actor.py 92.10% <100.00%> (+0.21%) ⬆️
... and 3 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/powerapi/backend_supervisor/backend_supervisor.py Dismissed
gfieni added 3 commits October 5, 2026 15:23
…rder

Clean up failed actor initialization without registering the actor.
Stop and join each pipeline stage before stopping downstream stages.

BREAKING CHANGE: Removed `start_message` parameter of `launch_actor`.
`kill_actors` now waits for stage shutdown.
Use the platform temporary directory for IPC endpoints.
Replace serialization wrappers with direct PyZMQ calls.
Always drain pending messages when handling a poison pill.
Remove shutdown mode propagation and simplify lifecycle tests.

BREAKING CHANGE: Remove `soft` argument from `PoisonPillMessage`,
and the `graceful` argument from `ActorProxy.kill`, `State.teadown`
and `Supervisor.kill_actors` methods.
@gfieni
gfieni force-pushed the refactor/actor-shutdown-flow branch from 121c8f7 to 9bab91a Compare October 5, 2026 13:23
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

@gfieni
gfieni merged commit 6f9ebfd into master Oct 5, 2026
10 checks passed
@gfieni
gfieni deleted the refactor/actor-shutdown-flow branch October 5, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants