Repository navigation
docs(storagecontrol): add Rapid Cache samples - #16611
sahusneha2004 wants to merge 8 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. Refs b/482946642 [Generated-by: AI]
There was a problem hiding this comment.
Code Review
This pull request introduces code samples for managing Rapid Cache resources in the Google Cloud Storage Control service, including creation, retrieval, listing, updating, and disabling of caches. It also excludes these samples from the integration tests against production due to the long duration required to disable a Rapid Cache. The code review feedback requests replacing several instances of auto type deduction with explicit StatusOr types to comply with the repository's style guide regarding obscured domain and return types.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16611 +/- ##
==========================================
- Coverage 92.53% 92.52% -0.01%
==========================================
Files 2269 2269
Lines 222896 222896
==========================================
- Hits 206250 206239 -11
- Misses 16646 16657 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ation test Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; the auto-run asserts running state, cache type, list membership and the updated ttl, and bounds the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642 [Generated-by: AI]
Replace auto with explicit StatusOr<RapidCache>, std::optional, bool and std::string types, as required by the repository style guide. [Generated-by: AI]
The create sample now only sets the name, zone and cache type, like the Anywhere Cache create sample. The TTL is set by the update sample. The create sample names the ID cache_id, like get and update. The auto-run always disables the cache it created (linear flow, no nested try/catch), bounds the disable wait with the native polling policy instead of a sleep loop, and only accepts a DEADLINE_EXCEEDED timeout. The disable sample comment explains that the operation completes only once the cache is removed. b/482946642 [Generated-by: AI]
Bind cache_id by const reference to zone_name in CreateRapidCache() to satisfy clang-tidy performance-unnecessary-copy-initialization. [Generated-by: AI]
kalragauri
left a comment
There was a problem hiding this comment.
The PR description has drifted from the code: the teardown polling policy is 2 minutes (not 10), there is no NoAwaitTag cleanup path anymore, and the create sample no longer sets ttl = 86400s. Could you rewrite the description to describe only the final state?
…sample Start DisableRapidCache with NoAwaitTag and print the operation name. The cache moves to the disabled state in seconds, but the operation only completes once the cache is fully removed, which can take over an hour. AutoRun now polls GetRapidCache for the disabled state instead. Require GOOGLE_CLOUD_CPP_STORAGE_TEST_RAPID_CACHE_BUCKET_NAME via CheckEnvironmentVariablesAreSet() instead of silently skipping, and soften the wording about the cache ID matching the zone. [Generated-by: AI]
Adds C++ samples for the Storage Control Rapid Cache CRUD APIs in
google/cloud/storagecontrol/v2/samples/storage_control_rapid_cache_samples.cc:storage_control_create_rapid_cache: callsCreateRapidCacheand waits for the LRO. It sets the cachenametoprojects/_/buckets/{bucket}/rapidCaches/{zone}, pluszoneandcache_type = "rapid-cache-ultra". It does not set a TTL, so the service default applies. It prints the name and state.storage_control_get_rapid_cache: prints the name, zone,cache_type, and state.storage_control_list_rapid_cachesstorage_control_update_rapid_cache: updatesttlto 172800s with aFieldMaskand waits for the LRO.storage_control_disable_rapid_cache: starts the LRO withNoAwaitTagand prints the operation name. It does not wait. The cache moves to thedisabledstate within seconds, but the operation only completes once the cache is fully removed, which can take over an hour.Refs b/482946642
Notes
Cache ID:
CreateRapidCacheRequesthas no ID field. In current testing, the service uses the zone name as the cache ID, so the sample sets the name that way. This matches the Java integration test (test(storage): Add integration tests for Storage Control RapidCache CRUD APIs google-cloud-java#14529). The proto does not document it as a contract.Required env var
GOOGLE_CLOUD_CPP_STORAGE_TEST_RAPID_CACHE_BUCKET_NAME: Rapid Cache Ultra needs a regional bucket with hierarchical namespace and UBLA, in the same region as the cache zone. The shared test buckets don't qualify.AutoRunchecks for the variable withexamples::CheckEnvironmentVariablesAreSet()and fails if it is missing, the same as the folder and Anywhere Cache samples. Zone:GOOGLE_CLOUD_CPP_STORAGE_TEST_RAPID_CACHE_ZONE, thenGOOGLE_CLOUD_CPP_TEST_ZONE, thenus-central1-a.AutoRun checks:
state == "running"andcache_typeListRapidCachesttl == 172800sGetRapidCachefor about 2 minutes untilstate == "disabled"If an earlier step fails, AutoRun still runs the disable step and then rethrows the first error.
Excluded from
integration-production.sh, like the Anywhere Cache samples. A disabled Rapid Cache can take over an hour to be fully removed. That blocks back-to-back runs in the same zone and blocks deleting the bucket (HTTP 409 "has Rapid Cache Ultra").Validation
clang-formatapplied;bazel buildOK. The local fast checkers can't run here because thetypostool is missing, so this relies on the CI checkers.storage-prober-prelaunch-acv2, with a new regional HNS+UBLA bucket inus-central1(zoneus-central1-a). Create → get → list → update (TTL 172800s) → disable (NoAwaitTag) → statedisabled: PASSED.