From 0a60524a9c85bc74ed82512fcccc57accbddff08 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 3 Aug 2022 20:50:01 +0300 Subject: [PATCH] [#1654] ir, node: Drop deprecated `profiler` and `metrics` config sections Signed-off-by: Pavel Karpy --- cmd/neofs-ir/defaults.go | 8 +++---- cmd/neofs-ir/main.go | 30 ++++-------------------- cmd/neofs-node/config/metrics/config.go | 24 ++++++------------- cmd/neofs-node/config/profiler/config.go | 20 +++++----------- config/example/node.env | 12 +++++----- config/example/node.json | 4 ++-- 6 files changed, 30 insertions(+), 68 deletions(-) diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index a9ed663f63..6b571a5703 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -37,11 +37,11 @@ func newConfig(path string) (*viper.Viper, error) { func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("logger.level", "info") - cfg.SetDefault("profiler.address", "localhost:6060") - cfg.SetDefault("profiler.shutdown_timeout", "30s") + cfg.SetDefault("pprof.address", "localhost:6060") + cfg.SetDefault("pprof.shutdown_timeout", "30s") - cfg.SetDefault("metrics.address", "localhost:9090") - cfg.SetDefault("metrics.shutdown_timeout", "30s") + cfg.SetDefault("prometheus.address", "localhost:9090") + cfg.SetDefault("prometheus.shutdown_timeout", "30s") cfg.SetDefault("without_mainnet", false) diff --git a/cmd/neofs-ir/main.go b/cmd/neofs-ir/main.go index f6eb1c6d7c..7274d2c9c4 100644 --- a/cmd/neofs-ir/main.go +++ b/cmd/neofs-ir/main.go @@ -110,51 +110,31 @@ func main() { func initHTTPServers(cfg *viper.Viper, log *logger.Logger) []*httputil.Server { items := []struct { cfgPrefix string - oldPrefix string handler func() http.Handler }{ - {"pprof", "profiler", httputil.Handler}, - {"prometheus", "metrics", promhttp.Handler}, + {"pprof", httputil.Handler}, + {"prometheus", promhttp.Handler}, } httpServers := make([]*httputil.Server, 0, len(items)) for _, item := range items { - var printDeprecatedMsg bool if !cfg.GetBool(item.cfgPrefix + ".enabled") { - if !cfg.GetBool(item.oldPrefix + ".enabled") { - log.Info(item.cfgPrefix + " is disabled, skip") - continue - } - printDeprecatedMsg = true + log.Info(item.cfgPrefix + " is disabled, skip") + continue } - // The default value is set only for the deprecated prefix, so empty string can be returned. addr := cfg.GetString(item.cfgPrefix + ".address") - if addr == "" { - addr = cfg.GetString(item.oldPrefix + ".address") - printDeprecatedMsg = true - } var prm httputil.Prm prm.Address = addr prm.Handler = item.handler() - timeout := cfg.GetDuration(item.cfgPrefix + ".shutdown_timeout") - if timeout == 0 { - timeout = cfg.GetDuration(item.oldPrefix + ".shutdown_timeout") - printDeprecatedMsg = true - } - - if printDeprecatedMsg { - log.Info(item.oldPrefix + " config section is deprecated, use " + item.cfgPrefix) - } - httpServers = append(httpServers, httputil.New(prm, httputil.WithShutdownTimeout( - timeout, + cfg.GetDuration(item.cfgPrefix+".shutdown_timeout"), ), ), ) diff --git a/cmd/neofs-node/config/metrics/config.go b/cmd/neofs-node/config/metrics/config.go index 03514016a9..d5941a6fdd 100644 --- a/cmd/neofs-node/config/metrics/config.go +++ b/cmd/neofs-node/config/metrics/config.go @@ -7,8 +7,7 @@ import ( ) const ( - subsection = "prometheus" - subsectionOld = "metrics" + subsection = "prometheus" // ShutdownTimeoutDefault is a default value for metrics HTTP service timeout. ShutdownTimeoutDefault = 30 * time.Second @@ -18,25 +17,19 @@ const ( ) // Enabled returns the value of "enabled" config parameter -// from "metrics" section. +// from "prometheus" section. // // Returns false if the value is missing or invalid. func Enabled(c *config.Config) bool { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - return config.BoolSafe(s, "enabled") + return config.BoolSafe(c.Sub(subsection), "enabled") } // ShutdownTimeout returns the value of "shutdown_timeout" config parameter -// from "metrics" section. +// from "prometheus" section. // // Returns ShutdownTimeoutDefault if the value is not positive duration. func ShutdownTimeout(c *config.Config) time.Duration { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - v := config.DurationSafe(s, "shutdown_timeout") + v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout") if v > 0 { return v } @@ -45,14 +38,11 @@ func ShutdownTimeout(c *config.Config) time.Duration { } // Address returns the value of "address" config parameter -// from "metrics" section. +// from "prometheus" section. // // Returns AddressDefault if the value is not set. func Address(c *config.Config) string { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - v := config.StringSafe(s, "address") + v := config.StringSafe(c.Sub(subsection), "address") if v != "" { return v } diff --git a/cmd/neofs-node/config/profiler/config.go b/cmd/neofs-node/config/profiler/config.go index 2ad9cee7a5..6419b803ab 100644 --- a/cmd/neofs-node/config/profiler/config.go +++ b/cmd/neofs-node/config/profiler/config.go @@ -7,8 +7,7 @@ import ( ) const ( - subsection = "pprof" - subsectionOld = "profiler" + subsection = "pprof" // ShutdownTimeoutDefault is a default value for profiler HTTP service timeout. ShutdownTimeoutDefault = 30 * time.Second @@ -18,25 +17,19 @@ const ( ) // Enabled returns the value of "enabled" config parameter -// from "profiler" section. +// from "pprof" section. // // Returns false if the value is missing or invalid. func Enabled(c *config.Config) bool { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - return config.BoolSafe(s, "enabled") + return config.BoolSafe(c.Sub(subsection), "enabled") } // ShutdownTimeout returns the value of "shutdown_timeout" config parameter -// from "profiler" section. +// from "pprof" section. // // Returns ShutdownTimeoutDefault if the value is not positive duration. func ShutdownTimeout(c *config.Config) time.Duration { - s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) - - v := config.DurationSafe(s, "shutdown_timeout") + v := config.DurationSafe(c.Sub(subsection), "shutdown_timeout") if v > 0 { return v } @@ -45,12 +38,11 @@ func ShutdownTimeout(c *config.Config) time.Duration { } // Address returns the value of "address" config parameter -// from "profiler" section. +// from "pprof" section. // // Returns AddressDefault if the value is not set. func Address(c *config.Config) string { s := c.Sub(subsection) - s.SetDefault(c.Sub(subsectionOld)) v := config.StringSafe(s, "address") if v != "" { diff --git a/config/example/node.env b/config/example/node.env index 8a018d1c8a..2f91b3696c 100644 --- a/config/example/node.env +++ b/config/example/node.env @@ -1,12 +1,12 @@ NEOFS_LOGGER_LEVEL=debug -NEOFS_PROFILER_ENABLED=true -NEOFS_PROFILER_ADDRESS=localhost:6060 -NEOFS_PROFILER_SHUTDOWN_TIMEOUT=15s +NEOFS_PPROF_ENABLED=true +NEOFS_PPROF_ADDRESS=localhost:6060 +NEOFS_PPROF_SHUTDOWN_TIMEOUT=15s -NEOFS_METRICS_ENABLED=true -NEOFS_METRICS_ADDRESS=localhost:9090 -NEOFS_METRICS_SHUTDOWN_TIMEOUT=15s +NEOFS_PROMETHEUS_ENABLED=true +NEOFS_PROMETHEUS_ADDRESS=localhost:9090 +NEOFS_PROMETHEUS_SHUTDOWN_TIMEOUT=15s # Node section NEOFS_NODE_KEY=./wallet.key diff --git a/config/example/node.json b/config/example/node.json index 53c4aaa61d..0e19233ca0 100644 --- a/config/example/node.json +++ b/config/example/node.json @@ -2,12 +2,12 @@ "logger": { "level": "debug" }, - "profiler": { + "pprof": { "enabled": true, "address": "localhost:6060", "shutdown_timeout": "15s" }, - "metrics": { + "prometheus": { "enabled": true, "address": "localhost:9090", "shutdown_timeout": "15s"