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

Add Lifecycle Hooks for Opening and Closing Handles During Configuration and Shutdown #261

Open
zbuchheit opened this issue Aug 5, 2024 · 3 comments
Labels
awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/enhancement Improvements or new features

Comments

@zbuchheit
Copy link
Contributor

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

It would be beneficial to execute a hook that opens a handle during configuration and closes the handle during shutdown. This would be particularly useful for providers that require a sync or commit action upon closure.

Affected area/feature

Related: pulumi/pulumi#9780

@zbuchheit zbuchheit added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels Aug 5, 2024
@mjeffryes mjeffryes removed the needs-triage Needs attention from the triage team label Aug 5, 2024
@iwahbe iwahbe added the awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). label Aug 6, 2024
@iwahbe
Copy link
Member

iwahbe commented Aug 6, 2024

I'm labeling as awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). because we need a life-cycle hook from Pulumi to make this work reliably.

@joeduffy
Copy link
Member

@iwahbe Wasn't sure what you meant by this. The need is to have a Close or Shutdown method on the provider itself that we invoke so that the provider can tidy up any resources, or perform shutdown actions like flushing logs, etc. Is this truly awaiting something upstream, or can that be done in the provider interface itself? Might require a new gRPC call?

@iwahbe
Copy link
Member

iwahbe commented Feb 28, 2025

We would need a change in the gRPC protocol so that the provider can be told "please cleanup and exit gracefully". I see two options here:

  1. We can add a Shutdown method. The engine would be required to call Shutdown before shutting down a provider (irrespective of if Cancel was called).
  2. We can change the semantics of the existing Cancel call so that:
    a. Cancel is always called before a provider exits
    b. Cancel implies that the provider does not need to accept future gRPC connections.

I would advocate for (2), since it keeps a smaller API surface area for provider authors. This SDK already assumes (2b).

iwahbe added a commit that referenced this issue Feb 28, 2025
When I was answering
#261 (comment), I was
looking at our implementation of `Cancel`. I noticed there wasn't a test for this edge
case, and added one.
iwahbe added a commit that referenced this issue Feb 28, 2025
When I was answering
#261 (comment), I was
looking at our implementation of `Cancel`. I noticed there wasn't a test for this edge
case, and added one.
iwahbe added a commit that referenced this issue Feb 28, 2025
When I was answering
#261 (comment),
I was looking at our implementation of `Cancel`. I noticed there wasn't
a test for this edge case, and added one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

4 participants