InfluxDB: Run queries in parallel behind influxdbRunQueriesInParallel feature toggle (#81209)
* create the feature flag * bring the concurrency in to the play * Update feature flag * Use concurrency number from settings * update influxdb dependency * use ConcurrentQueryCount from plugin-sdk-go * use helper method for concurrent query count * log the error * add value guard * add unit tests * handle concurrency error
This commit is contained in:
@@ -48,12 +48,14 @@ type Cfg struct {
|
||||
|
||||
AngularSupportEnabled bool
|
||||
HideAngularDeprecation []string
|
||||
|
||||
ConcurrentQueryCount int
|
||||
}
|
||||
|
||||
func NewCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSettings, pluginsAllowUnsigned []string,
|
||||
awsAllowedAuthProviders []string, awsAssumeRoleEnabled bool, awsExternalId string, azure *azsettings.AzureSettings, secureSocksDSProxy setting.SecureSocksDSProxySettings,
|
||||
grafanaVersion string, logDatasourceRequests bool, pluginsCDNURLTemplate string, appURL string, appSubURL string, tracing Tracing, features featuremgmt.FeatureToggles, angularSupportEnabled bool,
|
||||
grafanaComURL string, disablePlugins []string, hideAngularDeprecation []string, forwardHostEnvVars []string) *Cfg {
|
||||
grafanaComURL string, disablePlugins []string, hideAngularDeprecation []string, forwardHostEnvVars []string, concurrentQueryCount int) *Cfg {
|
||||
return &Cfg{
|
||||
log: log.New("plugin.cfg"),
|
||||
PluginsPath: pluginsPath,
|
||||
@@ -77,5 +79,6 @@ func NewCfg(devMode bool, pluginsPath string, pluginSettings setting.PluginSetti
|
||||
AngularSupportEnabled: angularSupportEnabled,
|
||||
HideAngularDeprecation: hideAngularDeprecation,
|
||||
ForwardHostEnvVars: forwardHostEnvVars,
|
||||
ConcurrentQueryCount: concurrentQueryCount,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/experimental/featuretoggles"
|
||||
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/plugins/auth"
|
||||
"github.com/grafana/grafana/pkg/plugins/config"
|
||||
@@ -105,14 +106,17 @@ func (s *Service) GetConfigMap(ctx context.Context, pluginID string, _ *auth.Ext
|
||||
if s.cfg.GrafanaAppURL != "" {
|
||||
m[backend.AppURL] = s.cfg.GrafanaAppURL
|
||||
}
|
||||
if s.cfg.ConcurrentQueryCount != 0 {
|
||||
m[backend.ConcurrentQueryCount] = strconv.Itoa(s.cfg.ConcurrentQueryCount)
|
||||
}
|
||||
|
||||
// TODO add support via plugin SDK
|
||||
//if externalService != nil {
|
||||
// if externalService != nil {
|
||||
// m[oauthtokenretriever.AppURL] = s.cfg.GrafanaAppURL
|
||||
// m[oauthtokenretriever.AppClientID] = externalService.ClientID
|
||||
// m[oauthtokenretriever.AppClientSecret] = externalService.ClientSecret
|
||||
// m[oauthtokenretriever.AppPrivateKey] = externalService.PrivateKey
|
||||
//}
|
||||
// }
|
||||
|
||||
if s.cfg.Features != nil {
|
||||
enabledFeatures := s.cfg.Features.GetEnabled(ctx)
|
||||
@@ -126,15 +130,15 @@ func (s *Service) GetConfigMap(ctx context.Context, pluginID string, _ *auth.Ext
|
||||
}
|
||||
}
|
||||
// TODO add support via plugin SDK
|
||||
//if s.cfg.AWSAssumeRoleEnabled {
|
||||
// if s.cfg.AWSAssumeRoleEnabled {
|
||||
// m[awsds.AssumeRoleEnabledEnvVarKeyName] = "true"
|
||||
//}
|
||||
//if len(s.cfg.AWSAllowedAuthProviders) > 0 {
|
||||
// }
|
||||
// if len(s.cfg.AWSAllowedAuthProviders) > 0 {
|
||||
// m[awsds.AllowedAuthProvidersEnvVarKeyName] = strings.Join(s.cfg.AWSAllowedAuthProviders, ",")
|
||||
//}
|
||||
//if s.cfg.AWSExternalId != "" {
|
||||
// }
|
||||
// if s.cfg.AWSExternalId != "" {
|
||||
// m[awsds.GrafanaAssumeRoleExternalIdKeyName] = s.cfg.AWSExternalId
|
||||
//}
|
||||
// }
|
||||
|
||||
if s.cfg.ProxySettings.Enabled {
|
||||
m[proxy.PluginSecureSocksProxyEnabled] = "true"
|
||||
@@ -198,10 +202,10 @@ func (s *Service) GetConfigMap(ctx context.Context, pluginID string, _ *auth.Ext
|
||||
}
|
||||
|
||||
// TODO add support via plugin SDK
|
||||
//ps := getPluginSettings(pluginID, s.cfg)
|
||||
//for k, v := range ps {
|
||||
// ps := getPluginSettings(pluginID, s.cfg)
|
||||
// for k, v := range ps {
|
||||
// m[fmt.Sprintf("%s_%s", customConfigPrefix, strings.ToUpper(k))] = v
|
||||
//}
|
||||
// }
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
@@ -798,6 +798,33 @@ func TestService_GetConfigMap_appURL(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestService_GetConfigMap_concurrentQueryCount(t *testing.T) {
|
||||
t.Run("Uses the configured concurrent query count", func(t *testing.T) {
|
||||
s := &Service{
|
||||
cfg: &config.Cfg{
|
||||
ConcurrentQueryCount: 42,
|
||||
},
|
||||
}
|
||||
require.Equal(t, map[string]string{"GF_CONCURRENT_QUERY_COUNT": "42"}, s.GetConfigMap(context.Background(), "", nil))
|
||||
})
|
||||
|
||||
t.Run("Doesn't set the concurrent query count if it is not in the config", func(t *testing.T) {
|
||||
s := &Service{
|
||||
cfg: &config.Cfg{},
|
||||
}
|
||||
require.Equal(t, map[string]string{}, s.GetConfigMap(context.Background(), "", nil))
|
||||
})
|
||||
|
||||
t.Run("Doesn't set the concurrent query count if it is zero", func(t *testing.T) {
|
||||
s := &Service{
|
||||
cfg: &config.Cfg{
|
||||
ConcurrentQueryCount: 0,
|
||||
},
|
||||
}
|
||||
require.Equal(t, map[string]string{}, s.GetConfigMap(context.Background(), "", nil))
|
||||
})
|
||||
}
|
||||
|
||||
func TestService_GetConfigMap_azure(t *testing.T) {
|
||||
azSettings := &azsettings.AzureSettings{
|
||||
Cloud: azsettings.AzurePublic,
|
||||
|
||||
Reference in New Issue
Block a user