Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate the S3 SDK from v1 to v2 #16664

Merged
merged 3 commits into from
Sep 17, 2024
Merged

Migrate the S3 SDK from v1 to v2 #16664

merged 3 commits into from
Sep 17, 2024

Conversation

frouioui
Copy link
Member

@frouioui frouioui commented Aug 27, 2024

Description

This PR updates the version of the AWS SDK from v1 to v2. The version 1 has been deprecated for some time now.

I have ran the following manual test:

  1. Create a Vitess cluster (1 unsharded keyspace) from the main branch
  2. Insert some data
  3. Backup the cluster into AWS S3
  4. Teardown the cluster
  5. Create a Vitess cluster (same config) from the migrate-to-s3-v2 branch (with --restore_from_backup)
  6. Restore from the previous backup
  7. Observe that the inserted data shows up after restoring
  8. Take another backup on AWS S3
  9. List all available backup on AWS S3
  10. Restore the cluster from the latest backup (using RestoreFromBackup)
  11. Remove the first backup we did (the one from main) from AWS S3
  12. Teardown the cluster
  13. Create another Vitess cluster (same config) from the main branch (with --restore_from_backup)
  14. Observe that the inserted data shows up after restoring

This test ensures that we can upgrade: old backups will still work with the new code, and that we can downgrade: new backups will work with the old code. While making sure that no config/flag change is needed between the two code version. It also checks that the GetBackups and RestoreFromBackup vtctldclient commands work.

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Copy link
Contributor

vitess-bot bot commented Aug 27, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Aug 27, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Aug 27, 2024
@frouioui frouioui force-pushed the migrate-to-s3-v2 branch 2 times, most recently from bd75773 to 9edbe34 Compare September 5, 2024 16:04
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
@frouioui frouioui added Type: Internal Cleanup Component: Backup and Restore and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Sep 12, 2024
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 40.50633% with 47 lines in your changes missing coverage. Please review.

Project coverage is 68.96%. Comparing base (538dd4c) to head (02598ab).
Report is 81 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/mysqlctl/s3backupstorage/s3.go 37.50% 40 Missing ⚠️
go/vt/mysqlctl/s3backupstorage/retryer.go 57.14% 6 Missing ⚠️
go/vt/mysqlctl/xtrabackupengine.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16664      +/-   ##
==========================================
- Coverage   68.98%   68.96%   -0.03%     
==========================================
  Files        1562     1565       +3     
  Lines      200690   201770    +1080     
==========================================
+ Hits       138449   139142     +693     
- Misses      62241    62628     +387     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
u.PartSize = partSizeBytes
})
object := objName(bh.dir, bh.name, filename)
sendStats := bh.bs.params.Stats.Scope(stats.Operation("AWS:Request:Send"))
// Using UploadWithContext breaks uploading to Minio and Ceph https://github.com/vitessio/vitess/issues/14188
_, err := uploader.Upload(&s3manager.UploadInput{
_, err := uploader.Upload(context.Background(), &s3.PutObjectInput{
Copy link
Member Author

Choose a reason for hiding this comment

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

Using context.Background() is a side-effect of the issue described in #14188. Upgrading to the SDK V2 does not fix it, the issue is rooted in how we handle the context and the goroutines. I started investigating the issue a bit deeper and will continue in a subsequent PR.

@deepthi deepthi removed the request for review from rohit-nayak-ps September 12, 2024 23:27
r: &request.Request{
Retryable: aws.Bool(false),
},
name: "no error",
Copy link
Member

Choose a reason for hiding this comment

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

Nice refactor.

@@ -277,7 +277,7 @@ func (be *XtrabackupEngine) executeFullBackup(ctx context.Context, params Backup
if err != nil {
return BackupUnusable, vterrors.Wrapf(err, "cannot JSON encode %v", backupManifestFileName)
}
if _, err := mwc.Write([]byte(data)); err != nil {
if _, err := mwc.Write(data); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This code is going to be called regardless of s3 or other storage backend. Why this change?

Copy link
Member Author

@frouioui frouioui Sep 12, 2024

Choose a reason for hiding this comment

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

data is a already a slice of bytes, I saw it while debugging something and thought I'd remove the useless conversion, I can revert if you want

@frouioui frouioui merged commit 3182049 into main Sep 17, 2024
189 checks passed
@frouioui frouioui deleted the migrate-to-s3-v2 branch September 17, 2024 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants