Skip to content

fix: check GCP registry consumers without decoding whole deployment records - #937

Merged
alongubkin merged 3 commits into
mainfrom
alon/alien-1265-gcp-registry-revoke
Oct 8, 2026
Merged

alongubkin merged 3 commits into
mainfrom
alon/alien-1265-gcp-registry-revoke

Conversation

@alongubkin

Copy link
Copy Markdown
Member

Summary

When a GCP deployment is deleted, the manager removes the project's shared Cloud Run grant on the artifact registry only if no other deployment runs in that project. It checked this by listing every GCP deployment as a full DeploymentRecord. That decode includes stack and runtime state. If one record carries a resource config that the current types reject (for example, a prepared Worker from an older release that still has ingress), the whole list fails. Then every GCP revoke on that manager fails, and deleted deployments keep read access to the registry. The failure happens after the deletion is committed, so nothing retries it.

  • DeploymentStore::has_other_gcp_project_deployment(caller, project_number, excluding_deployment_id) answers that one question. The default implementation reads list_deployments, so the SQLite store behaves the same as before. A store that can read a deployment's id, status and environment without decoding the rest of the record should override it.
  • revoke_registry_access uses it. If the check cannot be answered, it still fails closed: the grant stays and the revoke returns REGISTRY_ACCESS_CLEANUP_FAILED.

Testing

  • the_last_deployment_in_a_gcp_project_revokes_its_shared_grant, a_shared_grant_stays_while_another_deployment_uses_the_project, an_unanswered_consumer_check_keeps_the_grant_and_fails_the_revoke: these run revoke_registry_access against a recording registry and a mock store. The mock store fails the test if the revoke calls list_deployments.
  • only_another_deployment_in_the_same_project_keeps_the_shared_grant: tests the default implementation against a real SQLite store (self, another project, a sibling, then the sibling removed).
  • cargo test -p alien-manager --lib: 316 passed (Linux sandbox, CARGO_INCREMENTAL=0, debuginfo off).
  • I also checked a store override that reads only placement fields against a mock HTTP API. With a record that has a legacy Worker config: the full-record list fails, and the override still gives the right answer for both the same project and another project.

🤖 Generated with Claude Code

…ecords

A GCP revoke removes the project's shared Cloud Run grant only when no
other deployment runs in that project. It answered that by listing every
GCP deployment as a full record. One record with stack or runtime state
the current types reject failed the list, so every GCP revoke failed and
deleted deployments kept read access to the registry.

Add DeploymentStore::has_other_gcp_project_deployment. The default reads
list_deployments, so the standalone store keeps its behavior; a store
that can read a deployment's id, status and environment without the rest
of the record overrides it. The revoke uses it and still fails closed
when the check cannot be answered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alongubkin

Copy link
Copy Markdown
Member Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Refactors GCP registry access revocation logic.

The PR appears safe to merge; the missing deleted-sibling coverage is restored.

What we checked:

  • Deleted siblings are covered: create_with_state stores the supplied status. The query does not filter out deleted rows, so the test checks that the consumer method excludes them.

Summary

The PR lets stores answer the shared GCP registry-grant question through has_other_gcp_project_deployment. Its default implementation preserves the existing behavior; stores can override it to avoid decoding whole records.

  • Registry cleanup keeps the shared grant when another deployment uses the project or the check fails.
  • The latest change restores coverage for a stored deleted sibling while keeping the hard-delete case.
  • No new actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[GCP registry cleanup] --> B[Ask store about other project deployments]
  B -->|Another deployment exists| C[Keep shared grant]
  B -->|Check fails| D[Keep grant and return cleanup error]
  B -->|No other deployment| E[Remove shared grant]
Loading

Reviews (3) · Last reviewed commit: "style: rustfmt the GCP consumer test" · Reviewed by Greptile

Comment thread crates/alien-manager/src/stores/sqlite/deployment.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alongubkin

Copy link
Copy Markdown
Member Author

@greptileai review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alongubkin

Copy link
Copy Markdown
Member Author

@greptileai review

@alongubkin
alongubkin merged commit e08730d into main Oct 8, 2026
24 checks passed
@alongubkin
alongubkin deleted the alon/alien-1265-gcp-registry-revoke branch October 8, 2026 05:08
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