Skip to content

Conversation

@orgads
Copy link

@orgads orgads commented Nov 19, 2025

Previously, Terraform would not respect a SIGINT (Ctrl+C) if it occurred during the graph walk phase, specifically if a provider operation was about to start or blocked. This was because the context cancellation was not being propagated effectively to the graph walker or checked before starting new operations.

This commit introduces a StopContext to the Terraform Core Context, which is linked to the operation's stop context. The GraphWalker now checks this context before executing nodes. Additionally, the local backend now properly sets this context and handles early cancellation by returning immediately if the context is cancelled during the plan phase.

A regression test TestLocal_applyStopEarly has been added to verify that the operation aborts immediately when cancelled.

Fixes #31371

Target Release

1.14.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.
@orgads orgads requested a review from a team as a code owner November 19, 2025 21:06
Previously, Terraform would not respect a SIGINT (Ctrl+C) if it occurred
during the graph walk phase, specifically if a provider operation was
about to start or blocked. This was because the context cancellation
was not being propagated effectively to the graph walker or checked
before starting new operations.

This commit introduces a StopContext to the Terraform Core Context,
which is linked to the operation's stop context. The GraphWalker now
checks this context before executing nodes. Additionally, the local
backend now properly sets this context and handles early cancellation
by returning immediately if the context is cancelled during the plan
phase.

A regression test TestLocal_applyStopEarly has been added to verify
that the operation aborts immediately when cancelled.

Fixes hashicorp#31371
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants