Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 4, 2022
Merged

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

merged 1 commit into from
Apr 4, 2022

Conversation

soelinn
Copy link
Contributor

@soelinn soelinn commented Mar 28, 2022

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
Member

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

@soelinn
Copy link
Contributor Author

soelinn commented Mar 28, 2022

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.

@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
@TingluoHuang TingluoHuang merged commit 7b677e0 into actions:main 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