Skip to content

feat(storagecontrol): add anywhere cache samples#14265

Open
nidhiii-27 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
nidhiii-27:feat-storage-control-anywhere-cache-python
Open

feat(storagecontrol): add anywhere cache samples#14265
nidhiii-27 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
nidhiii-27:feat-storage-control-anywhere-cache-python

Conversation

@nidhiii-27
Copy link
Copy Markdown
Contributor

Implement Anywhere Cache (Rapid Cache) lifecycle operations (create, get, list, update, pause, resume, disable) in GCS Python samples.

@nidhiii-27 nidhiii-27 requested review from a team as code owners June 3, 2026 18:34
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jun 3, 2026
@snippet-bot
Copy link
Copy Markdown

snippet-bot Bot commented Jun 3, 2026

Here is the summary of changes.

You are about to add 7 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

Copy link
Copy Markdown
Contributor

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

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 new Python snippets for managing Google Cloud Storage Control Anywhere Caches, including operations to create, disable, get, list, pause, resume, and update caches, along with a comprehensive integration test verifying their lifecycle. The review feedback points out a critical issue in anywhere_cache_disable.py where the long-running operation is not awaited. This causes incorrect console output and can lead to flaky tests during cleanup, as the cache may not be fully disabled before bucket deletion. A code suggestion was provided to wait for the operation to complete.

Comment on lines +38 to +40
response = storage_control_client.disable_anywhere_cache(request=request)

print(f"Disabled anywhere cache: {response.name}")
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.

high

The disable_anywhere_cache method returns a Long-Running Operation (google.longrunning.Operation) rather than the AnywhereCache resource directly.

Currently, the code does not wait for this operation to complete. This has two major issues:

  1. Incorrect Output: response.name will print the operation's resource path (e.g., .../anywhereCaches/{zone}/operations/{operation_id}) instead of the disabled cache's resource path. (Note: The test assertion assert f"Disabled anywhere cache: {cache_name}" in out accidentally passes because the operation path contains the cache path as a prefix).
  2. Flaky/Failing Tests: Because the operation is asynchronous and not awaited, the cache is not fully disabled when the function returns. When the test teardown runs immediately after, the bucket deletion will fail because the cache is still in the process of being disabled.

Please update the code to wait for the operation to complete using operation.result() before printing the result.

Suggested change
response = storage_control_client.disable_anywhere_cache(request=request)
print(f"Disabled anywhere cache: {response.name}")
operation = storage_control_client.disable_anywhere_cache(request=request)
print("Waiting for operation to complete...")
response = operation.result()
print(f"Disabled anywhere cache: {response.name}")

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

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant