-
Notifications
You must be signed in to change notification settings - Fork 58
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
HCP Cluster Resource Deletion Cascading Subscription Delete #920
Open
mbarnes
wants to merge
10
commits into
main
Choose a base branch
from
subscription-deletion
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+369
−182
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Works for any document type now, and just stores a slice rather than the entire cache for that document type.
A new function NewQueryItemsSinglePageIterator alters the behavior of QueryItemsIterator to stop after the first "page" of items and record the Cosmos DB continuation token. The continuation token can be retrieved from the iterator with GetContinuationToken. A QueryItemsIterator created with NewQueryItemsIterator will never have a continuation token because it iterates until the last item. The in-memory cache also adds a GetContinuationToken method to its iterator implementation to fulfill the interface contract, but it always returns an empty string.
For CosmosDBClient, the maxItems argument controls the type of iterator returned. A positive maxItems returns a single- page iterator with a possible continuation token, otherwise the iterator continues until the last item. Since the in-memory cache does not have continuation tokens, the maxItems argument is ignored. This also drops the resourceType argument. Callers first need to parse the iterator items into resource documents before checking the resource type.
Add "externalID" and "internalID" parameters so the returned document is a minimum valid OperationDocument for writing.
The operation item must now be created in the database prior to calling ExposeOperation. ExposeOperation does all its processing in a database update callback. This is because there is an increasing number of cases where we create an implicit async operation with no visible status endpoint. Calling ExposeOperation makes an implicit async operation explicit, with a status endpoint for ARM to poll. Hence the rename. The tradeoff is explicit asyncrhonous operations now require two database operations (create and update) but it helps make the RP logic cleaner. This could possibly be mitigated in the future by using Cosmos DB's transactional batch operations, but it's gonna take some serious refactoring to get there.
CancelActiveOperation marks the status of any active operation on the resource as canceled.
Will be reusing DeleteResource for subscription deletion. Add database bookkeeping for the resource and any child resources. This includes creating implicit operations for each resource being deleted. The caller may then expose the returned operation ID.
By my read of the Subscription Lifecycle API Reference [1], we should favor 200 OK over 201 Created when creating or updating a subscription. [1] https://github.com/cloud-and-ai-microsoft/resource-provider-contract/blob/master/v1.0/subscription-lifecycle-api-reference.md#response
Called when a subscription is deleted. The method is idempotent in case of multiple subscription PUT requests.
Don't count on OperationID being set in OperationDocuments. Implicit async operations will not have this field set. Get the subscription ID from ExternalID instead.
mbarnes
force-pushed
the
subscription-deletion
branch
from
December 4, 2024 17:56
d76b6ac
to
05f8144
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
When a subscription state changes to "Deleted", the RP now triggers a deletion of all HCP clusters under the subscription as per the Resource Provider Contract.
Behind the scenes, this introduces the concept of "implicit" and "explicit" async operations:
Frontend.ExposeOperation
method enriches the "Operation" item with information necessary to make the status endpoint accessible to ARM, and adds appropriate async headers to anhttp.ResponseWriter
.Importantly, the backend pod does not distinguish between implicit and explicit async operations. The sole purpose of an "implicit" async operation at the moment, which is only used for deletions, is for the backend to delete the "Resource" item in Cosmos DB after the actual resource is deleted.
Jira: ARO-13321 - Implement Cascading Subscription Deletion
Special notes for your reviewer