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

core: get a cancelation context to the ephemeral resources #35778

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Sep 25, 2024

This turned out to be a very simple change to get the correct cancellation context into ephemeral resources. The internal terraform EvalContext has a very old Stopped method which returned a channel instead of a Context, and was never used.

Replace the Stopped method with StopCtx which returns the full context.Context so we can forward that into the ephemeral resource calls.

The existing Stopped method predates the use of a context, returning a
simple channel for signaling cancellation. The method was not used
however, so we can just update it to return a context to give us access
to cancellation for ephemeral values.
@jbardin jbardin requested a review from a team September 25, 2024 16:23
Copy link
Collaborator

@DanielMSchmidt DanielMSchmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍 Could we theoretically use a similar mechanism through the eval context to add tracing to the graph evaluation?

// We might be closing due to a context cancellation, but we still need to
// be able to make non-canceled Close requests.
//
// TODO: if we're going to ignore the cancellation to ensure that Close is
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a timeout (or a force cancel?) would make sense

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to think on that, since anytime you pick a timeout it's going to be wrong for some situation. This is already in a path that shouldn't be happening under normal circumstances though, so maybe it doesn't really matter so much.

@jbardin
Copy link
Member Author

jbardin commented Sep 26, 2024

We might be able to hook tracing into that, but the context handling in Terraform is a bit strange due to it's CLI nature. We also need to decide exactly what we'd want to get from tracing that logging doesn't already give us, the graph evaluation tends to be the uninteresting part when tracking down runtime issues.

@jbardin jbardin merged commit bb476a3 into main Sep 26, 2024
6 checks passed
@jbardin jbardin deleted the jbardin/ephemeral-cancel branch September 26, 2024 13:50
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants