fix: remove stale instance entry on recreate and guard stop against missing containers#468
fix: remove stale instance entry on recreate and guard stop against missing containers#468Syedowais312 wants to merge 3 commits into
Conversation
…issing containers Signed-off-by: syedowais312 <syedowais312sf@gmail.com>
|
Matching by |
Signed-off-by: syedowais312 <syedowais312sf@gmail.com>
f3b0073 to
700e6db
Compare
i have added appropriate test cases in pkg/config/localconfig_test.go |
|
Thanks for adding tests after the earlier review feedback. One thing I want to call out: the PR title mentions “guard stop against missing containers”, but I don’t see an actual missing-container guard added in
|
a859375 to
700e6db
Compare
Signed-off-by: syedowais312 <syedowais312sf@gmail.com>
a5e72de to
cd4b467
Compare
sorry i missed it earlier. |
Problem
When a container is removed externally (e.g.
docker system prune) andmicrocks startrecreates it, the old instance entry was never removed fromconfig causing duplicate instance records to accumulate on every recreate.
Two root causes:
RemoveInstancematched byName(not unique) instead ofContainerID(unique)autoRemovepath instop.gowas passinginstance.NametoRemoveInstance,silently failing to remove the correct entry
start.gowas clearinginstance.ContainerID = ""instead of callingRemoveInstanceto actually remove the stale record from configChanges
cmd/start.go: calllocalConfig.RemoveInstance(instance.ContainerID)toremove the stale record before recreating, instead of just clearing the local variable
cmd/stop.go: passinstance.ContainerIDtoRemoveInstancein theautoRemovepathpkg/config/localconfig.go:RemoveInstancenow matches byContainerIDinstead ofNameTesting
Ran
docker rm <container>while config showsstatus: Running, thenmicrocks start --name <instance>config shows a single clean entry withthe new container ID, no duplicates.
Realted: #456
Fix: #483