-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix(provider-maxcompute): fixed and refactored maxcompute and oss client caching flow #203
base: main
Are you sure you want to change the base?
Conversation
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.
do we need to do the same changes in alicloud_ram
provider?
pkg/aliAuth/aliauth.go
Outdated
"github.com/aliyun/aliyun-odps-go-sdk/odps/account" | ||
) | ||
|
||
const assumeRoleDurationHours int64 = 1 |
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.
const assumeRoleDurationHours int64 = 1 | |
var assumeRoleDefaultDuration = time.Hour |
can we directly set the value into duration here?
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.
sure
pkg/aliAuth/aliauth.go
Outdated
|
||
var durationSeconds = assumeRoleDurationHours * int64(time.Hour.Seconds()) | ||
|
||
type AliAuthAccount struct { |
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.
let's make it internal
type AliAuthAccount struct { | |
type aliAuthAccount struct { |
pkg/aliAuth/aliauth.go
Outdated
return nil, time.Time{}, fmt.Errorf("failed to assume role: %w", err) | ||
} | ||
|
||
expiryTimeStamp := time.Now().Add(time.Hour * time.Duration(assumeRoleDurationHours)) |
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.
can we check if token TTL is also present in from the assume role response, and use it for expiry instead of using default duration
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.
TTL is not present in the assume role response😕
pkg/aliAuth/aliauth.go
Outdated
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.
let's change this to pkg/aliauth/aliauth.go
if odpsClient, ok := p.getCachedOdpsClient(ramRole, stsClientID, pc.URN); ok { | ||
return odpsClient, nil | ||
} | ||
ramRole := p.getRamRole(creds, ramRoleFromAppeal) |
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 let's rename ramRoleFromAppeal
to overrideRamRole
for easier understanding 😀
} | ||
delete(p.odpsClients, cachedClientKey) |
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.
let's do the mutex lock & unlock above and below this line only
delete(p.odpsClients, cachedClientKey) | |
p.mu.Lock() | |
delete(p.odpsClients, cachedClientKey) | |
p.mu.Unlock() |
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 we should take the mutex lock at the time we're retreiving the value from map and release it once the delete operation is done. WDYT?
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.
reading the value doesn't need to lock the mutex but updating/deleting does
No description provided.