Repository navigation
feat(storagecontrol): add Rapid Cache samples - #14724
sahusneha2004 wants to merge 4 commits into
Conversation
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]
There was a problem hiding this comment.
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]
- create_rapid_cache: set only the required fields (name, zone, cache_type) and leave TTL to the update sample; use a cache_id variable consistent with get/update. - tests: move cleanup into a rapid_cache_id fixture that disables the cache on teardown if it is still active, so cleanup runs even when assertions fail; keep the test flow linear without nested try/except/finally; bound the disable wait with the native operation timeout. - disable_rapid_cache: document that the operation completes only after the cache is fully removed. [Generated-by: AI]
|
Here is the summary of changes. You are about to add 5 region tags.
This comment is generated by snippet-bot.
|
Description
Adds Python samples for the Storage Control API Rapid Cache CRUD operations:
storage_control_create_rapid_cachestoragecontrol/create_rapid_cache.pystorage_control_get_rapid_cachestoragecontrol/get_rapid_cache.pystorage_control_list_rapid_cachesstoragecontrol/list_rapid_caches.pystorage_control_update_rapid_cachestoragecontrol/update_rapid_cache.pystorage_control_disable_rapid_cachestoragecontrol/disable_rapid_cache.pyAlso:
google-cloud-storage-controlto1.17.0, the released version that includes the Rapid Cache RPCs.rapid_cache_test.py, a system test covering create → get → list → update → disable, plus two new fixtures inconftest.py:rapid_cache_zone(defaultus-central1-a, overridable via theRAPID_CACHE_ZONEenv var) andregional_hns_enabled_bucket.Refs b/482946642
Behavior notes (observed against the live API)
rapid-cache-ultracache. Creatingrapid-cachecurrently returns400 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 returnsRapid Cache feature is disabled.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.ttlto 2 days withupdate_mask=["ttl"].admit-on-second-missis rejected for Rapid Cache Ultra.disabledstate 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 toget_rapid_cachefor checking state. The test polls get (up to 2 minutes) until it seesState: disabled.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 leftoverstoragecontrol-samples-*buckets in the test project need periodic cleanup.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
rapid_cache_test.pypassed against a live allowlisted project (storage-prober-prelaunch-acv2)nox -s lint.snippets_test.pyandmanaged_folder_list_test.py, which this PR does not touch, have existing flake8 import-order errors (I100/I201) that makenox -s lintfail for thestoragecontrol/directory. I left them out of scope.enforce_type_hints=True)Generated with the
storage-sample-architectworkflow. 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.projects/_/buckets/{bucket}/rapidCaches/{zone}(the backend requires the cache ID to equal the zone), pluscache_type="rapid-cache-ultra"andttl=86400s(24h). Prints the name, state and cache type.timeoutparam (defaultNonewaits until it finishes) and prints the returned cache and its state.cache_idis the zone. After create and after get, it checks for staterunningand cache typerapid-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 statedisabledinstead of failing. If the test fails before the disable step, teardown starts a disable and ignores errors.disabled. Deleting the bucket returned 409 (has Rapid Cache Ultra), so the bucket was left in place as expected.