mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
* fix ipv6 startup fail #81870 * ipv6 startup fail * ipv6 startup fail
This commit is contained in:
parent
fae9bfccb2
commit
ba8b4bde3a
@ -11,9 +11,12 @@ import (
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
func applyGrafanaConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles, o *options.Options) {
|
||||
func applyGrafanaConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles, o *options.Options) error {
|
||||
defaultLogLevel := 0
|
||||
ip := net.ParseIP(cfg.HTTPAddr)
|
||||
if ip == nil {
|
||||
return fmt.Errorf("invalid IP address: %s", cfg.HTTPAddr)
|
||||
}
|
||||
apiURL := cfg.AppURL
|
||||
port, err := strconv.Atoi(cfg.HTTPPort)
|
||||
if err != nil {
|
||||
@ -27,7 +30,7 @@ func applyGrafanaConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles, o
|
||||
apiURL = fmt.Sprintf("https://%s:%d", ip, port)
|
||||
}
|
||||
|
||||
host := fmt.Sprintf("%s:%d", ip, port)
|
||||
host := net.JoinHostPort(cfg.HTTPAddr, strconv.Itoa(port))
|
||||
|
||||
apiserverCfg := cfg.SectionWithEnvOverrides("grafana-apiserver")
|
||||
|
||||
@ -54,4 +57,5 @@ func applyGrafanaConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles, o
|
||||
o.ExtraOptions.ExternalAddress = host
|
||||
o.ExtraOptions.APIURL = apiURL
|
||||
o.ExtraOptions.Verbosity = apiserverCfg.Key("log_level").MustInt(defaultLogLevel)
|
||||
return nil
|
||||
}
|
||||
|
@ -212,7 +212,10 @@ func (s *service) start(ctx context.Context) error {
|
||||
}
|
||||
|
||||
o := grafanaapiserveroptions.NewOptions(Codecs.LegacyCodec(groupVersions...))
|
||||
applyGrafanaConfig(s.cfg, s.features, o)
|
||||
err := applyGrafanaConfig(s.cfg, s.features, o)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if errs := o.Validate(); len(errs) != 0 {
|
||||
// TODO: handle multiple errors
|
||||
@ -286,7 +289,7 @@ func (s *service) start(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Add OpenAPI specs for each group+version
|
||||
err := builder.SetupConfig(
|
||||
err = builder.SetupConfig(
|
||||
Scheme,
|
||||
serverConfig,
|
||||
builders,
|
||||
|
Loading…
Reference in New Issue
Block a user