Skip to content

fix: prevent the MIG reconfigure from hanging on systemd-less hosts#431

Closed
lexfrei wants to merge 2 commits into
NVIDIA:mainfrom
lexfrei:fix/systemd-dbus-hang-systemdless-hosts
Closed

fix: prevent the MIG reconfigure from hanging on systemd-less hosts#431
lexfrei wants to merge 2 commits into
NVIDIA:mainfrom
lexfrei:fix/systemd-dbus-hang-systemdless-hosts

Conversation

@lexfrei

@lexfrei lexfrei commented Jul 9, 2026

Copy link
Copy Markdown

What

On hosts without systemd — notably Talos Linux — k8s-mig-manager v0.14.0 hangs indefinitely when the nvidia.com/mig.config label changes, and never applies the new MIG geometry.

The Go-native reconfigure path opens a systemd D-Bus connection unconditionally when it is constructed. On a systemd-less host the system bus socket (/run/dbus/system_bus_socket) still exists — it is bind-mounted from the host — but nothing answers it, so the D-Bus auth handshake performs a blocking read that never returns. This happens even when WITH_SHUTDOWN_HOST_GPU_CLIENTS=false, i.e. when no host-systemd work is actually required.

Why it matters

Most of the reconfigure flow does not need systemd at all — the MIG geometry change is applied by the nvidia-mig-parted binary, not through systemd. systemd is only needed to persist the host mig-manager state file (a daemon-reload) and to stop/restart host GPU client services. A host that never touches those paths should never need a D-Bus connection.

Changes

  • Connect to systemd D-Bus lazily. Constructing the reconfigurer no longer dials D-Bus; the connection is established (and cached) the first time a code path genuinely needs systemd. On the common systemd-less path the socket is never dialed, so the reconfigure completes.
  • Bound the D-Bus connection setup with a timeout, as a backstop for the paths that do require systemd. If the socket is unresponsive, the connection attempt now fails fast with a clear error instead of blocking forever.

Testing

  • Unit tests added for the connection timeout (fast failure on an unresponsive socket, immediate failure on a missing socket) and for the lazy behavior (construction does not dial; a failed connection is not cached; cleanup is safe when systemd was never used).
  • go build ./..., go vet, gofmt, and golangci-lint pass on the changed packages.
  • End-to-end behavior on an actual systemd-less GPU host (Talos) cannot be exercised in CI; it requires the target hardware and OS.

Addresses #356

lexfrei added 2 commits July 9, 2026 17:02
Constructing the reconfigurer unconditionally opened a systemd D-Bus
connection, even for reconfigurations that never touch host systemd
(WITH_SHUTDOWN_HOST_GPU_CLIENTS unset and no host state file to persist).
On hosts without systemd - such as Talos Linux - the system bus socket
may exist (bind-mounted from the host) but nothing answers it, so the
D-Bus auth handshake blocks forever and the MIG geometry change is never
applied, with no error logged.

Establish the connection lazily instead: build it the first time a code
path genuinely needs systemd (persisting the host state file, or
stopping/restarting host GPU client services) and cache it. When none of
those run, the socket is never dialed, so the reconfigure - including the
MIG geometry change, which is applied by the nvidia-mig-parted binary and
not via systemd - completes on systemd-less hosts.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
go-systemd's connection setup performs a blocking read during the D-Bus
auth handshake. When the system bus socket exists but no daemon answers
it - as on a systemd-less host where /run/dbus/system_bus_socket is
bind-mounted from the host - that read never returns and the caller
hangs indefinitely.

Bound the connection setup with a timeout. The dial runs in a goroutine;
if it does not complete in time, the connection context is canceled,
go-systemd's watcher closes the socket to unblock the stuck read, and
NewManager returns a clear error instead of blocking forever. This is a
backstop for the paths that do require systemd, so a misconfigured or
absent host daemon surfaces an actionable error rather than a silent
hang.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
@copy-pr-bot

copy-pr-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@rajathagasthya

Copy link
Copy Markdown
Contributor

@lexfrei Thanks for your contribution! #382 is already trying to address this issue. I would encourage you to look at it and provide feedback since my recommendation there aligns with your approach in this PR.

@lexfrei

lexfrei commented Jul 16, 2026

Copy link
Copy Markdown
Author

Closing in favour of #382, which already carries both of my commits (1dd5ebc, b5a207a) with authorship intact — thanks @Arc676 for picking them up. That PR is the broader change, so there's no reason to keep this one open beside it.

@rajathagasthya thanks for the pointer. I've left one piece of review feedback over on #382 rather than here.

@lexfrei lexfrei closed this Jul 16, 2026
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