Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): temporary fix for pprof enabled setting precedence #2786

Merged
merged 3 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion chain/dev/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ modules = [
ws-port = 8546

[pprof]
enabled = false
listening-address = "localhost:6060"
block-rate = 0
mutex-rate = 0
3 changes: 0 additions & 3 deletions chain/dev/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ var (
const (
// PprofConfig

// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
DefaultPprofEnabled = true

// DefaultPprofListeningAddress default pprof HTTP server listening address.
DefaultPprofListeningAddress = "localhost:6060"

Expand Down
1 change: 0 additions & 1 deletion chain/gssmr/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ modules = [
ws-port = 8546

[pprof]
enabled = false
listening-address = "localhost:6060"
block-rate = 0
mutex-rate = 0
3 changes: 0 additions & 3 deletions chain/gssmr/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ var (
const (
// PprofConfig

// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
DefaultPprofEnabled = true

// DefaultPprofListeningAddress default pprof HTTP server listening address.
DefaultPprofListeningAddress = "localhost:6060"

Expand Down
1 change: 0 additions & 1 deletion chain/kusama/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ ws = false
ws-external = false

[pprof]
enabled = false
listening-address = "localhost:6060"
block-rate = 0
mutex-rate = 0
3 changes: 0 additions & 3 deletions chain/kusama/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ var (
const (
// PprofConfig

// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
DefaultPprofEnabled = false

// DefaultPprofListeningAddress default pprof HTTP server listening address.
DefaultPprofListeningAddress = "localhost:6060"

Expand Down
1 change: 0 additions & 1 deletion chain/polkadot/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "
ws-port = 8546

[pprof]
enabled = false
listening-address = "localhost:6060"
block-rate = 0
mutex-rate = 0
3 changes: 0 additions & 3 deletions chain/polkadot/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ var (
const (
// PprofConfig

// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
DefaultPprofEnabled = false

// DefaultPprofListeningAddress default pprof HTTP server listening address.
DefaultPprofListeningAddress = "localhost:6060"

Expand Down
14 changes: 4 additions & 10 deletions cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,10 @@ func updateDotConfigFromGenesisData(ctx *cli.Context, cfg *dot.Config) error {
}

func setDotPprofConfig(ctx *cli.Context, tomlCfg ctoml.PprofConfig, cfg *dot.PprofConfig) {
if !cfg.Enabled {
// only allow to enable pprof from the TOML configuration.
// If it is enabled by default, it cannot be disabled.
// Flag takes precedence over TOML config, default is ignored.
if ctx.GlobalIsSet(PprofServerFlag.Name) {
cfg.Enabled = ctx.GlobalBool(PprofServerFlag.Name)
} else {
cfg.Enabled = tomlCfg.Enabled
}

Expand All @@ -905,13 +906,6 @@ func setDotPprofConfig(ctx *cli.Context, tomlCfg ctoml.PprofConfig, cfg *dot.Ppr
cfg.Settings.MutexProfileRate = tomlCfg.MutexRate
}

// check --pprofserver flag and update node configuration
if enabled := ctx.GlobalBool(PprofServerFlag.Name); enabled || cfg.Enabled {
cfg.Enabled = true
} else if ctx.IsSet(PprofServerFlag.Name) && !enabled {
cfg.Enabled = false
}

// check --pprofaddress flag and update node configuration
if address := ctx.GlobalString(PprofAddressFlag.Name); address != "" {
cfg.Settings.ListeningAddress = address
Expand Down
4 changes: 0 additions & 4 deletions dot/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ func GssmrConfig() *Config {
WSPort: gssmr.DefaultRPCWSPort,
},
Pprof: PprofConfig{
Enabled: gssmr.DefaultPprofEnabled,
Settings: pprof.Settings{
ListeningAddress: gssmr.DefaultPprofListeningAddress,
BlockProfileRate: gssmr.DefaultPprofBlockRate,
Expand Down Expand Up @@ -297,7 +296,6 @@ func KusamaConfig() *Config {
WSPort: kusama.DefaultRPCWSPort,
},
Pprof: PprofConfig{
Enabled: kusama.DefaultPprofEnabled,
Settings: pprof.Settings{
ListeningAddress: kusama.DefaultPprofListeningAddress,
BlockProfileRate: kusama.DefaultPprofBlockRate,
Expand Down Expand Up @@ -355,7 +353,6 @@ func PolkadotConfig() *Config {
WSPort: polkadot.DefaultRPCWSPort,
},
Pprof: PprofConfig{
Enabled: polkadot.DefaultPprofEnabled,
Settings: pprof.Settings{
ListeningAddress: polkadot.DefaultPprofListeningAddress,
BlockProfileRate: polkadot.DefaultPprofBlockRate,
Expand Down Expand Up @@ -418,7 +415,6 @@ func DevConfig() *Config {
WS: dev.DefaultWSEnabled,
},
Pprof: PprofConfig{
Enabled: dev.DefaultPprofEnabled,
Settings: pprof.Settings{
ListeningAddress: dev.DefaultPprofListeningAddress,
BlockProfileRate: dev.DefaultPprofBlockRate,
Expand Down
2 changes: 0 additions & 2 deletions dot/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func TestConfig(t *testing.T) {
WS: true,
},
Pprof: PprofConfig{
Enabled: true,
Settings: pprof.Settings{
ListeningAddress: "localhost:6060",
},
Expand Down Expand Up @@ -134,7 +133,6 @@ func TestConfig(t *testing.T) {
WSUnsafeExternal: false,
},
Pprof: PprofConfig{
Enabled: true,
Settings: pprof.Settings{
ListeningAddress: "localhost:6060",
BlockProfileRate: 0,
Expand Down