From cd012bdfb42a607ac9e3d3096e1b3faeb397e92d Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 10 Mar 2020 14:10:48 +0100 Subject: [PATCH] Fix caching problem (#22473) --- pkg/tsdb/cloudwatch/credentials.go | 2 +- .../datasource/cloudwatch/components/ConfigEditor.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/tsdb/cloudwatch/credentials.go b/pkg/tsdb/cloudwatch/credentials.go index 7d3c7d6c80c..fa4ef619884 100644 --- a/pkg/tsdb/cloudwatch/credentials.go +++ b/pkg/tsdb/cloudwatch/credentials.go @@ -28,7 +28,7 @@ var awsCredentialCache = make(map[string]cache) var credentialCacheLock sync.RWMutex func GetCredentials(dsInfo *DatasourceInfo) (*credentials.Credentials, error) { - cacheKey := dsInfo.AccessKey + ":" + dsInfo.Profile + ":" + dsInfo.AssumeRoleArn + cacheKey := fmt.Sprintf("%s:%s:%s:%s", dsInfo.AuthType, dsInfo.AccessKey, dsInfo.Profile, dsInfo.AssumeRoleArn) credentialCacheLock.RLock() if _, ok := awsCredentialCache[cacheKey]; ok { if awsCredentialCache[cacheKey].expiration != nil && diff --git a/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx b/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx index 748942fd2d4..cc621107712 100644 --- a/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx @@ -130,7 +130,12 @@ export class ConfigEditor extends PureComponent { value={authProviderOptions.find(authProvider => authProvider.value === options.jsonData.authType)} options={authProviderOptions} defaultValue={options.jsonData.authType} - onChange={onUpdateDatasourceJsonDataOptionSelect(this.props, 'authType')} + onChange={option => { + if (options.jsonData.authType === 'arn' && option.value !== 'arn') { + delete this.props.options.jsonData.assumeRoleArn; + } + onUpdateDatasourceJsonDataOptionSelect(this.props, 'authType')(option); + }} />