Skip to content

fix: disable probe and metrics endpoints by default#10

Merged
kvaps merged 1 commit intomainfrom
fix/disable-default-bind-addresses
Apr 27, 2026
Merged

fix: disable probe and metrics endpoints by default#10
kvaps merged 1 commit intomainfrom
fix/disable-default-bind-addresses

Conversation

@kvaps
Copy link
Copy Markdown
Member

@kvaps kvaps commented Apr 21, 2026

Summary

Change the defaults for --health-probe-bind-address and --metrics-bind-address from ":0" (bind to a random free port) to "0" (disabled), which is the controller-runtime convention for turning off the server.

Why

netstat on a node running cozy-proxy showed two unexpected high-port listeners:

tcp6  0  0 :::40267  :::*  LISTEN  109979/cozy-proxy
tcp6  0  0 :::33869  :::*  LISTEN  109979/cozy-proxy

Because the chart runs cozy-proxy with hostNetwork: true, those ports were exposed directly on the host. Users who want health probes or metrics can still opt in by passing an explicit bind address via flag.

Verified against controller-runtime v0.20.1:

  • Metrics (pkg/metrics/server/server.go): BindAddress == "0" skips server creation entirely.
  • Probe (pkg/manager/manager.go): addr == "" || addr == "0" returns a nil listener, so no probe server is started.
  • The previous ":0" value instead fell through to net.Listen("tcp", ":0"), which is exactly what produced the random high ports.

Test plan

  • Build and deploy; verify netstat -ltnp on the node shows no cozy-proxy listeners
  • Pass --health-probe-bind-address=:8081 and confirm the probe endpoint comes up on that port
  • Pass --metrics-bind-address=:8080 and confirm metrics are served

Fixes #5

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@kvaps has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 40 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d07a0eb4-0f88-4051-b7bb-d0b4b4dc8096

📥 Commits

Reviewing files that changed from the base of the PR and between e54181f and a39770a.

📒 Files selected for processing (1)
  • main.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/disable-default-bind-addresses

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the default bind addresses for the health probe and metrics endpoints to "0", allowing them to be disabled. The review feedback suggests improving the help text by providing example address formats and ensuring consistent pluralization for the metrics endpoint description.

Comment thread main.go
var metricsAddr string
flag.StringVar(&probeAddr, "health-probe-bind-address", ":0", "The address the probe endpoint binds to.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":0", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", "0", "The address the probe endpoint binds to. Set to \"0\" to disable.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Consider adding an example of the expected address format (e.g., :8081) to the help text. Since the default is now the special value "0", providing an example helps users understand that they should provide a :port string to enable the endpoint.

Suggested change
flag.StringVar(&probeAddr, "health-probe-bind-address", "0", "The address the probe endpoint binds to. Set to \"0\" to disable.")
flag.StringVar(&probeAddr, "health-probe-bind-address", "0", "The address the probe endpoint binds to (e.g., :8081). Set to \"0\" to disable.")

Comment thread main.go
flag.StringVar(&probeAddr, "health-probe-bind-address", ":0", "The address the probe endpoint binds to.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":0", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", "0", "The address the probe endpoint binds to. Set to \"0\" to disable.")
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metric endpoint binds to. Set to \"0\" to disable.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Consider adding an example of the expected address format (e.g., :8080) and using the plural 'metrics' in the help text to maintain consistency with the flag name (--metrics-bind-address).

Suggested change
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metric endpoint binds to. Set to \"0\" to disable.")
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to (e.g., :8080). Set to \"0\" to disable.")

The default values for --health-probe-bind-address and --metrics-bind-address
were ":0", which in controller-runtime means "bind to a random free port"
rather than "disabled". Because the chart runs cozy-proxy with hostNetwork=true,
these showed up as two unexpected high-port listeners on the host. Switch the
defaults to "0", the controller-runtime convention for disabling the server.
Users who want health probes or metrics can pass an explicit bind address.

Refs: #5

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps kvaps force-pushed the fix/disable-default-bind-addresses branch from 3050c29 to a39770a Compare April 27, 2026 18:09
@kvaps kvaps marked this pull request as ready for review April 27, 2026 18:15
@kvaps kvaps merged commit 1b459f6 into main Apr 27, 2026
2 checks passed
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.

Cozy proxy listens on a couple of high ports with no apparent need

1 participant