Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional “Terminate On Abort” mode to the WinRM node executor so that aborting a Rundeck job can terminate the remote WinRM command and its entire child process tree (via PID capture + taskkill /F /T), addressing orphaned processes on Windows nodes.
Changes:
- Added remote PID capture + streaming output marker filtering and an abort-time termination routine (
terminate_remote) that combines WS-Man terminate +taskkill /T. - Wired abort handling into the WinRM execution flow (signal handling, PID propagation via a tracker object).
- Added user-facing configuration and documentation plus unit tests for the kill helpers.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
contents/winrm_kill.py |
New PID marker/preamble, output filtering, and remote termination orchestration. |
contents/winrm-exec.py |
Integrates terminate-on-abort behavior (signal handling, wrapping commands, filtering marker output). |
contents/winrm_session.py |
Exposes live WinRM handles (shell/command IDs) to support abort-time termination. |
plugin.yaml |
Adds the new terminateonabort configuration option. |
README.md |
Documents “Terminate On Abort” behavior and operational notes. |
tests/test_winrm_kill.py |
Unit tests for PID parsing/stripping, streaming filter, and terminate orchestration. |
contents/common.py |
Minor regex literal cleanup (raw strings). |
.gitignore |
Ignores common Python build/test artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+438
to
+442
| # Emit any output still buffered in the marker filter (e.g. a final line with no | ||
| # trailing newline). | ||
| tail = marker_filter.flush() | ||
| if tail: | ||
| realstdout.write(tail) |
Jesus-Osuna-M
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces robust process tree termination for WinRM-executed jobs on Windows nodes, addressing the long-standing issue where aborting a job left remote processes running. The main feature is an optional "Terminate On Abort" mode, which—when enabled—ensures that aborting a job kills both the remote command and all its child processes. This is achieved by capturing the remote process PID and force-killing the process tree on abort. The implementation includes new code for PID capture, output filtering, and remote termination, as well as user-facing documentation and configuration options.
The most important changes are:
Process Tree Termination Feature:
plugin.yaml,README.md). When enabled, aborting a job will terminate the remote command and its entire process tree on the Windows node. This is disabled by default for backward compatibility. [1] [2] [3]Implementation of Remote PID Capture and Termination:
winrm_kill.pythat provides:MarkerFilterclass for streaming output filtering,taskkillcommand to kill the entire process tree on abort.Integration with Job Execution Flow:
winrm-exec.pyto:WinRM Session Enhancements:
winrm_session.pyto:Documentation:
README.mdwith a new "Aborting jobs" section, explaining the new behavior, configuration, and technical details for users and operators.These changes collectively ensure that aborting a WinRM-executed job on Windows nodes can now reliably clean up all spawned processes, improving reliability and resource management.