Skip to content

fix: preserve networks for non-stop kill signals - #5332

Closed
jonyhy96 wants to merge 1 commit into
containerd:mainfrom
jonyhy96:fix/kill-signal-network-cleanup
Closed

jonyhy96 wants to merge 1 commit into
containerd:mainfrom
jonyhy96:fix/kill-signal-network-cleanup

Conversation

@jonyhy96

@jonyhy96 jonyhy96 commented Nov 6, 2026 •

Copy link
Copy Markdown

Addresses #5327.

Change

kill now validates the task and sends the signal before network teardown. Only SIGKILL or the configured stop signal (SIGTERM by default) triggers network/healthcheck cleanup and the explicitly-stopped label. Unrelated signals such as nginx's SIGHUP and SIGUSR1 preserve these resources.

Cleanup tolerates container metadata disappearing after successful signal delivery, as can happen with run --rm. Other cleanup failures are still reported.

Verification

Passed locally:

  • 18 regression cases through the real Kill entry point and go-cni, using in-memory containerd services and a recording CNI plugin. These cover signals, custom stop signals, task/status/signal failures, paused tasks, cleanup errors, and auto-removal. The original network-gate cases fail on unmodified main.
  • go test -race ./pkg/cmd/container -count=1
  • go vet ./pkg/cmd/container ./cmd/nerdctl/container
  • make -B binaries, Windows package cross-compilation, and go mod tidy --diff
  • Repository-wide golangci-lint check of changes against the base commit: no new issues. The unfiltered affected-package check reports the same existing container_list.go formatting issue on main.

make test was also run. mountutil, portutil, and resolvconf fail due to missing host paths, iptables, and systemd's resolv.conf; the same failures were reproduced on unmodified main.

Added nginx published-port regression tests for SIGHUP and SIGUSR1. They compile, but execution is blocked by the absence of a running rootless containerd/RootlessKit environment. Real bridge/IPAM, forwarding, and systemd healthcheck behavior have not been verified locally. Runtime validation remains outstanding.

Scope

This follows the signal-based approach proposed in the issue, not an exit-status-based redesign. A process can still trap or ignore its configured stop signal; cleanup for that signal retains the existing limitation. A cleanup error can be returned after the signal has already taken effect. stop is unchanged.

AI assistance

The implementation and tests were substantially prepared with OpenAI Codex assistance. Local verification is listed above. The commit includes Assisted-by and DCO sign-off trailers.

Only clean up networking and healthcheck units for SIGKILL or the
container's configured stop signal, defaulting to SIGTERM. Other signals
may reload a service that still needs these resources and should not mark
it explicitly stopped.

Validate the task state and deliver the signal before tearing down the
network. Tolerate metadata already removed by the auto-remove path after
successful signal delivery.

Add recording-CNI regression tests for signal selection and failure paths,
and nginx published-port tests for SIGHUP and SIGUSR1.

Addresses containerd#5327

Assisted-by: OpenAI Codex
Signed-off-by: jony montana <hy352144278@gmail.com>
@jonyhy96
jonyhy96 marked this pull request as ready for review November 6, 2026 06:17
@AkihiroSuda

Copy link
Copy Markdown
Member

Real bridge/IPAM, forwarding, and systemd healthcheck behavior have not been verified locally. Runtime validation remains outstanding.

Why?

@jonyhy96 jonyhy96 closed this Nov 6, 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