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

Implement provider cancellation #3224

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Conversation

danielrbradley
Copy link
Member

Attempt to gracefully shut down the provider if the engine indicates that we need to halt operations.

Fixes #1055

Attempt to gracefully shut down the provider if the engine indicates that we need to halt operations.

Fixes #1055
Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 55.32%. Comparing base (fabbaf4) to head (d422a42).

Files Patch % Lines
provider/pkg/provider/provider.go 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3224      +/-   ##
==========================================
+ Coverage   55.28%   55.32%   +0.03%     
==========================================
  Files          66       66              
  Lines        9917     9929      +12     
==========================================
+ Hits         5483     5493      +10     
- Misses       4002     4004       +2     
  Partials      432      432              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1007,6 +1016,8 @@ func (k *azureNativeProvider) findUnsetPropertiesToMaintain(res *resources.Azure

// Read the current live state associated with a resource.
func (k *azureNativeProvider) Read(ctx context.Context, req *rpc.ReadRequest) (*rpc.ReadResponse, error) {
// Use the global context to handle provider shutdown.
ctx = k.context
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it really correct to disregard the passed-in context? Can you explain why?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is exactly what aws-native and kubernetes do. I think by the time the request gets cancelled, we're way past being able to actually do anything to shut down cleanly. This is why the cancellation exists externally.

My first pass of this was to do something fancy with combining the contexts to make it an OR between the two cancellations, but I think it's significantly harder to reason about in practice and this appears sufficient from other providers.

@danielrbradley danielrbradley merged commit 6e5d10a into master Apr 18, 2024
24 checks passed
@danielrbradley danielrbradley deleted the 1055-fix-cancellation branch April 18, 2024 18:38
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.

Cooperative cancellation of in-progress operations
2 participants