Skip to content

fix(storage): limit retries in InsertObjectWithBadChecksum sample - #16322

Merged
v-pratap merged 2 commits into
googleapis:mainfrom
v-pratap:fix-bad-checksum-sample-timeout
Aug 5, 2026
Merged

fix(storage): limit retries in InsertObjectWithBadChecksum sample#16322
v-pratap merged 2 commits into
googleapis:mainfrom
v-pratap:fix-bad-checksum-sample-timeout

Conversation

@v-pratap

@v-pratap v-pratap commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

In InsertObjectWithBadChecksum, client.InsertObject was called without limiting retries. When executed in CI against the gRPC emulator, checksum errors over gRPC return retryable error statuses, causing the operation to retry until the default 15-minute LimitedTimeRetryPolicy expires and timing out the test target (//google/cloud/storage/examples:storage_object_samples).

This PR adds .set<gcs::RetryPolicyOption>(gcs::LimitedErrorCountRetryPolicy(2).clone()) to the per-call options in InsertObjectWithBadChecksum. This ensures the operation fails after 2 retries and returns immediately.

@v-pratap
v-pratap requested review from a team as code owners August 5, 2026 07:29
@product-auto-label product-auto-label Bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Aug 5, 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 updates the InsertObjectWithBadChecksum example to set a custom retry policy with a limited error count. The feedback suggests using std::make_shared directly to instantiate the retry policy instead of creating a temporary object and calling .clone(), which avoids unnecessary heap allocation and copying.

Comment thread google/cloud/storage/examples/storage_object_samples.cc Outdated
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (e41509e) to head (726b240).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16322      +/-   ##
==========================================
- Coverage   92.25%   92.24%   -0.02%     
==========================================
  Files        2227     2227              
  Lines      209234   209234              
==========================================
- Hits       193024   193001      -23     
- Misses      16210    16233      +23     

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

@v-pratap
v-pratap merged commit 849ed7b into googleapis:main Aug 5, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants