Apiservers: expand/configure timeout
This commit is contained in:
@@ -40,12 +40,19 @@ func applyGrafanaConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles, o
|
||||
apiserverCfg := cfg.SectionWithEnvOverrides("grafana-apiserver")
|
||||
|
||||
runtimeConfig := apiserverCfg.Key("runtime_config").String()
|
||||
|
||||
if runtimeConfig != "" {
|
||||
if err := o.APIEnablementOptions.RuntimeConfig.Set(runtimeConfig); err != nil {
|
||||
return fmt.Errorf("failed to set runtime config: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// equivalent to --request-timeout flag from k8s apiserver
|
||||
requestTimeout := apiserverCfg.Key("request_timeout").MustDuration(0)
|
||||
if requestTimeout > 0 {
|
||||
o.ExtraOptions.RequestTimeout = requestTimeout
|
||||
}
|
||||
|
||||
o.RecommendedOptions.Etcd.StorageConfig.Transport.ServerList = apiserverCfg.Key("etcd_servers").Strings(",")
|
||||
|
||||
o.RecommendedOptions.SecureServing.BindAddress = ip
|
||||
|
||||
@@ -3,6 +3,7 @@ package options
|
||||
import (
|
||||
"log/slog"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
genericfeatures "k8s.io/apiserver/pkg/features"
|
||||
@@ -20,12 +21,14 @@ type ExtraOptions struct {
|
||||
ExternalAddress string
|
||||
APIURL string
|
||||
Verbosity int
|
||||
RequestTimeout time.Duration
|
||||
}
|
||||
|
||||
func NewExtraOptions() *ExtraOptions {
|
||||
return &ExtraOptions{
|
||||
DevMode: false,
|
||||
Verbosity: 0,
|
||||
DevMode: false,
|
||||
Verbosity: 0,
|
||||
RequestTimeout: 1 * time.Hour,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,15 @@ func (o *Options) ApplyTo(serverConfig *genericapiserver.RecommendedConfig) erro
|
||||
}
|
||||
serverConfig.SecureServing = nil
|
||||
}
|
||||
|
||||
// serverConfig.RequestTimeout is a k8s setting for all http requests, defaulting to 1 minute
|
||||
// This setting is not removable so we force a long timeout to match existing behavior
|
||||
// (ex: most (all?) sql datasources before apiservers were introduced did not have a global timeout and could run indefinitely)
|
||||
// Normally for apiservers, this is set with a command line flag, --request-timeout, however in st-mode, we set a default in ExtraOptions
|
||||
// and make it potentially configurable as needed by users in custom.ini
|
||||
if o.ExtraOptions.RequestTimeout > 0 {
|
||||
serverConfig.RequestTimeout = o.ExtraOptions.RequestTimeout
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user