Skip to content

hot restart: inherit listen sockets before entering the network namespace - #47492

Merged
mattklein123 merged 2 commits into
envoyproxy:mainfrom
bpalermo:hot-restart-netns-inherit
Sep 30, 2026
Merged

mattklein123 merged 2 commits into
envoyproxy:mainfrom
bpalermo:hot-restart-netns-inherit

Conversation

@bpalermo

Copy link
Copy Markdown
Contributor

Commit Message

hot restart: inherit listen sockets before entering the network namespace

Additional Description

Follow-up to #43653. A listener whose address sets network_namespace_filepath is created by
running the whole socket creation, including the request to the hot restart parent, inside the
target namespace. If the namespace path can no longer be opened (typical when a CNI plugin removes
the pod namespace pin after the socket was bound) the namespace switch fails before the parent is
ever asked, so the successor rejects the listener (lds.update_rejected,
listener_create_failure) and the port goes dead once the parent finishes draining, even though
the parent still holds a valid socket bound in that namespace. An in-place LDS update of the same
listener masks this, since it clones the socket factory without reopening the namespace; the loss
only shows up at the next hot restart.

The successor now asks the parent for the socket before entering the namespace: an inherited
socket is already bound in the right namespace and needs no setns to be duplicated. Entering the
namespace to bind a fresh socket only happens when the parent has none, so creating a new listener
in a missing namespace still fails cleanly.

Risk Level

Low. Only affects listeners with network_namespace_filepath, and only reorders the existing
parent-socket request ahead of the namespace switch.

Testing

New unit tests in listener_manager_impl_test: the parent hands over a socket and the namespace
file is never opened; without a parent socket a missing namespace path still fails the listener.
Reproduced the loss manually with file-based LDS, a bind-mounted namespace file, and
--restart-epoch 1 then 2 with the namespace removed in between.

Docs Changes

N/A

Release Notes

Added a bug-fix changelog fragment.

Platform Specific Features

Linux only (network namespaces).

…pace

A listener whose address carries network_namespace_filepath is created by running the whole
socket creation, including the request to the hot restart parent, inside the target namespace.
When the namespace path can no longer be opened (e.g. it was removed after the parent bound the
socket) the namespace switch fails before the parent is ever asked, so the successor rejects the
listener and the port dies once the parent finishes draining, even though the parent still holds
a valid socket bound in that namespace.

Ask the parent for the socket before entering the namespace: an inherited socket is already bound
in the right namespace and needs no setns to be duplicated. Only fall back to entering the
namespace to create a fresh socket when the parent has none, so creating a new listener in a
missing namespace still fails cleanly.

Signed-off-by: Bruno Palermo <[email protected]>
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