mirror of
https://github.com/games-on-whales/LXC2Docker.git
synced 2026-10-15 12:52:04 +00:00
[PR #151] [MERGED] Fix stop intent races and isolate shared records #151
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/LXC2Docker#151
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/LXC2Docker/pull/151
Author: @JBailes
Created: 8/9/2026
Status: ✅ Merged
Merged: 8/9/2026
Merged by: @JBailes
Base:
main← Head:fix/stop-intent-before-stop📝 Commits (3)
6abbc2capi: record stop intent before stopping, not after6b5cb39store: isolate container records across goroutines643be48api: isolate exec records across goroutines📊 Changes
11 files changed (+905 additions, -176 deletions)
View changed files
📝
internal/api/containers.go(+118 -28)📝
internal/api/exec.go(+17 -3)📝
internal/api/exec_claim_test.go(+50 -0)📝
internal/api/portainer_ops.go(+7 -6)➕
internal/api/stop_intent_test.go(+210 -0)📝
internal/api/system.go(+6 -2)📝
internal/lxc/manager.go(+141 -115)📝
internal/lxc/pve_tarball.go(+14 -15)➕
internal/lxc/restart_policy_race_test.go(+72 -0)📝
internal/store/store.go(+124 -7)📝
internal/store/store_test.go(+146 -0)📄 Description
Summary
Root cause
GetContainer, ListContainers, and the exec store returned live pointers after releasing their mutexes. API request goroutines and background watchers then read and mutated those records concurrently.
For containers using unless-stopped, stop intent was also recorded only after the workload exited. A restart-watcher tick in that shutdown window could observe an exited container without user intent and immediately start it again. The already-stopped path returned 304 without recording intent at all.
Impact
Explicitly stopping Wolf and other unless-stopped containers now keeps them stopped. Stop, kill, restart-watcher, and removal operations establish a deterministic final state, while lifecycle operations for unrelated containers remain concurrent.
Validation
TestCheckCreateDiskPressure is excluded because it depends on host free space and fails on this development machine before and after the change. No tests were run against a live Proxmox VE host.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.