From 9108fd1b9d5646aa24ee51661cf8e5eefcd52525 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Thu, 24 Jan 2019 14:04:21 -0500 Subject: [PATCH] add global datasource proxy timeout setting closes grafana#5699 --- conf/defaults.ini | 3 +++ conf/sample.ini | 3 +++ pkg/api/pluginproxy/ds_proxy.go | 2 +- pkg/setting/setting.go | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/conf/defaults.ini b/conf/defaults.ini index 37e1ee2c7df..ae9afded3e4 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -143,6 +143,9 @@ conn_max_lifetime = 14400 # This enables data proxy logging, default is false logging = false +# How long the data proxy should wait before timing out default is 30 (seconds) +timeout = 30 + #################################### Analytics ########################### [analytics] # Server reporting, sends usage counters to stats.grafana.org every 24 hours. diff --git a/conf/sample.ini b/conf/sample.ini index 96b92db6f48..413695c02e0 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -130,6 +130,9 @@ log_queries = # This enables data proxy logging, default is false ;logging = false +# How long the data proxy should wait before timing out default is 30 (seconds) +;timeout = 30 + #################################### Analytics #################################### [analytics] # Server reporting, sends usage counters to stats.grafana.org every 24 hours. diff --git a/pkg/api/pluginproxy/ds_proxy.go b/pkg/api/pluginproxy/ds_proxy.go index 38a2fd187e3..b569b006531 100644 --- a/pkg/api/pluginproxy/ds_proxy.go +++ b/pkg/api/pluginproxy/ds_proxy.go @@ -54,7 +54,7 @@ func NewDataSourceProxy(ds *m.DataSource, plugin *plugins.DataSourcePlugin, ctx func newHTTPClient() httpClient { return &http.Client{ - Timeout: time.Second * 30, + Timeout: time.Duration(setting.DataProxyTimeout) * time.Second, Transport: &http.Transport{Proxy: http.ProxyFromEnvironment}, } } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 1e4bc96cd7f..d88bdf1c299 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -77,6 +77,7 @@ var ( SocketPath string RouterLogging bool DataProxyLogging bool + DataProxyTimeout int StaticRootPath string EnableGzip bool EnforceDomain bool @@ -583,6 +584,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { // read data proxy settings dataproxy := iniFile.Section("dataproxy") DataProxyLogging = dataproxy.Key("logging").MustBool(false) + DataProxyTimeout = dataproxy.Key("timeout").MustInt(30) // read security settings security := iniFile.Section("security")