[PR #70] [MERGED] fix(lxc): force-stop PVE CTs that ignore the shutdown signal #70

Closed
opened 2026-10-15 12:51:46 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/70
Author: @JBailes
Created: 6/7/2026
Status: ✅ Merged
Merged: 6/7/2026
Merged by: @JBailes

Base: main ← Head: fix/pve-graceful-stop


📝 Commits (1)

  • b54364e fix(lxc): force-stop PVE CTs that ignore the shutdown signal

📊 Changes

1 file changed (+18 additions, -6 deletions)

View changed files

📝 internal/lxc/manager.go (+18 -6)

📄 Description

Fixes the "container cannot shut down gracefully" report in #53.

docker stop on a Proxmox CT ran pct shutdown <vmid> --timeout N. pct shutdown defaults to forceStop=0, which (per PVE::LXC::vm_stop) runs lxc-stop --nokill — it sends the shutdown signal, waits, and then gives up without killing. A container whose init ignores that signal (Wolf does) is never stopped: the grace period expires, lxc-stop fails with exit code 1, but the surrounding task can still finish TASK OK, and the CT keeps running. The daemon only ran its pct stop fallback on a non-zero exit code, so it returned success while the CT was still up — leaving the user to pct enter and kill 1 by hand.

Two changes:

  • Pass --forceStop 1 so PVE escalates to a hard stop once the timeout elapses (vm_stop then runs lxc-stop without --nokill, i.e. kill-after-timeout). This matches docker stop semantics: grace period, then SIGKILL.
  • Decide the fallback on the live pct status, not the exit code, since the shutdown task can report success while the CT is still running. Anything left gets pct stop.

Reported on PVE 9.2; forceStop default confirmed 0 in PVE/API2/LXC/Status.pm and the --nokill path in PVE::LXC::vm_stop. Build and unit tests pass.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/70 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 6/7/2026 **Status:** ✅ Merged **Merged:** 6/7/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `main` ← **Head:** `fix/pve-graceful-stop` --- ### 📝 Commits (1) - [`b54364e`](https://github.com/games-on-whales/LXC2Docker/commit/b54364eee15fb44cb57d7fa6dd218b0107c6d1fc) fix(lxc): force-stop PVE CTs that ignore the shutdown signal ### 📊 Changes **1 file changed** (+18 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `internal/lxc/manager.go` (+18 -6) </details> ### 📄 Description Fixes the "container cannot shut down gracefully" report in #53. `docker stop` on a Proxmox CT ran `pct shutdown <vmid> --timeout N`. `pct shutdown` defaults to `forceStop=0`, which (per `PVE::LXC::vm_stop`) runs `lxc-stop --nokill` — it sends the shutdown signal, waits, and then gives up *without* killing. A container whose init ignores that signal (Wolf does) is never stopped: the grace period expires, `lxc-stop` fails with `exit code 1`, but the surrounding task can still finish `TASK OK`, and the CT keeps running. The daemon only ran its `pct stop` fallback on a non-zero exit code, so it returned success while the CT was still up — leaving the user to `pct enter` and `kill 1` by hand. Two changes: - Pass `--forceStop 1` so PVE escalates to a hard stop once the timeout elapses (`vm_stop` then runs `lxc-stop` *without* `--nokill`, i.e. kill-after-timeout). This matches `docker stop` semantics: grace period, then SIGKILL. - Decide the fallback on the live `pct status`, not the exit code, since the shutdown task can report success while the CT is still running. Anything left gets `pct stop`. Reported on PVE 9.2; `forceStop` default confirmed `0` in `PVE/API2/LXC/Status.pm` and the `--nokill` path in `PVE::LXC::vm_stop`. Build and unit tests pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:51:46 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#70
No description provided.