Skip to content

[confignet] Add Unix domain socket lifecycle management to AddrConfig #15189

Description

@jakubsomonday

Component(s)

config/confignet

Is your feature request related to a problem? Please describe.

When using Unix domain sockets with the Collector (via confignet.AddrConfig.Listen()), operators face three recurring pain points:

  1. Stale socket files block restarts. If a Collector process is killed ungracefully (OOM, SIGKILL, node eviction), the socket file remains on the filesystem. The next process fails to bind with "address already in use." This is especially common in Kubernetes DaemonSet deployments with host-mounted volumes (see #14274, which was filed against contrib but describes the same root cause).
  2. Socket file permissions are not configurable. Socket files inherit the process umask, which is often too restrictive for multi-service setups. Operators must use external tooling (systemd ExecStartPost, init scripts) to chmod the socket after the Collector starts.
  3. Socket files are not cleaned up on close. When Listen() returns a net.Listener for a Unix socket, calling Close() does not remove the socket file, leaving stale files behind for the next restart.

Describe the solution you'd like

Add two new fields to confignet.AddrConfig and enhance Listen():

  • socket_permissions (os.FileMode) — File mode applied to the socket file after binding. Only valid for Unix transports. When zero (default), inherits the process umask.
  • socket_clean_on_start (bool) — Remove a pre-existing socket file before binding. Only applies to filesystem-based Unix sockets (not abstract sockets with @ prefix). Default: false.

Listen() would also wrap the returned listener so that Close() removes the socket file automatically.

Describe alternatives you've considered

  • External wrapper scripts (e.g., ExecStartPre=rm -f /path/to/socket) — Works but pushes responsibility outside the Collector and is error-prone.
  • Handling this in confighttp/configgrpc — These layers now delegate to confignet.AddrConfig.Listen() (since #14248), so solving it in confignet benefits all consumers automatically.

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions