-
Notifications
You must be signed in to change notification settings - Fork 360
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
Upgrade code to use aws sdk go v2 #6486
Conversation
a737512
to
bad1f51
Compare
♻️ PR Preview 204c1f4 has been successfully destroyed since this PR has been closed. 🤖 By surge-preview |
e971157
to
eea0f60
Compare
a82f8c8
to
9de5ecb
Compare
@guy-har can you review only the adapter part that before had to stream data to s3 - the s3 client I'm using should provide the same functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! Amazing work.
27c8a32
to
a51cd7e
Compare
ddbf018
to
62cea17
Compare
…ming_chunk_timeout
ee79f8b
to
d6f1e39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only nits. It's a neat way of getting at the expiry time.
pkg/block/s3/adapter.go
Outdated
// TODO(barak): handle expiry window of the client credentials when pre-signed | ||
// support enabled | ||
expiry := time.Now().Add(a.preSignedExpiry) | ||
expiry := time.Now().UTC().Add(a.preSignedExpiry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UTC is a timezone. The best kind of timezone, but still a timezone. Unless Golang defaults yo something line SQL TIMESTAMP (which is without TIMEZONE), I don't think UTC is needed or required here.
Timezones belong when formatting time, not when processing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, I will remove it.
it was easy to debug as the aws credentials expire time was in this tz.
|
||
func (c *CaptureExpiresPresigner) PresignHTTP(ctx context.Context, credentials aws.Credentials, r *http.Request, payloadHash string, service string, region string, signingTime time.Time, optFns ...func(*v4.SignerOptions)) (url string, signedHeader http.Header, err error) { | ||
// capture credentials expiry | ||
c.CredentialsCanExpire = credentials.CanExpire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could just capture credentials and make them available later on. No need to run the processing logic here. I prefer to keep the signing path as simple and unmodified as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was worried about capturing something that holds a state that can change and instead capture the same information the signer accepted.
Let me know if you think. if the risk is low I'll update the code.
Also... I understand that the v2 SDK will refresh credentials, and do so on time? The v1 SDK doesn't refresh credentials if it only presigns, and we needed |
Yes, the sdk v2 presign_middleware.go calls |
if captureExpiresPresigner.CredentialsCanExpire && captureExpiresPresigner.CredentialsExpireAt.Before(expiry) { | ||
expiry = captureExpiresPresigner.CredentialsExpireAt | ||
expiry = captureExpiresPresigner.CredentialsExpireAt.Add(a.sessionExpiryWindow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PLEASE add a comment before this. I did not understand the logic until you explained it to me!
Perhaps something like
// AWS Go SDK v2 stores the time to renew credentials in `CredentialsExpireAt`. This is // a.sessionExpiryWindow before actual credentials expiry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @arielshaqed !
streaming_chunk_timeout
andstreaming_chunk_size
removed from S3.access_secret_key
was removed from S3 credentials.client_log_request
andclient_log_retries
added to s3 block adapter to control logging level of the s3 adapter.TODO:
Close #2684
Close #6553