Skip to content

Conversation

@coro
Copy link
Contributor

@coro coro commented Jun 10, 2022

Summary Of Changes

Allow users to opt-in to exposing pprof debugging endpoints on the operator's metrics port.
Users may add the ENABLE_DEBUG_PPROF env variable to the operator Pod to enable the pprof endpoints.
This is an opt-in pattern, as memory/CPU profiling can have a non-insignificant impact on runtime perf,
and could be a denial of service vector. These endpoints should not be enabled in production.

With this feature enabled, users can access the pprof output at <OPERATOR_URL>:<METRICS_PORT>/debug/pprof. For example, after
port-forwarding to the operator Pod:

go tool pprof -inuse_space -web http://localhost:9782/debug/pprof/heap

Note to reviewers: remember to look at the commits in this PR and consider if they can be squashed

Additional Context

For more info on pprof: https://github.com/google/pprof/blob/main/doc/README.md
For documentation on the Go library this imports: https://pkg.go.dev/net/http/pprof

Note that this PR adds a unit test which necessitates binding the manager binary to a local port. This will cause firewall warnings on MacOS.

Local Testing

Please ensure you run the unit, integration and system tests before approving the PR.

To run the unit and integration tests:

$ make unit-tests integration-tests

You will need to target a k8s cluster and have the operator deployed for running the system tests.

For example, for a Kubernetes context named dev-bunny:

$ kubectx dev-bunny
$ make destroy deploy-dev
# wait for operator to be deployed
$ make system-tests

Allow users to opt-in to exposing pprof debugging endpoints on the operator's metrics port.
Users may add the `ENABLE_DEBUG_PPROF` env variable to the operator Pod to enable the pprof endpoints.
This is an opt-in pattern, as memory/CPU profiling can have a non-insignificant impact on runtime perf,
and could be a denial of service vector. These endpoints should not be enabled in production.

With this feature enabled, users can access the pprof output at `<OPERATOR_URL>:<METRICS_PORT>/debug/pprof`. For example, after
port-forwarding to the operator Pod:
```
go tool pprof -inuse_space -web http://localhost:9782/debug/pprof/heap
```
@Zerpet Zerpet self-requested a review June 10, 2022 14:53
@Zerpet
Copy link
Member

Zerpet commented Jun 13, 2022

Don't forget to document this new feature in RabbitMQ docs!

@coro
Copy link
Contributor Author

coro commented Jun 13, 2022

Doc PR: rabbitmq/rabbitmq-website#1420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants