Skip to content

Commit 8a35103

Browse files
mattisonchaofreeznetCopilot
authored
fix(apiserver-resources): ignore not-found errors during deletion (#386)
* fix(rolebinding): ignore not-found error during deletion When deleting a RoleBinding, if the resource doesn't exist on the cloud API server, treat it as success instead of retrying indefinitely. This prevents the controller from getting stuck in an error loop during helm uninstall when the remote resource was already cleaned up. * test(controllers): cover not-found deletion for apiserver resources Agent-Logs-Url: https://github.com/streamnative/pulsar-resources-operator/sessions/b16d9baf-494b-4238-a360-615646daac66 Co-authored-by: freeznet <1381618+freeznet@users.noreply.github.com> * fix(controllers): unify delete-time not-found handling Agent-Logs-Url: https://github.com/streamnative/pulsar-resources-operator/sessions/ee155778-92d2-4761-a44d-8ea1051096ed Co-authored-by: freeznet <1381618+freeznet@users.noreply.github.com> --------- Co-authored-by: Rui Fu <freeznet@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: freeznet <1381618+freeznet@users.noreply.github.com>
1 parent 64d4f9d commit 8a35103

9 files changed

Lines changed: 638 additions & 21 deletions

controllers/apikey_controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,11 @@ func (r *APIKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
213213
if !apiKey.DeletionTimestamp.IsZero() {
214214
if controllerutil.ContainsFinalizer(apiKey, APIKeyFinalizer) {
215215
if err := apiKeyClient.DeleteAPIKey(ctx, apiKey); err != nil {
216-
if !apierrors.IsNotFound(err) {
216+
if !ignoreDeleteNotFound(logger, err, "Remote APIKey already deleted or not found", "apiKey", apiKey.Name) {
217217
r.updateAPIKeyStatus(ctx, apiKey, err, "DeleteFailed",
218218
fmt.Sprintf("Failed to delete external resources: %v", err))
219219
return ctrl.Result{}, err
220220
}
221-
logger.Info("Remote APIKey already deleted or not found",
222-
"apiKey", apiKey.Name)
223221
}
224222
controllerutil.RemoveFinalizer(apiKey, APIKeyFinalizer)
225223
if err := r.Update(ctx, apiKey); err != nil {

0 commit comments

Comments
 (0)