Skip to content

objstore: extract AWS SDK related logic into separate client and extract common code of s3 like store#65561

Merged
ti-chi-bot[bot] merged 7 commits intopingcap:masterfrom
D3Hunter:encapsulate-s3
Jan 16, 2026
Merged

objstore: extract AWS SDK related logic into separate client and extract common code of s3 like store#65561
ti-chi-bot[bot] merged 7 commits intopingcap:masterfrom
D3Hunter:encapsulate-s3

Conversation

@D3Hunter
Copy link
Copy Markdown
Contributor

@D3Hunter D3Hunter commented Jan 13, 2026

What problem does this PR solve?

Issue Number: ref #65461

Problem Summary:

What changed and how does it work?

  • extract code commmon to s3 and s3 compatible store into a separate pkg
  • extract AWS SDK related logic into separate client, and refactor the way to check permissions
  • fix a issue that we take permission check of GetObject as success when the error is not smithy.APIError, this issue shouldn't happen normally, but we fix it anyway

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 13, 2026
@tiprow
Copy link
Copy Markdown

tiprow bot commented Jan 13, 2026

Hi @D3Hunter. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

name string
}

func (s *asyncWriter) start(ctx context.Context) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is from here

s3Writer.wg.Add(1)
go func() {
_, err := up.Upload(ctx, upParams)
// like a channel we only let sender close the pipe in happy path
if err != nil {
log.Warn("upload to s3 failed", zap.String("filename", name), zap.Error(err))
_ = rd.CloseWithError(err)
}
s3Writer.err = err
s3Writer.wg.Done()
}()

require.Equal(t, []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), res)
}

func TestPutAndDeleteObjectCheck(t *testing.T) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moved to s3like permission test

return nil
}
}
return errors.Trace(err)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

previously we take other error as success

// if key not exists and we reach this error, that
// means we have the correct permission to GetObject
// other we will get another error
return nil
}
return errors.Trace(err)
}
return nil

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 66.42066% with 182 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.7342%. Comparing base (8333420) to head (512691b).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #65561        +/-   ##
================================================
- Coverage   77.8487%   77.7342%   -0.1146%     
================================================
  Files          1978       1905        -73     
  Lines        542181     530747     -11434     
================================================
- Hits         422081     412572      -9509     
+ Misses       118441     118168       -273     
+ Partials       1659          7      -1652     
Flag Coverage Δ
integration 41.6391% <0.0000%> (-6.5508%) ⬇️
unit 76.8621% <66.4206%> (+0.4029%) ⬆️

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

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.8272% <ø> (-12.3154%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +354 to +358
type multipartWriter struct {
svc S3API
createOutput *s3.CreateMultipartUploadOutput
completeParts []types.CompletedPart
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

renamed from

type S3Uploader struct {
svc S3API
createOutput *s3.CreateMultipartUploadOutput
completeParts []types.CompletedPart
}

key string
}

func (u *multipartUploader) Upload(ctx context.Context, rd io.Reader) error {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

abstracted from

upParams := &s3.PutObjectInput{
Bucket: aws.String(rs.options.Bucket),
Key: aws.String(rs.options.Prefix + name),
Body: rd,
}
s3Writer := &s3ObjectWriter{wd: wd, wg: &sync.WaitGroup{}}
s3Writer.wg.Add(1)
go func() {
_, err := up.Upload(ctx, upParams)

@D3Hunter
Copy link
Copy Markdown
Contributor Author

/retest

@D3Hunter D3Hunter changed the title [wip]objstore: extract AWS SDK related logic into separate client and extract common code of s3 like store objstore: extract AWS SDK related logic into separate client and extract common code of s3 like store Jan 15, 2026
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 15, 2026
@D3Hunter
Copy link
Copy Markdown
Contributor Author

/retest

@tiprow
Copy link
Copy Markdown

tiprow bot commented Jan 15, 2026

@D3Hunter: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 15, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Jan 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joechenrh, Leavrth

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 16, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Jan 16, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-15 13:21:19.037752582 +0000 UTC m=+68106.651709438: ☑️ agreed by joechenrh.
  • 2026-01-16 01:44:43.892091587 +0000 UTC m=+112711.506048433: ☑️ agreed by Leavrth.

@tiprow
Copy link
Copy Markdown

tiprow bot commented Jan 16, 2026

@D3Hunter: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tidb_parser_test 512691b link true /test tidb_parser_test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@lance6716
Copy link
Copy Markdown
Contributor

/retest

@tiprow
Copy link
Copy Markdown

tiprow bot commented Jan 16, 2026

@lance6716: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit e4bd81b into pingcap:master Jan 16, 2026
30 of 31 checks passed
@D3Hunter D3Hunter deleted the encapsulate-s3 branch January 16, 2026 04:29
hawkingrei pushed a commit to hawkingrei/tidb that referenced this pull request Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants