Skip to content

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

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

sahusneha2004 wants to merge 2 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 (CreateRapidCache, cache_type = "rapid-cache-ultra"; waits for the LRO)
  • storage_control_get_rapid_cache
  • storage_control_list_rapid_caches
  • storage_control_update_rapid_cache (updates ttl via a FieldMask; waits for the LRO)
  • storage_control_disable_rapid_cache (starts the LRO with NoAwaitTag and does not wait: the cache is disabled within seconds, but the operation only completes once the cache is fully removed, which can take 30+ minutes)

Refs b/482946642

Testing / CI notes (please review)

  • New env var GOOGLE_CLOUD_CPP_STORAGE_TEST_RAPID_CACHE_BUCKET_NAME. Rapid Cache Ultra needs a regional bucket with hierarchical namespace + UBLA in the same region as the cache zone. The shared test buckets don't qualify, and the generated cc_test for samples only links //:storagecontrol, so AutoRun cannot create a bucket itself. Following the folder-samples precedent (GOOGLE_CLOUD_CPP_STORAGE_TEST_FOLDER_BUCKET_NAME), AutoRun uses a pre-provisioned bucket and skips gracefully if the variable is unset. Zone: GOOGLE_CLOUD_CPP_STORAGE_TEST_RAPID_CACHE_ZONE, falling back to GOOGLE_CLOUD_CPP_TEST_ZONE, then us-central1-a.
  • Excluded from integration-production.sh, like the Anywhere Cache samples: a disabled Rapid Cache takes 30+ minutes to be removed, which blocks back-to-back runs in the same zone and blocks bucket deletion (HTTP 409 "has Rapid Cache Ultra").
  • The cache ID is server-assigned; AutoRun discovers it via ListRapidCaches (by zone, ignoring disabled caches) instead of assuming it.

Validation

  • clang-format applied; bazel build OK.
  • Live run once against storage-prober-prelaunch-acv2 with a regional HNS+UBLA bucket in us-central1 (zone us-central1-a): create → get → list → update (TTL 172800s) → disable → state disabled — PASSED.
  • Local fast checkers could not run (missing typos tool); relying on CI checkers.

Alignment with googleapis/google-cloud-java#14529

The samples now follow the API usage in the Java Rapid Cache integration test (ITRapidCacheTest.java). Where this section conflicts with the notes above, this section wins.

  • Create: sets the cache name explicitly to projects/_/buckets/{bucket}/rapidCaches/{zone}, because the backend requires the cache ID to equal the zone (CreateRapidCacheRequest has no ID field). Also sets cache_type = "rapid-cache-ultra" and ttl = 86400s (24h). Prints the name and state.

  • Get: also prints cache_type.

  • Disable: now waits for the LRO (DisableRapidCache(name).get()) instead of using NoAwaitTag.

  • AutoRun: uses cache_id = zone, so the ListRapidCaches lookup is gone. It checks:

    • state == "running" and cache_type after create
    • the cache is in ListRapidCaches
    • ttl == 172800s after update

    The disable wait is capped by a 10-minute polling policy. On timeout, AutoRun checks that GetRapidCache reports disabled and does not fail. If an earlier step fails, cleanup sends a NoAwaitTag disable.

  • Region tags, env-var gating, and the integration-production.sh exclusion are unchanged.

Validation (alignment commit): clang-format applied; bazel build OK. AutoRun ran live once against storage-prober-prelaunch-acv2 with a new regional HNS+UBLA bucket in us-central1 (zone us-central1-a). Create, get, list and update (TTL 172800s) passed. The disable LRO did not finish within 10 minutes (the polling policy returned DEADLINE_EXCEEDED), but the cache state was disabled. Result: PASSED.

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.

