Skip to content

fix(GPTEINFRA-18860): fix ServiceAccessConfig cleanup on ResourceClaim delete - #4012

Open
aleixhub wants to merge 1 commit into
mainfrom
fix/service-access-manager-resourceclaim-delete
Open

aleixhub wants to merge 1 commit into
mainfrom
fix/service-access-manager-resourceclaim-delete

Conversation

@aleixhub

Copy link
Copy Markdown
Contributor

Problem

When a shared ResourceClaim is deleted, service-access-manager's delete handler (resourceclaim.py) crashes:

service_access_config = await service_access_config.ServiceAccessConfig.fetch(...)

It references the local variable service_access_config, which this same statement is assigning, instead of the serviceaccessconfig module. The module also wasn't imported. This raises UnboundLocalError, which the except k8sApiException doesn't catch.

Impact

Low. The ServiceAccessConfig's own 60s timer notices the ResourceClaim is gone and deletes itself, along with its Role, RoleBinding and ServiceAccess objects. In practice the bug causes:

  • an error traceback in the operator logs on every shared ResourceClaim delete
  • up to about 60s of delay before shared access is cleaned up

Fix

Use serviceaccessconfig.ServiceAccessConfig.fetch(...), importing the module inside the handler.

The import has to be inside the function, not at the top of the file. operator.py imports resourceclaim first, and serviceaccessconfig does from resourceclaim import ResourceClaim. A top-level import would fail at startup with a circular ImportError. I checked both variants by importing the modules in operator.py's order with stubbed dependencies: the function-level import loads cleanly, and the top-level one fails.

Testing

  • Share a service (ResourceClaim), then delete it. The ServiceAccessConfig, Role, RoleBinding and ServiceAccess are removed right away, with no traceback in the service-access-manager logs.

🤖 Generated with Claude Code

…rceClaim delete

The ResourceClaim delete handler referenced the local variable
service_access_config instead of the serviceaccessconfig module, which
raised UnboundLocalError and left the ServiceAccessConfig to be removed
later by its own 60s timer. Import the module inside the handler to
avoid a circular import with serviceaccessconfig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aleixhub aleixhub changed the title fix(service-access-manager): fix ServiceAccessConfig cleanup on ResourceClaim delete fix(GPTEINFRA-18860): fix ServiceAccessConfig cleanup on ResourceClaim delete Nov 20, 2026

This branch has not been deployed

No deployments
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.

1 participant