Skip to content

fix: replace netstat with /proc/net/tcp for port availability checks#2890

Closed
barnabasbusa wants to merge 1 commit intomainfrom
bbusa/netstat-fix
Closed

fix: replace netstat with /proc/net/tcp for port availability checks#2890
barnabasbusa wants to merge 1 commit intomainfrom
bbusa/netstat-fix

Conversation

@barnabasbusa
Copy link
Collaborator

The fluent-bit debug container (distroless:debug) does not include netstat, causing the logs collector port check to always fail on k8s. Use /proc/net/tcp which works on any Linux container without tool deps.

When it broke: Commit be932f7 ("impl k8s fluentbit collector availability check", Feb 18, 2025), merged via PR #2653 at commit 05e3813 ("feat:
fluent bit logs collector in k8s backend", Feb 22, 2025). This has been broken since day one of the k8s logs collector feature - it was never
working.

Root cause: The port availability check runs netstat -anp tcp | grep LISTEN | grep 9713 via kubectl exec inside the fluent/fluent-bit:4.0.0-debug
container. That image is based on Google's distroless:debug, which has a minimal busybox that does not include netstat. The engine and API
containers are Alpine-based and have busybox netstat, so their checks work fine.

The fix: Replaced the netstat command with a /proc/net/tcp check in both the Kubernetes and Docker backends:
grep -i ':25F1 ' /proc/net/tcp /proc/net/tcp6 2>/dev/null | grep -qi ' 0A '

  • Reads the Linux proc filesystem directly (always available, zero tool dependency)
  • 25F1 is the hex representation of the port number
  • 0A is the TCP LISTEN state in /proc/net/tcp

The fluent-bit debug container (distroless:debug) does not include
netstat, causing the logs collector port check to always fail on k8s.
Use /proc/net/tcp which works on any Linux container without tool deps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@barnabasbusa
Copy link
Collaborator Author

Closing as it is now part of #2891

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.

1 participant

Comments