Skip to content

fix(storage): Handle redirect on takeover.#13354

Merged
tritone merged 1 commit intogoogleapis:mainfrom
cjc25:takeover-redirect
Nov 14, 2025
Merged

fix(storage): Handle redirect on takeover.#13354
tritone merged 1 commit intogoogleapis:mainfrom
cjc25:takeover-redirect

Conversation

@cjc25
Copy link
Copy Markdown
Contributor

@cjc25 cjc25 commented Nov 13, 2025

The initial takeover response wasn't being checked for a redirect.

PR #13239 addressed successful responses. This addresses error responses.

See #12785, b/459905219

The initial takeover response wasn't being checked for a redirect.

googleapis#13239 addressed successful responses. This addresses error responses.
@cjc25 cjc25 requested review from a team November 13, 2025 20:53
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Nov 13, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @cjc25, 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 addresses a critical oversight in the storage system's gRPC stream takeover process. It ensures that redirect responses are properly handled even when an error occurs during the initial stream reception. This enhancement improves the robustness and reliability of the system by preventing unhandled redirects in error scenarios, complementing previous work that focused on successful responses.

Highlights

  • Error Handling: Introduced a mechanism to check for and handle redirect responses when an error occurs during the initial takeover phase of a gRPC stream. Previously, only successful responses were checked for redirects.
  • Code Refinement: Modified the gRPCAppendTakeoverBidiWriteBufferSender.connect method to call s.maybeHandleRedirectionError(err) instead of directly assigning stream.Recv() errors, ensuring potential redirects are processed.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

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 correctly adds handling for redirection information in error responses during a takeover, which was a missing case. My review focuses on improving the consistency of the implementation with existing redirection handling logic in the success path, for better code maintainability.

if err != nil {
s.streamErr = err
// A Recv() error may be a redirect.
s.streamErr = s.maybeHandleRedirectionError(err)
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

For consistency with how redirects are handled in the success path, consider changing maybeHandleRedirectionError to return a boolean. This would make the control flow more explicit and align the patterns used for success and error cases.

The existing success path handling in maybeHandleRedirection returns a boolean:

if s.maybeHandleRedirection(resp) {
    s.streamErr = errRedirection
    // ...
}

Aligning this error path would look like this:

// A Recv() error may be a redirect.
if s.maybeHandleRedirectionError(err) { // This function would now return bool
    s.streamErr = errRedirection
} else {
    s.streamErr = err
}

This would involve changing maybeHandleRedirectionError to return true when a redirect is successfully handled, and false otherwise. This approach separates the detection/handling of the redirect from the decision of which error to propagate, improving clarity.

Copy link
Copy Markdown
Contributor

@tritone tritone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think this should go out in the patch release as well so that we get the append integration tests working correctly again.

@cjc25
Copy link
Copy Markdown
Contributor Author

cjc25 commented Nov 13, 2025

kokoro failure looks like a read codec flake

@cjc25 cjc25 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 13, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 13, 2025
@tritone tritone merged commit b0f1362 into googleapis:main Nov 14, 2025
9 checks passed
cpriti-os added a commit that referenced this pull request Nov 14, 2025
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: v0.6.0
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:718167d5c23ed389b41f617b3a00ac839bdd938a6bd2d48ae0c2f1fa51ab1c3d
<details><summary>storage: 1.57.2</summary>

##
[1.57.2](storage/v1.57.1...storage/v1.57.2)
(2025-11-14)

### Features

### Bug Fixes

* Handle redirect on takeover. (#13354)
([b0f1362](b0f13626))

* add env var to allow disabling bound token (#13236)
([cdaf6a6](cdaf6a6d))

### Documentation

* updates to docs and docs formatting (PiperOrigin-RevId: 828488192)
([93ca68d](93ca68d5))

</details>
@cjc25 cjc25 deleted the takeover-redirect branch November 18, 2025 16:19
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants