Skip to content

docs(storagecontrol): add Rapid Cache samples - #16611

Open
sahusneha2004 wants to merge 8 commits into
mainfrom
storagecontrol-rapid-cache-samples-cpp
Open

sahusneha2004 wants to merge 8 commits into
mainfrom
storagecontrol-rapid-cache-samples-cpp

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown

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: calls CreateRapidCache and waits for the LRO. It sets the cache name to projects/_/buckets/{bucket}/rapidCaches/{zone}, plus zone and cache_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_caches
  • storage_control_update_rapid_cache: updates ttl to 172800s with a FieldMask and waits for the LRO.
  • storage_control_disable_rapid_cache: starts the LRO with NoAwaitTag and prints the operation name. It does not wait. The cache moves to the disabled state 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: CreateRapidCacheRequest has 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. AutoRun checks for the variable with examples::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, then GOOGLE_CLOUD_CPP_TEST_ZONE, then us-central1-a.

  • AutoRun checks:

    • after create: state == "running" and cache_type
    • the cache appears in ListRapidCaches
    • after update: ttl == 172800s
    • after disable: polls GetRapidCache for about 2 minutes until state == "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-format applied; bazel build OK. The local fast checkers can't run here because the typos tool is missing, so this relies on the CI checkers.
  • Ran AutoRun once against storage-prober-prelaunch-acv2, with a new regional HNS+UBLA bucket in us-central1 (zone us-central1-a). Create → get → list → update (TTL 172800s) → disable (NoAwaitTag) → state disabled: PASSED.
  • Without the bucket env var, AutoRun fails with "The GOOGLE_CLOUD_CPP_STORAGE_TEST_RAPID_CACHE_BUCKET_NAME environment variable is not set".

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]
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 2, 2026
@sahusneha2004 sahusneha2004 added ai-generated storage-sample-architect Generated by storage-sample-architect skill labels Nov 2, 2026

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

Copy link
Copy Markdown

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 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

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.52%. Comparing base (5dcdef5) to head (9a95516).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…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]
@sahusneha2004
sahusneha2004 marked this pull request as ready for review November 6, 2026 11:19
@sahusneha2004
sahusneha2004 requested review from a team as code owners November 6, 2026 11:19

@kalragauri kalragauri 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.

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?

sahusneha2004 and others added 2 commits November 10, 2026 13:39
…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]

This branch was previously deployed

1 inactive (outdated) deployment
internal — 0322f2a3 Deployed Nov 2, 2026 by sahusneha2004 via Save PR ref #12772
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 Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants