Skip to content

Commit 877e805

Browse files
armruleonardoce
authored andcommitted
feat: migrato to string
Signed-off-by: Armando Ruocco <[email protected]>
1 parent 1003a3e commit 877e805

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
@@ -52,9 +52,10 @@ func NewCmd() *cobra.Command {
5252
},
5353
}
5454

55-
cmd.Flags().Bool("pprof-server",
56-
false,
57-
"If true it will start a pprof debug http server on localhost:6061. Defaults to false.",
55+
cmd.Flags().String("pprof-server",
56+
"",
57+
"The address where pprof server should be exposed, for example: 0.0.0.0:6061. "+
58+
"Empty string means disabled. Disabled by default",
5859
)
5960
_ = viper.BindPFlag("pprof-server", cmd.Flags().Lookup("pprof-server"))
6061

internal/cnpgi/instance/manager.go

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

5454
controllerOptions := ctrl.Options{
55-
PprofBindAddress: getPprofServerAddress(),
55+
PprofBindAddress: viper.GetString("pprof-server"),
5656
Scheme: scheme,
5757
Client: client.Options{
5858
// Important: the caching options below are used by
@@ -149,11 +149,3 @@ func generateScheme(ctx context.Context) *runtime.Scheme {
149149

150150
return result
151151
}
152-
153-
func getPprofServerAddress() string {
154-
if viper.GetBool("pprof-server") {
155-
return "0.0.0.0:6061"
156-
}
157-
158-
return ""
159-
}

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)