Skip to content

Use retry framework for DirectPath verification stat call#4667

Open
vadlakondaswetha wants to merge 1 commit intomasterfrom
add-retry-to-dp-stat-1834218318169272590
Open

Use retry framework for DirectPath verification stat call#4667
vadlakondaswetha wants to merge 1 commit intomasterfrom
add-retry-to-dp-stat-1834218318169272590

Conversation

@vadlakondaswetha
Copy link
Copy Markdown
Collaborator

Use storageutil.ExecuteWithRetryAtLogLevel to wrap the Stat call for DirectPath connectivity validation. This ensures connection stalls are correctly managed within the retry backoff loop, and fallback metrics are integrated correctly. Added an exported method for RetryConfig to override backoff limits.


PR created automatically by Jules for task 1834218318169272590 started by @vadlakondaswetha

…stat call

Co-authored-by: vadlakondaswetha <101323867+vadlakondaswetha@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vadlakondaswetha vadlakondaswetha requested a review from a team as a code owner May 5, 2026 02:19
@vadlakondaswetha vadlakondaswetha requested a review from charith87 May 5, 2026 02:19
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the DirectPath connectivity verification process to utilize the existing storage retry utility. By moving away from manual retry configuration management, the implementation ensures more consistent handling of connection stalls and better integration with fallback metrics. The changes also introduce necessary flexibility in the retry configuration to support specific backoff requirements for the detection phase.

Highlights

  • Retry Framework Integration: Replaced the manual retry configuration for DirectPath connectivity verification with the standardized storageutil.ExecuteWithRetryAtLogLevel framework.
  • Backoff Customization: Added an exported SetBackoffOverrides method to RetryConfig to allow fine-grained control over backoff multipliers and maximum durations.
  • Code Cleanup: Removed the deprecated setDPDetectionRetryConfig helper function as the logic is now handled by the unified retry utility.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Use retry framework for DirectPath verification stat call". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@github-actions github-actions Bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label May 5, 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 refactors DirectPath connectivity verification to use a localized retry loop and adds a SetBackoffOverrides method to the RetryConfig struct. Key feedback points out critical issues such as nested retries between the SDK and the new loop, a regression in metric collection, and improper gating of retry logic. Additionally, the reviewer recommended clarifying the request description and correcting misleading comments about the execution paths.

retryConfig := storageutil.NewRetryConfig(clientConfig, directPathDetectionTimeout, directPathDetectionMaxRetryDuration, storageutil.DefaultInitialBackoff)
retryConfig.SetBackoffOverrides(1.5, directPathDetectionMaxBackoff)
reqDescription := fmt.Sprintf("VerifyDirectPathConnectivity %q", testObject)
_, statErr = storageutil.ExecuteWithRetryAtLogLevel(ctx, retryConfig, "VerifyDirectPathConnectivity", reqDescription, apiCall, logger.LevelTrace)
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

This implementation introduces nested retries, which can lead to significantly longer wait times than intended.

  1. The sc client is already configured with production retry settings at line 204.
  2. ExecuteWithRetryAtLogLevel wraps the apiCall in a second retry loop using the detection configuration.

When a call fails, the Go Storage SDK will first perform its own retries (production config) inside the apiCall, and then ExecuteWithRetryAtLogLevel will retry that entire process again. To use the custom retry framework effectively, you should ensure the underlying SDK retries are disabled (e.g., by setting MaxAttempts to 1 on the client) for the duration of this check, similar to how the previous implementation swapped the configuration.

retryConfig := storageutil.NewRetryConfig(clientConfig, directPathDetectionTimeout, directPathDetectionMaxRetryDuration, storageutil.DefaultInitialBackoff)
retryConfig.SetBackoffOverrides(1.5, directPathDetectionMaxBackoff)
reqDescription := fmt.Sprintf("VerifyDirectPathConnectivity %q", testObject)
_, statErr = storageutil.ExecuteWithRetryAtLogLevel(ctx, retryConfig, "VerifyDirectPathConnectivity", reqDescription, apiCall, logger.LevelTrace)
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

There appears to be a regression in metric collection. The previous implementation used storageutil.ShouldRetryWithMonitoring, which explicitly recorded metrics for each retry attempt. The new implementation uses storageutil.ExecuteWithRetryAtLogLevel, which calls ShouldRetry(err) internally. Based on the provided code for ExecuteWithRetryAtLogLevel, it does not take a MetricHandle or perform any monitoring, which contradicts the PR description's claim that "fallback metrics are integrated correctly".

_, statErr := bucketHandle.Object(testObject).Attrs(verifyCtx)

var statErr error
if clientConfig != nil && clientConfig.MetricHandle != nil {
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 condition clientConfig.MetricHandle != nil incorrectly gates the use of the retry framework. If metrics are disabled in production, the DirectPath verification will skip the specialized retry logic and fall back to the else block. This reduces the robustness of the connectivity check. Following the repository's preference for using no-op implementations instead of nil for interface arguments, the retry framework should be used regardless of whether the metric handle is present.

References
  1. In tests, prefer using no-op implementations (e.g., tracing.NewNoopTracer(), metrics.NewNoopMetrics()) over nil for interface arguments to prevent potential nil pointer panics and improve consistency.

if clientConfig != nil && clientConfig.MetricHandle != nil {
retryConfig := storageutil.NewRetryConfig(clientConfig, directPathDetectionTimeout, directPathDetectionMaxRetryDuration, storageutil.DefaultInitialBackoff)
retryConfig.SetBackoffOverrides(1.5, directPathDetectionMaxBackoff)
reqDescription := fmt.Sprintf("VerifyDirectPathConnectivity %q", testObject)
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 reqDescription is redundant as it repeats the operation name. It would be cleaner to provide a description that identifies the resource being checked.

Suggested change
reqDescription := fmt.Sprintf("VerifyDirectPathConnectivity %q", testObject)
reqDescription := fmt.Sprintf("bucket %q object %q", bucketName, testObject)

reqDescription := fmt.Sprintf("VerifyDirectPathConnectivity %q", testObject)
_, statErr = storageutil.ExecuteWithRetryAtLogLevel(ctx, retryConfig, "VerifyDirectPathConnectivity", reqDescription, apiCall, logger.LevelTrace)
} else {
// When tests run without Viper config, execute without retry loop
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 comment here is misleading. This block is executed whenever MetricHandle is nil, which is not exclusive to tests (it happens if metrics are disabled in config). Additionally, because sc is configured with production retries at line 204, the apiCall will still perform retries via the SDK, so it is not truly executing "without retry loop". Consistent with the repository's preference for using no-op implementations instead of nil for interface arguments, the logic should ideally not be gated by a nil check.

References
  1. In tests, prefer using no-op implementations (e.g., tracing.NewNoopTracer(), metrics.NewNoopMetrics()) over nil for interface arguments to prevent potential nil pointer panics and improve consistency.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 70.58824% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.70%. Comparing base (5dd21b6) to head (3bfe1ba).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
internal/storage/storage_handle.go 64.28% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4667       +/-   ##
===========================================
+ Coverage        0   83.70%   +83.70%     
===========================================
  Files           0      165      +165     
  Lines           0    20485    +20485     
===========================================
+ Hits            0    17147    +17147     
- Misses          0     2698     +2698     
- Partials        0      640      +640     
Flag Coverage Δ
unittests 83.70% <70.58%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Hi @charith87, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

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

Labels

remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant