Skip to content

fix: remove stale instance entry on recreate and guard stop against m…#468

Open
Syedowais312 wants to merge 1 commit into
microcks:masterfrom
Syedowais312:fix/stale-instance-cleanup
Open

fix: remove stale instance entry on recreate and guard stop against m…#468
Syedowais312 wants to merge 1 commit into
microcks:masterfrom
Syedowais312:fix/stale-instance-cleanup

Conversation

@Syedowais312

@Syedowais312 Syedowais312 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

When a container is removed externally (e.g. docker system prune) and
microcks start recreates it, the old instance entry was never removed from
config causing duplicate instance records to accumulate on every recreate.

Two root causes:

  1. RemoveInstance matched by Name (not unique) instead of ContainerID (unique)
  2. The autoRemove path in stop.go was passing instance.Name to RemoveInstance,
    silently failing to remove the correct entry
  3. start.go was clearing instance.ContainerID = "" instead of calling
    RemoveInstance to actually remove the stale record from config

Changes

  • cmd/start.go: call localConfig.RemoveInstance(instance.ContainerID) to
    remove the stale record before recreating, instead of just clearing the local variable
  • cmd/stop.go: pass instance.ContainerID to RemoveInstance in the autoRemove path
  • pkg/config/localconfig.go: RemoveInstance now matches by ContainerID instead of Name

Testing

Ran docker rm <container> while config shows status: Running, then
microcks start --name <instance> config shows a single clean entry with
the new container ID, no duplicates.

Realted: #456

…issing containers

Signed-off-by: syedowais312 <syedowais312sf@gmail.com>
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.

1 participant