Skip to content

feat(storagecontrol): Added samples for Anywhere Cache.#14020

Closed
nidhiii-27 wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
nidhiii-27:add-anywhere-cache-samples-storagecontrol-16032530739510550879-5165499522432895204
Closed

feat(storagecontrol): Added samples for Anywhere Cache.#14020
nidhiii-27 wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
nidhiii-27:add-anywhere-cache-samples-storagecontrol-16032530739510550879-5165499522432895204

Conversation

@nidhiii-27
Copy link
Copy Markdown
Contributor

Implemented create, get, list, update, pause, resume, and disable anywhere cache snippets. Added integration tests.

Implemented create, get, list, update, pause, resume, and disable
anywhere cache snippets. Added integration tests.

API Reference: https://github.com/googleapis/google-cloud-cpp/pull/15134/changes

Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Apr 9, 2026
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 a comprehensive set of Python code samples for managing Google Cloud Storage Control Anywhere Caches, including operations for creation, retrieval, listing, updating, pausing, resuming, and disabling. It also includes an integration test suite. Review feedback highlights a potential issue with the test's retry mechanism, where a non-idempotent test function decorated with a backoff could fail upon retry due to resource conflicts. There is also a suggestion to improve test assertions to verify all output fields from the retrieval sample.

Comment on lines +32 to +34
@backoff.on_exception(
backoff.expo, exceptions.InternalServerError, max_tries=3
)
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

Applying @backoff to the entire test function is problematic because the test is not idempotent. If the create_anywhere_cache operation succeeds but a subsequent step (like get or update) fails with an InternalServerError, the retry will attempt to call create_anywhere_cache again with the same bucket and zone. This will result in a 409 AlreadyExists error, causing the test to fail on the retry attempt rather than successfully retrying the failed step.

Consider applying the backoff to individual operations or ensuring the test can handle existing resources. Additionally, it is recommended to include exceptions.ServiceUnavailable (503) in the list of retryable exceptions.

Comment on lines +48 to +54
get_anywhere_cache.get_anywhere_cache(bucket_name, ZONE)
out, _ = capsys.readouterr()
expected = (
f"Anywhere Cache: "
f"projects/_/buckets/{bucket_name}/anywhereCaches/{ZONE}"
)
assert expected in out
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.

medium

The test for get_anywhere_cache only verifies that the resource name is printed. However, the get_anywhere_cache.py sample also prints the Admission Policy and State. To ensure the sample is fully functional and the output is as expected, consider adding assertions for these additional printed lines.

@nidhiii-27 nidhiii-27 closed this Apr 9, 2026
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