Skip to content

Commit 585814e

Browse files
armrumnencia
authored andcommitted
feat: migrato to string
Signed-off-by: Armando Ruocco <[email protected]>
1 parent 3ace7f2 commit 585814e

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

internal/cmd/instance/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ func NewCmd() *cobra.Command {
3333
},
3434
}
3535

36-
cmd.Flags().Bool("pprof-server",
37-
false,
38-
"If true it will start a pprof debug http server on localhost:6061. Defaults to false.",
36+
cmd.Flags().String("pprof-server",
37+
"",
38+
"The address where pprof server should be exposed, for example: 0.0.0.0:6061. "+
39+
"Empty string means disabled. Disabled by default",
3940
)
4041
_ = viper.BindPFlag("pprof-server", cmd.Flags().Lookup("pprof-server"))
4142

internal/cnpgi/instance/manager.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func Start(ctx context.Context) error {
3333
namespace := viper.GetString("namespace")
3434

3535
controllerOptions := ctrl.Options{
36-
PprofBindAddress: getPprofServerAddress(),
36+
PprofBindAddress: viper.GetString("pprof-server"),
3737
Scheme: scheme,
3838
Client: client.Options{
3939
// Important: the caching options below are used by
@@ -130,11 +130,3 @@ func generateScheme(ctx context.Context) *runtime.Scheme {
130130

131131
return result
132132
}
133-
134-
func getPprofServerAddress() string {
135-
if viper.GetBool("pprof-server") {
136-
return "0.0.0.0:6061"
137-
}
138-
139-
return ""
140-
}

web/docs/misc.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ For a complete list of supported options, refer to the
7777
7878
## Enable the pprof debug server for the sidecar
7979
80-
You can enable the instance sidecar's pprof debug HTTP server by adding the `--pprof-server` flag to the container's
81-
arguments via `.spec.instanceSidecarConfiguration.additionalContainerArgs` in the `ObjectStore` resource.
80+
You can enable the instance sidecar's pprof debug HTTP server by adding the `--pprof-server=<address>` flag to the container's
81+
arguments via `.spec.instanceSidecarConfiguration.additionalContainerArgs`.
8282

83-
This starts a pprof server on port 6061 inside the Pod.
83+
Pass a bind address in the form `<host>:<port>` (for example, `0.0.0.0:6061`).
84+
An empty value disables the server (disabled by default).
8485

8586
### Example
8687

@@ -92,5 +93,5 @@ metadata:
9293
spec:
9394
instanceSidecarConfiguration:
9495
additionalContainerArgs:
95-
- "--pprof-server"
96+
- "--pprof-server=0.0.0.0:6061"
9697
```

0 commit comments

Comments
 (0)