Skip to content

Commit d4d6262

Browse files
authored
fix(config): temporary fix for pprof enabled setting precedence (#2786)
- Flag value is used first - TOML config value is then used - Default value is ignored (always `false`) - Remove default pprof enabled values
1 parent 102ddce commit d4d6262

File tree

11 files changed

+4
-32
lines changed

11 files changed

+4
-32
lines changed

chain/dev/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ modules = [
5252
ws-port = 8546
5353

5454
[pprof]
55-
enabled = false
5655
listening-address = "localhost:6060"
5756
block-rate = 0
5857
mutex-rate = 0

chain/dev/defaults.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ var (
9696
const (
9797
// PprofConfig
9898

99-
// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
100-
DefaultPprofEnabled = true
101-
10299
// DefaultPprofListeningAddress default pprof HTTP server listening address.
103100
DefaultPprofListeningAddress = "localhost:6060"
104101

chain/gssmr/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ modules = [
5454
ws-port = 8546
5555

5656
[pprof]
57-
enabled = false
5857
listening-address = "localhost:6060"
5958
block-rate = 0
6059
mutex-rate = 0

chain/gssmr/defaults.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ var (
104104
const (
105105
// PprofConfig
106106

107-
// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
108-
DefaultPprofEnabled = true
109-
110107
// DefaultPprofListeningAddress default pprof HTTP server listening address.
111108
DefaultPprofListeningAddress = "localhost:6060"
112109

chain/kusama/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ ws = false
4242
ws-external = false
4343

4444
[pprof]
45-
enabled = false
4645
listening-address = "localhost:6060"
4746
block-rate = 0
4847
mutex-rate = 0

chain/kusama/defaults.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ var (
8888
const (
8989
// PprofConfig
9090

91-
// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
92-
DefaultPprofEnabled = false
93-
9491
// DefaultPprofListeningAddress default pprof HTTP server listening address.
9592
DefaultPprofListeningAddress = "localhost:6060"
9693

chain/polkadot/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "
3939
ws-port = 8546
4040

4141
[pprof]
42-
enabled = false
4342
listening-address = "localhost:6060"
4443
block-rate = 0
4544
mutex-rate = 0

chain/polkadot/defaults.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ var (
8686
const (
8787
// PprofConfig
8888

89-
// DefaultPprofEnabled to indicate the pprof http server should be enabled or not.
90-
DefaultPprofEnabled = false
91-
9289
// DefaultPprofListeningAddress default pprof HTTP server listening address.
9390
DefaultPprofListeningAddress = "localhost:6060"
9491

cmd/gossamer/config.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,10 @@ func updateDotConfigFromGenesisData(ctx *cli.Context, cfg *dot.Config) error {
883883
}
884884

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

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

908-
// check --pprofserver flag and update node configuration
909-
if enabled := ctx.GlobalBool(PprofServerFlag.Name); enabled || cfg.Enabled {
910-
cfg.Enabled = true
911-
} else if ctx.IsSet(PprofServerFlag.Name) && !enabled {
912-
cfg.Enabled = false
913-
}
914-
915909
// check --pprofaddress flag and update node configuration
916910
if address := ctx.GlobalString(PprofAddressFlag.Name); address != "" {
917911
cfg.Settings.ListeningAddress = address

dot/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ func GssmrConfig() *Config {
239239
WSPort: gssmr.DefaultRPCWSPort,
240240
},
241241
Pprof: PprofConfig{
242-
Enabled: gssmr.DefaultPprofEnabled,
243242
Settings: pprof.Settings{
244243
ListeningAddress: gssmr.DefaultPprofListeningAddress,
245244
BlockProfileRate: gssmr.DefaultPprofBlockRate,
@@ -297,7 +296,6 @@ func KusamaConfig() *Config {
297296
WSPort: kusama.DefaultRPCWSPort,
298297
},
299298
Pprof: PprofConfig{
300-
Enabled: kusama.DefaultPprofEnabled,
301299
Settings: pprof.Settings{
302300
ListeningAddress: kusama.DefaultPprofListeningAddress,
303301
BlockProfileRate: kusama.DefaultPprofBlockRate,
@@ -355,7 +353,6 @@ func PolkadotConfig() *Config {
355353
WSPort: polkadot.DefaultRPCWSPort,
356354
},
357355
Pprof: PprofConfig{
358-
Enabled: polkadot.DefaultPprofEnabled,
359356
Settings: pprof.Settings{
360357
ListeningAddress: polkadot.DefaultPprofListeningAddress,
361358
BlockProfileRate: polkadot.DefaultPprofBlockRate,
@@ -418,7 +415,6 @@ func DevConfig() *Config {
418415
WS: dev.DefaultWSEnabled,
419416
},
420417
Pprof: PprofConfig{
421-
Enabled: dev.DefaultPprofEnabled,
422418
Settings: pprof.Settings{
423419
ListeningAddress: dev.DefaultPprofListeningAddress,
424420
BlockProfileRate: dev.DefaultPprofBlockRate,

dot/config_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ func TestConfig(t *testing.T) {
7474
WS: true,
7575
},
7676
Pprof: PprofConfig{
77-
Enabled: true,
7877
Settings: pprof.Settings{
7978
ListeningAddress: "localhost:6060",
8079
},
@@ -134,7 +133,6 @@ func TestConfig(t *testing.T) {
134133
WSUnsafeExternal: false,
135134
},
136135
Pprof: PprofConfig{
137-
Enabled: true,
138136
Settings: pprof.Settings{
139137
ListeningAddress: "localhost:6060",
140138
BlockProfileRate: 0,

0 commit comments

Comments
 (0)