Skip to content

feat(storagecontrol): add Rapid Cache samples - #14724

Draft
sahusneha2004 wants to merge 3 commits into
mainfrom
storagecontrol-rapid-cache-samples-python
Draft

sahusneha2004 wants to merge 3 commits into
mainfrom
storagecontrol-rapid-cache-samples-python

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown

Description

Adds Python samples for the Storage Control API Rapid Cache CRUD operations:

Region tag File
storage_control_create_rapid_cache storagecontrol/create_rapid_cache.py
storage_control_get_rapid_cache storagecontrol/get_rapid_cache.py
storage_control_list_rapid_caches storagecontrol/list_rapid_caches.py
storage_control_update_rapid_cache storagecontrol/update_rapid_cache.py
storage_control_disable_rapid_cache storagecontrol/disable_rapid_cache.py

Also:

  • Bumps google-cloud-storage-control to 1.17.0, the released version that includes the Rapid Cache RPCs.
  • Adds rapid_cache_test.py, a system test covering create → get → list → update → disable, plus two new fixtures in conftest.py: rapid_cache_zone (default us-central1-a, overridable via the RAPID_CACHE_ZONE env var) and regional_hns_enabled_bucket.

Refs b/482946642

Behavior notes (observed against the live API)

  • Cache type: samples create a rapid-cache-ultra cache. Creating rapid-cache currently returns 400 Rapid Cache management operations are not supported at this time. Rapid Cache Ultra requires a bucket with hierarchical namespace enabled in a single region; a multi-region bucket returns Rapid Cache feature is disabled.
  • Cache ID: the create request does not set a name. The server returns projects/_/buckets/<bucket>/rapidCaches/<id>, where <id> is currently the zone. Get, update and disable take (bucket_name, cache_id). The test parses the ID from the returned name and does not assume it equals the zone.
  • Update: changes ttl to 2 days with update_mask=["ttl"]. admit-on-second-miss is rejected for Rapid Cache Ultra.
  • Disable does not wait for the long-running operation. The cache reaches the disabled state within seconds, but the disable LRO only completes once the cache is fully removed. That did not happen within 30 minutes in testing. The sample prints the cache and operation names and points to get_rapid_cache for checking state. The test polls get (up to 2 minutes) until it sees State: disabled.
  • Test bucket cleanup is best-effort. A bucket can't be deleted until its disabled cache is fully removed (409 The bucket you tried to delete has Rapid Cache Ultra). The fixture retries deletion on 409 for 2 minutes, then logs a warning and leaves the bucket behind. The repo has no stale-bucket sweeper, so leftover storagecontrol-samples-* buckets in the test project need periodic cleanup.
  • CI: the test is not skipped. The CI project (BUILD_SPECIFIC_GCLOUD_PROJECT) must be allowlisted for Rapid Cache Ultra in the test zone; otherwise create will fail. I found no existing Anywhere Cache or long-LRO skip precedent in this repo.

Checklist

  • Please merge this PR for me once it is approved
  • Tests pass: rapid_cache_test.py passed against a live allowlisted project (storage-prober-prelaunch-acv2)
  • Lint pass: all new and changed files pass nox -s lint. snippets_test.py and managed_folder_list_test.py, which this PR does not touch, have existing flake8 import-order errors (I100/I201) that make nox -s lint fail for the storagecontrol/ directory. I left them out of scope.
  • Region tags wrap only imports and sample logic
  • Type hints on all new functions (enforce_type_hints=True)

Generated with the storage-sample-architect workflow. This Python implementation is the golden reference for the other languages.

Update: aligned with googleapis/google-cloud-java#14529

The samples now follow the API usage in the reference integration test (ITRapidCacheTest.java). Where this conflicts with the Cache ID and Disable behavior notes above, this section takes precedence.

  • create: sets the cache name explicitly to projects/_/buckets/{bucket}/rapidCaches/{zone} (the backend requires the cache ID to equal the zone), plus cache_type="rapid-cache-ultra" and ttl=86400s (24h). Prints the name, state and cache type.
  • get: also prints the cache type. Docs now say the cache ID is the zone (same for update and disable).
  • disable: now waits for the long-running operation, like the reference. Adds an optional timeout param (default None waits until it finishes) and prints the returned cache and its state.
  • Test: cache_id is the zone. After create and after get, it checks for state running and cache type rapid-cache-ultra. It also checks the cache is listed and that ttl is 172800s after update. The disable wait is capped at 600s. On timeout, the test calls get and checks for state disabled instead of failing. If the test fails before the disable step, teardown starts a disable and ignores errors.
  • Fixture: waits 20s after creating the HNS bucket so its metadata can propagate. Bucket deletion is still best-effort.
  • Live run (storage-prober-prelaunch-acv2, us-central1-a): passed in 12m09s. The disable operation didn't finish within 600s, so the test fell back to the state check, which showed disabled. Deleting the bucket returned 409 (has Rapid Cache Ultra), so the bucket was left in place as expected.

Adds samples for the Storage Control Rapid Cache CRUD APIs: storage_control_create_rapid_cache, storage_control_get_rapid_cache, storage_control_list_rapid_caches, storage_control_update_rapid_cache, storage_control_disable_rapid_cache. Bumps google-cloud-storage-control to 1.17.0. Refs b/482946642

[Generated-by: AI]
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for managing Rapid Caches in Google Cloud Storage Control. It adds scripts to create, disable, get, list, and update Rapid Caches, along with corresponding integration tests and test fixtures in conftest.py. Additionally, the google-cloud-storage-control dependency in requirements.txt is updated to version 1.17.0. There are no review comments to address, and I have no further feedback to provide.

Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642

[Generated-by: AI]
Reorder imports in storagecontrol/conftest.py and storagecontrol/rapid_cache_test.py to match the repository-root flake8-import-order configuration used by the GitHub Actions Lint workflow.

[Generated-by: AI]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated samples Issues that are directly related to samples. storage-sample-architect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant