Skip to content

Mark run as Cancelled/Failed upon HostContext.RunnerShutdownToken state - #1792

Merged
TingluoHuang merged 1 commit into
actions:mainfrom
soelinn:users/soelinn/shutdown-result-change
Apr 4, 2022
Merged

TingluoHuang merged 1 commit into
actions:mainfrom
soelinn:users/soelinn/shutdown-result-change

Conversation

@soelinn

@soelinn soelinn commented Mar 28, 2022 •

Copy link
Copy Markdown
Contributor

github/c2c-actions-support#883

  • Currently when Actions Runner shuts down for any ShutdownReason, Workflow Run ends as Cancelled.
  • ShutdownReason.OperatingSystemShutdown only occurs for Windows platform, and shutdown causes on other platforms are hard to detect accurately.
  • Requirement Change
    • ✅ SAME: User Cancellation from the GitHub UI remains the same ➡️ TaskResult.Cancelled.
    • ⚠️ CHANGE: Mark Workflow Run as TaskResult.Failed after receiving a runner shutdown signal (e.g., SIGTERM)
      • This TaskResult.Failed state can only be occur if the Runner process can report its shutdown state back to the Actions Service successfully before exiting.
      • I coded this behavior change by depending on the HostContext.RunnerShutdownToken.IsCancellationRequested when the Runner process receives a Ctrl-C or Ctrl-Break signal. It will only be able to report back to the Actions Service upon SIGTERM as SIGKILL will be immediate, and won't allow graceful shutdown.
    • If Runner process exiting due to Ctrl-C SIGTERM by user manually ➡️ TaskResult.Failed

@soelinn
soelinn requested a review from a team as a code owner March 28, 2022 20:25
@TingluoHuang

Copy link
Copy Markdown
Member

FYI, you might only get OperatingSystemShutdown when you are on Windows and configure the runner as a Windows service.

@soelinn

soelinn commented Mar 28, 2022

Copy link
Copy Markdown
Contributor Author

I expected it'll be cases like this, and I might not be able to handle it reliably and distinguish between UserCancellation vs OS shutdown. I will probably need to consult @chrispat.

Comment thread src/Runner.Common/HostContext.cs Resolved
@soelinn
soelinn dismissed a stale review via ab54aee April 4, 2022 15:59
@soelinn soelinn changed the title Mark run as Cancelled/Failed depending on ShutdownReason Mark run as Cancelled/Failed upon HostContext.RunnerShutdownToken state Apr 4, 2022
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