Skip to content

samples(storage-control): add Rapid Cache samples - #36687

Draft
sahusneha2004 wants to merge 2 commits into
mainfrom
storage-control-rapid-cache-samples-ruby
Draft

sahusneha2004 wants to merge 2 commits into
mainfrom
storage-control-rapid-cache-samples-ruby

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown

Adds Storage Control samples for Rapid Cache: create, get, list, update, and disable.

Region tags:

  • 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

What each sample does:

  • Create makes a rapid-cache-ultra cache in a zone. It doesn't set a name; the server assigns the cache ID, and the sample prints the name it gets back.
  • Update sets the TTL to 172800s with update_mask: ["ttl"].
  • Disable starts the long-running operation, prints the operation name, and returns without waiting. The cache shows as disabled within seconds, but the operation only finishes once the cache is fully removed, which takes more than 30 minutes.
  • Create and update wait for their operations by polling operations_client.get_operation. Gapic::Operation#wait_until_done! fails against this API: reload! resends the original call's options, including its x-goog-request-params header, so the server returns INVALID_ARGUMENT: The x-goog-request-params must specify the same name as the resource in the request. Please don't switch these back to wait_until_done!.

Dependencies: bumps the samples Gemfile.lock to google-cloud-storage-control-v2 1.15.0, the first release with the Rapid Cache RPCs, and google-cloud-storage-control 1.4.2. gapic-common (1.6.1) and grpc (1.85.0) were bumped along with them.

Testing:

  • The acceptance test acceptance/storage_control_rapid_cache_test.rb runs the full flow on a regional HNS + UBLA bucket: create, get, list, update, disable, then check that the state becomes disabled.
  • It only runs when STORAGE_CONTROL_RUN_RAPID_CACHE_TESTS is set, so it's skipped in CI like the Anywhere Cache test. The zone defaults to us-east1-b; set STORAGE_CONTROL_RAPID_CACHE_ZONE to use another.
  • Cleaning up the bucket is best effort. Deleting it returns 409 The bucket you tried to delete has Rapid Cache Ultra for a long time after the cache is disabled, so the test retries for about 2 minutes, then leaves the bucket for the stale-bucket sweeper and logs its name.
  • I ran it live once against a test project: 1 run, 19 assertions, 0 failures. bundle exec rubocop reports no offenses.

b/482946642

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

The samples now follow the API usage in the reference integration test (ITRapidCacheTest.java). Where these points differ from the sections above, these points apply.

  • Create sets an explicit name, projects/_/buckets/{bucket}/rapidCaches/{zone}. The backend requires the cache ID to be the same as the zone. It also sets cache_type: "rapid-cache-ultra" and ttl: 86400s (24h), and prints the name, cache type and TTL.
  • Get also prints the cache type. The docs for cache_id in get, update and disable now say the ID is the same as the zone.
  • Disable now waits for the long-running operation by polling operations_client.get_operation, the same way create and update do. It takes an optional timeout: in seconds (default nil, which means wait until done) and prints the disabled cache. The old "does not wait" comment is removed.
  • Test:
    • Waits 20s after creating the bucket.
    • Uses cache_id = zone.
    • Checks the create output (name, rapid-cache-ultra, TTL 86400) and the get output (State: running and cache type).
    • Checks that the list output contains the cache name, and that the update sets the TTL to 172800.
    • Disable always runs in ensure with timeout: 600. If it times out, the test checks with get that the state is disabled instead of failing.
    • The now-unused rapid_cache_ids_helper was removed from helper.rb.
    • Zone default, CI gating and region tags are unchanged.
  • Testing: I ran the test live once against a test project: 1 run, 22 assertions, 0 failures, in about 13 minutes. The disable operation didn't finish within 600s, so the fallback check confirmed the disabled state. The bucket was left for the stale-bucket sweeper, as expected. bundle exec rubocop reports no offenses.

Adds create, get, list, update and disable Rapid Cache samples for Storage Control, with an acceptance test gated by STORAGE_CONTROL_RUN_RAPID_CACHE_TESTS. b/482946642

[Generated-by: AI]
@sahusneha2004 sahusneha2004 added ai-generated Generated by AI storage-sample-architect Generated by storage-sample-architect skill labels Nov 2, 2026
…ration test

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]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Generated by AI storage-sample-architect Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant