inspect by kind, not the ambiguous bare form — a same-named network stops a container from ever being found
docker inspect <name> resolves across every object kind, not just
containers. A module regularly names a network the same as the
container that joins it (keycloak does this today, ordinarily) — so
when the container does not exist yet but the same-named network
already does, the bare form answers with the network's JSON instead
of reporting the container absent, and the template these callers use
(.State.Running) fails to execute against it entirely.
Live on novox tonight: minio's LB container, named the same as its
network ("minio"), could never be created — every apply crashed on
"the container runtime could not say whether minio is here", stuck
since first push, because the check itself never got a clean answer.
Fixed at every call site asking a container's state by name
(containerState, inspectFound, NamesFree, raiseGiteaServer,
containerRunning) by scoping to `docker container inspect`, matching
the type-scoped form this codebase already uses correctly for
networks, volumes and images elsewhere. Also scoped the one image
inspect that was still bare (publish.go), for the same reason.
mesh-host runs as a host-level service (nox-mesh-host.service), not a
Docker module — merging this does not redeploy it. The live novox
failure persists until the service itself is rebuilt and updated.
This commit is contained in:
+10
-1
@@ -424,12 +424,21 @@ type foundContainer struct {
|
||||
|
||||
// inspectFound reads a container by name the way a hold needs it: its id, whether it runs, and
|
||||
// whether a host made it.
|
||||
//
|
||||
// **`container inspect`, not the bare form.** A name is not unique across object kinds — a
|
||||
// module regularly names a network the same as the container that joins it (`keycloak` names
|
||||
// both, and it is ordinary). The bare form resolves across every kind and returns whichever it
|
||||
// finds, so a container that does not exist yet but a same-named network does answers with the
|
||||
// network's JSON — no `.State` field at all — and the template below fails to execute rather
|
||||
// than failing to find anything. That reads as "the runtime could not say", which this function's
|
||||
// caller correctly refuses to build on (novox/hq ADR 0100) — but there was something to say, a
|
||||
// question of kind, not of ambiguity that should have stopped anything.
|
||||
func inspectFound(ctx context.Context, name string, run Runner) (foundContainer, bool, error) {
|
||||
cri, err := containerRuntime(ctx, run)
|
||||
if err != nil {
|
||||
return foundContainer{}, false, fmt.Errorf("%w, so nothing can be said about %q", err, name)
|
||||
}
|
||||
out, err := run(ctx, cri, "inspect", "--format",
|
||||
out, err := run(ctx, cri, "container", "inspect", "--format",
|
||||
"{{.Id}}\t{{.State.Running}}\t{{index .Config.Labels \""+specLabel+"\"}}", name)
|
||||
if err != nil {
|
||||
if absent(err) {
|
||||
|
||||
Reference in New Issue
Block a user