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

Allow listening for go debug on all interfaces, not just localhost #1088

Merged
merged 2 commits into from
Oct 11, 2022
Merged

Allow listening for go debug on all interfaces, not just localhost #1088

merged 2 commits into from
Oct 11, 2022

Conversation

matthew1001
Copy link
Contributor

It's difficult using the go pprof debug utility when running in a container since the network interface it binds to defaults to localhost. This PR makes 2 changes:

  1. Make the interface address configurable
  2. Change the default interface to "*"

It still requires changes to the docker run command or docker compose overrides file to get a route through to the debug listener, but doesn't require you to rebuild firefly.

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like to avoid changing the default on this one if that's ok.

@@ -359,6 +361,7 @@ func setDefaults() {
viper.SetDefault(string(CacheOperationsTTL), "5m")
viper.SetDefault(string(HistogramsMaxChartRows), 100)
viper.SetDefault(string(DebugPort), -1)
viper.SetDefault(string(DebugAddress), "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggest the defaults stays as localhost, as exposing the debug server externally is not something I believe users would want to do outside of a dockerized/k8s environment where they have carefully considered the security implications.

A follow-up PR with firefly-cli to have a flag to allocate ports to the debug ports of various services (ethconnect/evmconnect/core etc.) might be valuable for dev environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I almost left the default as localhost - I'll revert it back. Happy to look at the firefly-cli/firefly-* PRs after this one.

@@ -209,6 +209,8 @@ var (
PluginsIdentityList = ffc("plugins.identity")
// DebugPort a HTTP port on which to enable the go debugger
DebugPort = ffc("debug.port")
// DebugAddress the HTTP interface for the debugger to listen on
DebugAddress = ffc("debug.address")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you'll need to add a documentation entry for this one too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, let me do that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's where to add the config doc:

ConfigDebugPort = ffc("config.debug.port", "An HTTP port on which to enable the go debugger", i18n.IntType)

Then make reference before you check in.

Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
… config test

Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
@matthew1001
Copy link
Contributor Author

Both comments should be addressed in the new commit. I notice that we have a config test so I updated that, although it feels like it's of limited use as it's just testing the defaults haven't been changed. Didn't seem to do any harm to add a couple of tests to it though.

@peterbroadhurst peterbroadhurst changed the title Listen for go debug on all interfaces, not just localhost Allow listening for go debug on all interfaces, not just localhost Oct 11, 2022
@@ -29,4 +29,6 @@ func TestInitConfigOK(t *testing.T) {
Reset()

assert.Equal(t, 25, config.GetInt(APIDefaultFilterLimit))
assert.Equal(t, "localhost", config.GetString(DebugAddress))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this test is for the config scaffolding code, rather than for individual fields - but all good 👍

@peterbroadhurst peterbroadhurst merged commit 2ba1adc into hyperledger:main Oct 11, 2022
@matthew1001 matthew1001 deleted the debug-port-all-interfaces branch October 12, 2022 07:45
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.

2 participants