Skip to content

[bucket] Fix s3manager endpoint mismatch with COSI credentials#2211

Merged
kvaps merged 1 commit intomainfrom
fix/bucket-s3manager-endpoint
Mar 13, 2026
Merged

[bucket] Fix s3manager endpoint mismatch with COSI credentials#2211
kvaps merged 1 commit intomainfrom
fix/bucket-s3manager-endpoint

Conversation

@IvanHunters
Copy link
Collaborator

@IvanHunters IvanHunters commented Mar 12, 2026

What this PR does

Fixes s3manager UI deployment to use the actual S3 endpoint from BucketInfo (COSI) instead of constructing it from the tenant namespace host.

The deployment was using s3.<tenant>.<cluster-domain> while credentials issued by COSI point to the root-level S3 endpoint. This mismatch caused "invalid credentials" errors on login even with correct credentials from the bucket secret.

Falls back to the constructed namespace host on first deploy before BucketAccess secrets exist.

Release note

[bucket] Fix s3manager endpoint mismatch causing "invalid credentials" errors in login mode

Summary by CodeRabbit

  • Refactor
    • Deployment configuration now supports per-user endpoint customization. Endpoints are dynamically retrieved from account-specific settings, enabling flexible configurations while maintaining backward compatibility for standard deployments without custom settings.

…Info

The deployment template was constructing the S3 endpoint from the tenant's
namespace host (e.g. s3.freedom.infra.example.com), while COSI credentials
are issued for the actual SeaweedFS endpoint (e.g. s3.infra.example.com).
This mismatch caused 'invalid credentials' errors when users tried to log
in with valid credentials from the bucket secret.

Now the endpoint is resolved from BucketInfo (same source as credentials),
with a fallback to the constructed namespace host for first-time deploys
before BucketAccess secrets are created.

Signed-off-by: IvanHunters <[email protected]>
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 12, 2026
@gemini-code-assist
Copy link
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 resolves a critical issue where the s3manager UI deployment failed to authenticate due to a mismatch between its assumed S3 endpoint and the actual endpoint provided by COSI credentials. By dynamically extracting the correct S3 endpoint from the BucketInfo within the BucketAccess secret, the s3manager now connects to the appropriate S3 service, eliminating "invalid credentials" errors and ensuring reliable operation. A fallback mechanism is also included for initial deployments.

Highlights

  • Endpoint Resolution: The s3manager UI deployment now correctly resolves the S3 endpoint using BucketInfo from COSI credentials.
  • Credential Mismatch Fix: Addressed the "invalid credentials" error caused by s3manager attempting to connect to an incorrect S3 endpoint.
  • Fallback Mechanism: Implemented a fallback to the constructed namespace host for initial deployments when BucketAccess secrets are not yet available.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/system/bucket/templates/deployment.yaml
    • Introduced Helm templating logic to retrieve the S3 endpoint from BucketInfo within BucketAccess secrets.
    • Modified the ENDPOINT environment variable in the s3manager deployment to use the dynamically determined S3 endpoint.
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.

@dosubot dosubot bot added the bug Something isn't working label Mar 12, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c9478783-2ae9-439d-8256-47d3b6f8ebe4

📥 Commits

Reviewing files that changed from the base of the PR and between 941fb02 and f647cfd.

📒 Files selected for processing (1)
  • packages/system/bucket/templates/deployment.yaml

📝 Walkthrough

Walkthrough

The deployment template now sources the S3 endpoint dynamically from per-user secrets instead of using a hard-coded value. The template iterates over users, retrieves their associated Secrets, decodes the BucketInfo, extracts the endpoint, removes the "https://" prefix, and assigns it to the ENDPOINT environment variable, with a fallback to the original template value if no secret exists.

Changes

Cohort / File(s) Summary
S3 Endpoint Configuration
packages/system/bucket/templates/deployment.yaml
Modified ENDPOINT environment variable assignment to dynamically fetch S3 endpoint from per-user Secrets instead of using a hard-coded value. Added iterative lookup logic with conditional fallback to original template value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A secret whispers through the template's ear,
Each user's endpoint now crystal clear,
No more hardcoding, flexibility's here,
Kubernetes secrets bring cheer, bring cheer!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title '[bucket] Fix s3manager endpoint mismatch with COSI credentials' is fully related to the main change in the changeset. It accurately summarizes the key problem being fixed: resolving the endpoint mismatch between s3manager and COSI-provided credentials.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/bucket-s3manager-endpoint
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

Copy link
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 fixes an issue where the s3manager UI was using a constructed S3 endpoint instead of the one provided by COSI, leading to authentication failures. The change introduces logic to look up an existing user's secret to extract the correct endpoint, with a fallback to the old behavior. My review focuses on making this new logic more robust and efficient by avoiding an unnecessary loop over all users.

Comment on lines +2 to +9
{{- range $name, $user := .Values.users }}
{{- $secretName := printf "%s-%s" $.Values.bucketName $name }}
{{- $existingSecret := lookup "v1" "Secret" $.Release.Namespace $secretName }}
{{- if $existingSecret }}
{{- $bucketInfo := fromJson (b64dec (index $existingSecret.data "BucketInfo")) }}
{{- $endpoint = trimPrefix "https://" (index $bucketInfo.spec.secretS3 "endpoint") }}
{{- end }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The current logic iterates through all users and repeatedly overwrites the $endpoint variable. This is inefficient and could lead to non-deterministic behavior if different users' secrets were to contain different endpoints, as map iteration order is not guaranteed. Since the S3 endpoint from COSI should be the same for all users of a bucket, it's more robust and efficient to get the endpoint from just one user secret.

I suggest refactoring this to deterministically pick one user (e.g., the first one alphabetically) and get the endpoint from their secret, avoiding the loop altogether.

{{- with (keys .Values.users | sortAlpha | first) }}
  {{- $secretName := printf "%s-%s" $.Values.bucketName . }}
  {{- $existingSecret := lookup "v1" "Secret" $.Release.Namespace $secretName }}
  {{- if $existingSecret }}
    {{- $bucketInfo := fromJson (b64dec (index $existingSecret.data "BucketInfo")) }}
    {{- $endpoint = trimPrefix "https://" (index $bucketInfo.spec.secretS3 "endpoint") }}
  {{- end }}
{{- end }}

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 12, 2026
@kvaps kvaps added backport Should change be backported on previus release backport-previous labels Mar 13, 2026
@kvaps kvaps merged commit 22f2e4f into main Mar 13, 2026
23 of 25 checks passed
@kvaps kvaps deleted the fix/bucket-s3manager-endpoint branch March 13, 2026 15:23
@github-actions
Copy link

Backport failed for release-1.0, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-1.0
git worktree add -d .worktree/backport-2211-to-release-1.0 origin/release-1.0
cd .worktree/backport-2211-to-release-1.0
git switch --create backport-2211-to-release-1.0
git cherry-pick -x f647cfd7b9b339b2dc4aa0078b480239fe30095e

@github-actions
Copy link

Successfully created backport PR for release-1.1:

kvaps added a commit that referenced this pull request Mar 13, 2026
…COSI credentials (#2215)

# Description
Backport of #2211 to `release-1.1`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Should change be backported on previus release backport-previous bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants