add debug logging for client selection (#8556)

This commit is contained in:
Becca Petrin 2020-03-16 13:36:47 -07:00 committed by GitHub
parent f4de04d87e
commit a69167ac11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -250,12 +250,19 @@ func (b *backend) clientIAM(ctx context.Context, s logical.Storage, region, acco
if err != nil {
return nil, err
}
if stsRole == "" {
b.Logger().Debug(fmt.Sprintf("no stsRole found for %s", accountID))
} else {
b.Logger().Debug(fmt.Sprintf("found stsRole %s for account %s", stsRole, accountID))
}
b.configMutex.RLock()
if b.IAMClientsMap[region] != nil && b.IAMClientsMap[region][stsRole] != nil {
defer b.configMutex.RUnlock()
// If the client object was already created, return it
b.Logger().Debug(fmt.Sprintf("returning cached client for region %s and stsRole %s", region, stsRole))
return b.IAMClientsMap[region][stsRole], nil
}
b.Logger().Debug(fmt.Sprintf("no cached client for region %s and stsRole %s", region, stsRole))
// Release the read lock and acquire the write lock
b.configMutex.RUnlock()