Skip to content

feat(storagecontrol): add Rapid Cache samples - #14724

Merged
sahusneha2004 merged 5 commits into
mainfrom
storagecontrol-rapid-cache-samples-python
Nov 18, 2026
Merged

sahusneha2004 merged 5 commits into
mainfrom
storagecontrol-rapid-cache-samples-python

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds Python samples for the Storage Control API Rapid Cache operations:

Region tag File
storage_control_create_rapid_cache storagecontrol/create_rapid_cache.py
storage_control_get_rapid_cache storagecontrol/get_rapid_cache.py
storage_control_list_rapid_caches storagecontrol/list_rapid_caches.py
storage_control_update_rapid_cache storagecontrol/update_rapid_cache.py
storage_control_disable_rapid_cache storagecontrol/disable_rapid_cache.py

Also:

  • Bumps google-cloud-storage-control to 1.17.0, the first released version with the Rapid Cache RPCs.
  • Adds rapid_cache_test.py, a system test that runs create → get → list → update → disable.
  • Adds three fixtures to conftest.py:
    • rapid_cache_zone: defaults to us-central1-a, can be overridden with RAPID_CACHE_ZONE, and checks the zone format.
    • regional_hns_enabled_bucket
    • rapid_cache_id

Refs b/482946642

Sample behavior

  • create: sets only zone and cache_type="rapid-cache-ultra". It does not set name or ttl; the TTL uses the server default. Rapid Cache Ultra requires a regional bucket with hierarchical namespace enabled. The sample waits for the create operation and prints the name, state and cache type.
  • get: prints the name, zone, state, cache type and, when set, the TTL.
  • list: prints the name of each cache on the bucket.
  • update: sets ttl with update_mask=["ttl"] and prints the new TTL.
  • disable: starts the long-running operation without waiting and prints the cache path and operation name. The cache moves to disabled quickly. The operation only completes once the cache is fully removed, which can take more than an hour. Use get_rapid_cache to check the state.

Tests

  • Opt-in: rapid_cache_test.py is skipped unless RUN_RAPID_CACHE_TESTS=True, the same way zonal_snippets_test.py is gated. Rapid Cache Ultra needs an allowlisted project, and test buckets stay behind until the cache removal finishes.
  • After disable, the test checks the printed output. It then calls get and checks for State: disabled, and accepts NotFound in case removal already finished.
  • Teardown: disables any cache on the bucket that is not already disabled, without waiting. Then it tries to delete the bucket once. If that fails (for example 409 ... has Rapid Cache Ultra), it logs a warning and leaves the bucket. The test project needs periodic cleanup of leftover storagecontrol-samples-* buckets.

Checklist

  • Please merge this PR for me once it is approved
  • Tests pass: with RUN_RAPID_CACHE_TESTS=True, rapid_cache_test.py passed against an allowlisted project (storage-prober-prelaunch-acv2, us-central1-a) in about 17s. It is skipped when the variable is not set.
  • Lint passes: the changed files pass black and flake8 with the GitHub Actions Lint config (.github/scripts/noxfile-lint.py via lint-changed.sh). The older per-directory nox -s lint also reports existing I100/I201 errors in snippets_test.py and managed_folder_list_test.py, which this PR does not touch.
  • Region tags wrap only imports and sample logic
  • Type hints on all new functions (enforce_type_hints=True)

Generated with the storage-sample-architect workflow.

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]
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 2, 2026

@gemini-code-assist gemini-code-assist Bot 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.

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

snippet-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@sahusneha2004

Copy link
Copy Markdown
Contributor Author

CI triage: Kokoro failures are not caused by this PR

All eight failing Kokoro CI checks (Lint, Python 3.8 to 3.14) fail before any build step runs. They fail while Kokoro reads the job config:

UserException: ... ReadBuildConfig; no file found at path
'src/github/python-docs-samples/.kokoro/lint/presubmit' or with allowed extensions

(The Python 3.x jobs show the same error for .kokoro/python3.x/presubmit.)

No code changes are needed for these checks. A maintainer can merge once reviews are done, or retire the leftover Kokoro status contexts in the repo's required-checks settings.

[Generated-by: AI]

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

Thanks for adding the Rapid Cache samples. Overall structure and region tags look good.

I have a few comments below, mainly around:

  • Avoid blocking indefinitely in disable_rapid_cache.py.
  • Fix a 404 edge case and gate rapid_cache_test.py for non-allowlisted projects.
  • Clean up create_rapid_cache.py and test fixture teardown/waits in conftest.py.

Also, please update the PR description to reflect only the final code. Several notes currently contradict HEAD (such as ttl on create, fixture count, and lint behavior).

Comment thread storagecontrol/disable_rapid_cache.py Resolved
Comment thread storagecontrol/rapid_cache_test.py Resolved
Comment thread storagecontrol/rapid_cache_test.py Resolved
Comment thread storagecontrol/create_rapid_cache.py Resolved
Comment thread storagecontrol/get_rapid_cache.py Resolved
Comment thread storagecontrol/conftest.py Resolved
Comment thread storagecontrol/conftest.py Resolved
Comment thread storagecontrol/conftest.py Resolved
Comment thread storagecontrol/conftest.py Resolved
- disable_rapid_cache: start the LRO without waiting; print the cache path
  and operation name and point users to get_rapid_cache.
- create_rapid_cache: drop the unused RapidCache.name; note that Rapid
  Cache Ultra requires a regional HNS bucket.
- get_rapid_cache: print the TTL when set.
- Soften cache ID comments; the ID is not guaranteed to equal the zone.
- rapid_cache_test: opt-in via RUN_RAPID_CACHE_TESTS=True; assert the
  disable output and tolerate NotFound when checking the disabled state.
- conftest: validate RAPID_CACHE_ZONE, remove the 20s sleep, use a single
  best-effort bucket delete, and disable caches by name on teardown.

[Generated-by: AI]
@sahusneha2004
sahusneha2004 merged commit 5bdfda6 into main Nov 18, 2026
14 of 19 checks passed
@sahusneha2004
sahusneha2004 deleted the storagecontrol-rapid-cache-samples-python branch November 18, 2026 07:35
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants