Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

feat: Migrate to aws-sdk-go-v2 #233

Merged
merged 56 commits into from
Oct 14, 2021
Merged

feat: Migrate to aws-sdk-go-v2 #233

merged 56 commits into from
Oct 14, 2021

Conversation

Joey-1445601153
Copy link
Contributor

@Joey-1445601153 Joey-1445601153 commented Sep 28, 2021

Fix #86
It's incomplete now.

storage.go Outdated Show resolved Hide resolved
@Xuanwo Xuanwo changed the title fix:Migrate to aws-sdk-go-v2 feat: Migrate to aws-sdk-go-v2 Sep 29, 2021
service.go Outdated Show resolved Hide resolved
storage.go Outdated Show resolved Hide resolved
utils.go Outdated Show resolved Hide resolved
@Joey-1445601153 Joey-1445601153 marked this pull request as ready for review September 29, 2021 07:57
@Xuanwo
Copy link
Collaborator

Xuanwo commented Sep 29, 2021

Please fix all CI here.

@Xuanwo
Copy link
Collaborator

Xuanwo commented Sep 29, 2021

6           The error should be nil ✘    storager.go:238: delete: Storager s3 {Name: *******, WorkDir: /b5279654-b8cd-4e38-a1ca-d22e45a92382/}, [d7ef011a-d173-4652-b291-1d3c9481b22c]: unexpected: operation error S3: DeleteObject, exceeded maximum number of attempts, 3, https response error StatusCode: 0, RequestID: , HostID: , request send failed, Delete "https://*******.s3.us-west-2.amazonaws.com/b5279654-b8cd-4e38-a1ca-d22e45a92382/d7ef011a-d173-4652-b291-1d3c9481b22c?x-id=DeleteObject": 301 response missing Location header

Looks like we are missing the location.

@Xuanwo
Copy link
Collaborator

Xuanwo commented Sep 30, 2021

54         The error should be nil ✘✔    storager.go:291: write: Storager s3 {Name: *******, WorkDir: /f573cc53-e0f8-4a60-85ec-7ea6e61f10b8/}, [f19db38f-6934-4b2d-a459-f5adec2718ab]: unexpected: operation error S3: PutObject, exceeded maximum number of attempts, 3, https response error StatusCode: 0, RequestID: , HostID: , request send failed, Put "https://*******.s3.*******.amazonaws.com/f573cc53-e0f8-4a60-85ec-7ea6e61f10b8/f19db38f-6934-4b2d-a459-f5adec2718ab?x-id=PutObject": net/http: HTTP/1.x transport connection broken: http: ContentLength=1333208 with Body length 0

I believe this is why we need cfg.S3DisableContentMD5Validation = aws.Bool(true) before. Does aws-go-sdk-v2 provide similar feature?

@Joey-1445601153
Copy link
Contributor Author

54         The error should be nil ✘✔    storager.go:291: write: Storager s3 {Name: *******, WorkDir: /f573cc53-e0f8-4a60-85ec-7ea6e61f10b8/}, [f19db38f-6934-4b2d-a459-f5adec2718ab]: unexpected: operation error S3: PutObject, exceeded maximum number of attempts, 3, https response error StatusCode: 0, RequestID: , HostID: , request send failed, Put "https://*******.s3.*******.amazonaws.com/f573cc53-e0f8-4a60-85ec-7ea6e61f10b8/f19db38f-6934-4b2d-a459-f5adec2718ab?x-id=PutObject": net/http: HTTP/1.x transport connection broken: http: ContentLength=1333208 with Body length 0

I believe this is why we need cfg.S3DisableContentMD5Validation = aws.Bool(true) before. Does aws-go-sdk-v2 provide similar feature?

No,I have not found it yet.

@Xuanwo
Copy link
Collaborator

Xuanwo commented Sep 30, 2021

Maybe we need to use https://github.com/aws/aws-sdk-go-v2/blob/cc132614991d2e36a7b5ca8685aea13bf1337224/aws/signer/v4/middleware.go#L107-L110

GitHub
AWS SDK for the Go programming language. . Contribute to aws/aws-sdk-go-v2 development by creating an account on GitHub.

@Xuanwo
Copy link
Collaborator

