Skip to content

Conversation

@Diaphteiros
Copy link
Contributor

What this PR does / why we need it:
When working with the ClusterAccess library and trying to delete resource, one should theoretically call Reconcile at the beginning of the deletion logic, ensuring the access to the cluster exists so resources on the cluster can be deleted. After that is done, one should call ReconcileDelete to delete the resources for the cluster access itself.
This was not possible so far, because when walking through the deletion logic multiple times (because it waits for resources to be removed), the call to Reconcile would re-create resources that had already been deleted by ReconcileDelete, causing the deletion to be stuck in an endless loop.

This PR changes the clusteraccess library's logic in two ways:

  1. Resources created by the library now have a finalizer. During deletion, these finalizers will only be removed after all other finalizers (usually from the ClusterProvider) have been removed too. This change means that all AccessRequests are now deleted simultaneously (instead of only one at a time as before) and while the AccessRequest is not yet done, it can still be retrieved via the AccessRequest method.
  2. The ClusterAccess Reconciler now remembers requests for which the resources are in deletion. It does so by storing the request internally when ReconcileDelete is first called and by removing the request from the internal storage again when ReconcileDelete returns without a RequeueAfter value and without an error. As long as a request is part of the internal storage, calling Reconcile for this request will not create any new resources. This makes it possible to call Reconcile during the controller's deletion logic without having to worry about it re-creating already deleted resources.

Which issue(s) this PR fixes:
Fixes #192

Special notes for your reviewer:

Release note:

The ClusterAccess Reconciler's `Reconcile` method can now be called during the deletion logic of the embedding controller without re-creating resources that have already been deleted by an earlier `ReconcileDelete` call. This means `Reconcile` can now be called at the beginning of a deleting reconciliation and `ReconcileDelete` at the end, without resources being created and deleted endlessly when walking through this deletion flow multiple times (because the request is reconciled multiple times because it needs to wait for resources being deleted).

@Diaphteiros Diaphteiros merged commit 6680414 into main Oct 30, 2025
5 checks passed
@Diaphteiros Diaphteiros deleted the improve-clusteraccess branch October 30, 2025 14:06
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.

Improve ClusterAccess library behavior

3 participants