diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index 9ad87282..548ddff4 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -363,10 +363,18 @@ func TestAWantAndItsCompositionApplyTheModuleAndTheHaveNamesBoth(t *testing.T) { } } // A container's digest is the one after its image's @. - container := json.RawMessage(`{"id":"web.c","type":"container","name":"web-c","image":"store/web@` + d3 + `","module":"web"}`) + container := json.RawMessage(`{"id":"web.c","type":"container","name":"web-c","image":"store/web@` + d3 + `","image-seat":"mesh-artifact-store","image-holder":"n1","module":"web"}`) if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container}); got != "" { t.Fatalf("a container whose digest is in the parts differs: %q", got) } + // A-454: an image the manifest pins from outside, by its digest, is no part of the want's parts, and a mesh-built one still is. + upstream := json.RawMessage(`{"id":"web.u","type":"container","name":"web-u","image":"registry@` + d2 + `","module":"web"}`) + if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, upstream}); got != "" { + t.Fatalf("an upstream image pinned by its digest is a part: %q", got) + } + if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{upstream}); !strings.Contains(got, "in the want's parts and not fetched: "+d3) || strings.Contains(got, d2) { + t.Fatalf("with only an upstream image the mesh-built one is not missing, or the upstream one is named: %q", got) + } // A-432: a runtime of its own runs the tool runner's program, which the module's parts do not name. ownRuntime := json.RawMessage(`{"id":"web.own-runtime","type":"process","name":"web-runtime","source":"store/node-tools","digest":"` + d1 + `","run":["./node-tools"],"module":"web"}`) if got := partsDifference(map[string]string{"web:c": d3}, []json.RawMessage{container, ownRuntime}); got != "" { diff --git a/internal/agent/parts.go b/internal/agent/parts.go index 1da96058..f5f0482c 100644 --- a/internal/agent/parts.go +++ b/internal/agent/parts.go @@ -69,6 +69,11 @@ func partsDifference(parts map[string]string, resources []json.RawMessage) strin fetched[res.Digest] = true } case *declaration.Container: + // Only an image the mesh built is a part: the composition names the seat it came through (the artifact store or a + // registry seat) beside it. An image the manifest pins from outside, by its digest, is no part (design 47 G A-454). + if res.ImageSeat == "" { + continue + } if strings.HasPrefix(res.Image, "sha256:") { fetched[res.Image] = true } else if _, digest, ok := strings.Cut(res.Image, "@"); ok {