Xuanwo commented Sep 30, 2021

We can call the previous function via

https://github.com/aws/aws-sdk-go-v2/blob/cc132614991d2e36a7b5ca8685aea13bf1337224/service/s3/api_client.go#L131-L135

GitHub
AWS SDK for the Go programming language. . Contribute to aws/aws-sdk-go-v2 development by creating an account on GitHub.

utils.go Outdated Show resolved Hide resolved
@Xuanwo
Copy link
Collaborator

Xuanwo commented Sep 30, 2021

1   go: github.com/beyondstorage/go-service-s3/v2: package github.com/aws/smithy-go/middleware imported from implicitly required module; to add missing requirements, run:

11:37:51     go get github.com/aws/smithy-go/[email protected]

11:37:51   make: *** [Makefile:35: integration_test] Error 1

11:37:52   Process exited with code 2

Please always run make build before submit.

@Joey-1445601153
Copy link
Contributor Author

Joey-1445601153 commented Sep 30, 2021

The error should be nil ✘    storager.go:201: delete: Storager s3 {Name: *******, WorkDir: /9b827af8-195e-49a3-a2b9-5e5645e4c296/}, [63386767-902c-4486-8660-7762a504e718]: unexpected: operation error S3: DeleteObject, https response error StatusCode: 400, RequestID: 4S6DEFYWG5MJCF6G, HostID: 2rJAfdfSIdDhwU/EayYcYq7U+l1Gcc/zYXLjugEJpJ74ePullv//mVc+bzNbms1F4ZfnGkHlsUY=, api error InvalidRequest: Missing required header for this request: x-amz-content-sha256

It seems like we have to find a way to replace cfg.LowerCaseHeaderMaps = aws.Bool(true).

@Xuanwo
Copy link
Collaborator

Xuanwo commented Sep 30, 2021

Maybe you want to use the following style to add code blocks.

```
xxxxx
```

service.toml Outdated
@@ -4,7 +4,7 @@ name = "s3"

[namespace.service.new]
required = ["credential"]
optional = [ "endpoint", "http_client_options", "force_path_style", "disable_100_continue", "use_accelerate", "use_arn_region"]
optional = [ "endpoint", "http_client_options", "force_path_style", "location", "disable_100_continue", "use_accelerate", "use_arn_region"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need location in this service?

@Xuanwo
Copy link
Collaborator

Xuanwo commented Oct 9, 2021

ping @JinnyYi for a review.

@Xuanwo Xuanwo requested review from a team October 9, 2021 09:06
utils.go Outdated Show resolved Hide resolved
utils.go Outdated Show resolved Hide resolved
utils.go Outdated Show resolved Hide resolved
storage.go Outdated

getReq, _ := s.service.GetObjectRequest(input)
url, headers, err := getReq.PresignRequest(expire)
presignClient := s3.NewPresignClient(s.service)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we need to set PresignOptions like expire?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we need to set PresignOptions like expire?

Yes, i missed it too!!!
i will check it and fix it right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems that the configs for presign client could be different with basic client? Maybe we can consider or discuss it later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JinnyYi
I found that in aws-sdk-go-v2's test case,they use it like

	presignClient := s3.NewPresignClient(s.service, func(options *s3.PresignOptions) {
		options.Expires = expire
	})

And now I config it in this way too.

@Xuanwo
Copy link
Collaborator

Xuanwo commented Oct 12, 2021

Looks much better than the first version!

@Joey-1445601153
Copy link
Contributor Author

Looks much better than the first version!

Well,thanks to all your reviewers.

@Xuanwo
Copy link
Collaborator

Xuanwo commented Oct 13, 2021

ping @JinnyYi for the final decision.

@JinnyYi
Copy link
Contributor

JinnyYi commented Oct 13, 2021

ping @JinnyYi for the final decision.

I've no more questions.

Maybe we should identify the following issues soon to provide capabilities equivalent to the current version:

@JinnyYi JinnyYi merged commit 712be85 into beyondstorage:master Oct 14, 2021
@Joey-1445601153 Joey-1445601153 deleted the dev branch October 14, 2021 02:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to aws-sdk-go-v2
5 participants