// Creating a Rapid Cache is a long-running operation. This example blocks
// until it completes. Real applications may want to set up a callback, wait
// on a coroutine, or poll until it completes.
auto rapid_cache = client.CreateRapidCache(parent, cache).get();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, using auto is disallowed when it hides StatusOr<T>, domain objects, or protobuf messages. Please explicitly specify the type google::cloud::StatusOr<google::storage::control::v2::RapidCache>.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache>
        rapid_cache = client.CreateRapidCache(parent, cache).get();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

std::string const& bucket_name, std::string const& cache_id) {
auto const name = std::string{"projects/_/buckets/"} + bucket_name +
"/rapidCaches/" + cache_id;
auto rapid_cache = client.GetRapidCache(name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, using auto is disallowed when it hides StatusOr<T>, domain objects, or protobuf messages. Please explicitly specify the type google::cloud::StatusOr<google::storage::control::v2::RapidCache>.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache>
        rapid_cache = client.GetRapidCache(name);
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

std::string const& bucket_name) {
auto const parent = std::string{"projects/_/buckets/"} + bucket_name;
// The returned range fetches additional pages as needed.
for (auto rapid_cache : client.ListRapidCaches(parent)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, using auto is disallowed when it hides StatusOr<T>, domain objects, or protobuf messages. Please explicitly specify the type google::cloud::StatusOr<google::storage::control::v2::RapidCache>.

    for (google::cloud::StatusOr<google::storage::control::v2::RapidCache>
             rapid_cache : client.ListRapidCaches(parent)) {
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

// Updating a Rapid Cache is a long-running operation. This example blocks
// until it completes. Real applications may want to set up a callback, wait
// on a coroutine, or poll until it completes.
auto rapid_cache = client.UpdateRapidCache(cache, field_mask).get();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, using auto is disallowed when it hides StatusOr<T>, domain objects, or protobuf messages. Please explicitly specify the type google::cloud::StatusOr<google::storage::control::v2::RapidCache>.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache>
        rapid_cache = client.UpdateRapidCache(cache, field_mask).get();
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

Comment on lines +134 to +135
auto operation =
client.DisableRapidCache(google::cloud::NoAwaitTag{}, name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, using auto is disallowed when it hides StatusOr<T>, domain objects, or protobuf messages. Please explicitly specify the type google::cloud::StatusOr<google::longrunning::Operation>.

    google::cloud::StatusOr<google::longrunning::Operation> operation =
        client.DisableRapidCache(google::cloud::NoAwaitTag{}, name);
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

// cannot be disabled here, and must be disabled manually.
auto const parent = std::string{"projects/_/buckets/"} + *bucket_name;
std::string cache_id;
for (auto cache : client.ListRapidCaches(parent)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, using auto is disallowed when it hides StatusOr<T>, domain objects, or protobuf messages. Please explicitly specify the type google::cloud::StatusOr<google::storage::control::v2::RapidCache>.

  for (google::cloud::StatusOr<google::storage::control::v2::RapidCache> cache :
       client.ListRapidCaches(parent)) {
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

// The cache moves to the "disabled" state shortly after the request.
auto const name = parent + "/rapidCaches/" + cache_id;
for (int i = 0; i != 12; ++i) {
auto cache = client.GetRapidCache(name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

According to the repository style guide, using auto is disallowed when it hides StatusOr<T>, domain objects, or protobuf messages. Please explicitly specify the type google::cloud::StatusOr<google::storage::control::v2::RapidCache>.

    google::cloud::StatusOr<google::storage::control::v2::RapidCache> cache =
        client.GetRapidCache(name);
References
  1. Reject Obscured Domain & Return Types: Flag and reject auto when it hides StatusOr, domain objects, protobuf messages/fields, or function return types. (link)

@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.46%. Comparing base (eaa2592) to head (0322f2a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16611      +/-   ##
==========================================
+ Coverage   92.42%   92.46%   +0.04%     
==========================================
  Files        2266     2266              
  Lines      221667   221667              
==========================================
+ Hits       204872   204969      +97     
+ Misses      16795    16698      -97     

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

This branch was successfully deployed

1 active 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.

1 participant