A module in InOwn wanted at a build of the new form has its build taken in: the reader and the composition fold by one rule (issue 1585)
frombus skipped reading the build of every module in Scope.InOwn, while compose.compositions folds such a module only at no src2: fingerprint: a want at src2: (nats on novox, its have waiting for a yes) composed it from the indexer's unresolved manifest and built() refused it, "no build has published" its server artifact. compose.Folds is now the one rule; frombus takes the build in, or keeps the module at its wanted build, exactly where it says the module is not folded. A row composes spiegel, in InOwn and wanted at src2:, from its build's upstream image; it read the indexer's manifest before. Claude-Session: https://claude.ai/code/session_01JG73KG7AfSdh6FP8VrBqCn
This commit is contained in:
@@ -63,6 +63,15 @@ func CompositionsIn(in Input, node string, fps map[string]string, mode Mode) (ou
|
|||||||
return compositions(in, node, fps, mode, false)
|
return compositions(in, node, fps, mode, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Folds says whether a module the node runs inside its own composition (inOwn, Node.InOwn) is folded there at the
|
||||||
|
// fingerprint fp it is composed at: only at no fingerprint of the new form. At one (src2:) it has a composition of its
|
||||||
|
// own, composed from its build, so every reader of a build (frombus) takes the build in exactly where this says it is
|
||||||
|
// not folded (issue 1585: nats on novox, folded by the reader and composed at src2: here, refused for its server
|
||||||
|
// artifact no build had published).
|
||||||
|
func Folds(inOwn bool, fp string) bool {
|
||||||
|
return inOwn && !strings.HasPrefix(fp, delivery.SourcePrefix2)
|
||||||
|
}
|
||||||
|
|
||||||
func compositions(in Input, node string, fps map[string]string, mode Mode, applied bool) (out map[string]delivery.Composed, skipped, stood []string, err error) {
|
func compositions(in Input, node string, fps map[string]string, mode Mode, applied bool) (out map[string]delivery.Composed, skipped, stood []string, err error) {
|
||||||
reading := in
|
reading := in
|
||||||
reading.Nodes = append([]Node(nil), in.Nodes...)
|
reading.Nodes = append([]Node(nil), in.Nodes...)
|
||||||
@@ -84,7 +93,7 @@ func compositions(in Input, node string, fps map[string]string, mode Mode, appli
|
|||||||
// The private network's module is built by nobody: no fingerprint of the new form ever names it.
|
// The private network's module is built by nobody: no fingerprint of the new form ever names it.
|
||||||
inOwn[overlay.Name] = true
|
inOwn[overlay.Name] = true
|
||||||
folds := func(module string) bool {
|
folds := func(module string) bool {
|
||||||
return module != "" && inOwn[module] && !strings.HasPrefix(fps[module], delivery.SourcePrefix2)
|
return module != "" && Folds(inOwn[module], fps[module])
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
return nil, nil, nil, fmt.Errorf("compose: the mesh has no node %q", node)
|
return nil, nil, nil, fmt.Errorf("compose: the mesh has no node %q", node)
|
||||||
|
|||||||
@@ -191,6 +191,28 @@ func answerNamesEveryRefusalAndLeavesAnOldBuildToTheNode(t *testing.T) {
|
|||||||
!strings.Contains(held["spiegel"], "spiegel has not been built for this mesh") {
|
!strings.Contains(held["spiegel"], "spiegel has not been built for this mesh") {
|
||||||
t.Errorf("composed spiegel without what runs: %v %v, want spiegel held alone", err, held)
|
t.Errorf("composed spiegel without what runs: %v %v, want spiegel held alone", err, held)
|
||||||
}
|
}
|
||||||
|
// Issue 1585 (nats on novox, met twice): wanted at a build of the new form, a module in InOwn is no longer folded
|
||||||
|
// (compose.Folds), so its build is taken in and it composes with its image, never from the indexer's manifest as
|
||||||
|
// "not built for this mesh".
|
||||||
|
{
|
||||||
|
bb := mk("lemurs", overlay.Name, "spiegel")
|
||||||
|
bp := bb.placements["n1"]
|
||||||
|
bp.Decided.Endpoint = "n1.example:51820"
|
||||||
|
bb.placements["n1"] = bp
|
||||||
|
sp := bb.modules["spiegel"]
|
||||||
|
sp.FP2 = fp("3")
|
||||||
|
bb.modules["spiegel"] = sp
|
||||||
|
image := "registry.example:5100/spiegel/site@sha256:" + strings.Repeat("7", 64)
|
||||||
|
bb.builds["spiegel "+sp.FP2] = &delivery.BuilderBuild{State: delivery.BuildDone, Manifest: sp.Manifest,
|
||||||
|
Artifacts: []delivery.BuiltArtifact{{Name: "site", Kind: "upstream", Reference: image, Digest: "sha256:" + strings.Repeat("7", 64)}}}
|
||||||
|
read, err := ComposingInput(ctx, bb, Mesh{}, Scope{Node: "n1", InOwn: []string{"spiegel"}},
|
||||||
|
map[string]string{"lemurs": fp("e"), "spiegel": sp.FP2})
|
||||||
|
raw, _ := json.Marshal(read.Catalogue["spiegel"])
|
||||||
|
if err != nil || read.ComposedHow.Held["spiegel"] != "" || !strings.Contains(string(raw), strings.Repeat("7", 64)) {
|
||||||
|
t.Errorf("spiegel in InOwn wanted at %s: %v, held %v, read as %s; want its build's image", sp.FP2, err,
|
||||||
|
read.ComposedHow, raw)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// (C) Issue 1126, C5: what the others read of a module carried as it runs is what runs, never its stub's: the filter
|
// (C) Issue 1126, C5: what the others read of a module carried as it runs is what runs, never its stub's: the filter
|
||||||
// opens the machine port its running container publishes (de-spiegel's 20005 on novox, not its software's 8080; a
|
// opens the machine port its running container publishes (de-spiegel's 20005 on novox, not its software's 8080; a
|
||||||
|
|||||||
@@ -876,7 +876,7 @@ func fromBuilds(ctx context.Context, r Reader, build func(ctx context.Context, m
|
|||||||
keptAt := maps.Clone(s.KeptAt)
|
keptAt := maps.Clone(s.KeptAt)
|
||||||
for _, pm := range p.Modules {
|
for _, pm := range p.Modules {
|
||||||
if m, ok := modules[pm.Module]; ok && m.FP2 != "" && wanted[pm.Module] != "" && wanted[pm.Module] != m.FP2 &&
|
if m, ok := modules[pm.Module]; ok && m.FP2 != "" && wanted[pm.Module] != "" && wanted[pm.Module] != m.FP2 &&
|
||||||
keptAt[pm.Module] == "" && !slices.Contains(s.InOwn, pm.Module) {
|
keptAt[pm.Module] == "" && !compose.Folds(slices.Contains(s.InOwn, pm.Module), wanted[pm.Module]) {
|
||||||
if keptAt == nil {
|
if keptAt == nil {
|
||||||
keptAt = map[string]string{}
|
keptAt = map[string]string{}
|
||||||
}
|
}
|
||||||
@@ -891,9 +891,10 @@ func fromBuilds(ctx context.Context, r Reader, build func(ctx context.Context, m
|
|||||||
}
|
}
|
||||||
for _, pm := range p.Modules {
|
for _, pm := range p.Modules {
|
||||||
m, ok := modules[pm.Module]
|
m, ok := modules[pm.Module]
|
||||||
if !ok || m.FP2 == "" || keptAt[pm.Module] != "" || slices.Contains(s.InOwn, pm.Module) {
|
if !ok || m.FP2 == "" || keptAt[pm.Module] != "" || compose.Folds(slices.Contains(s.InOwn, pm.Module), wanted[pm.Module]) {
|
||||||
// A module it runs inside its own composition is composed there as before: no build of the new form is what
|
// A module it runs inside its own composition is composed there as before while it is folded: no build of the
|
||||||
// it runs (Scope.InOwn).
|
// new form is what it runs (Scope.InOwn). Wanted at a build of the new form it is no longer folded (compose.Folds,
|
||||||
|
// the composition's own rule), so its build is taken in (issue 1585).
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, refused := in.Refused[pm.Module]; refused {
|
if _, refused := in.Refused[pm.Module]; refused {
|
||||||
|
|||||||
Reference in New Issue
Block a user