composer: a module that fetches from an artifact store no node reaches waits alone, never the node
Typed resolution.NoStoreError from artifactsInto (image, source, tools bundle, runtime program, templates archive), laid on its module by composeWithoutStoreFetchers with A-452's "nothing provides" words and composed again, instead of a whole-node refusal. Replaces storeHeld and modulesNeedingTheStore, whose shape list missed bundles and held stand-ins. Builds: design 47 G-22 A-452, A-461, A-461b, A-459b
This commit is contained in:
@@ -2,6 +2,7 @@ package compose
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -171,6 +172,29 @@ func ComposeIn(in Input, node string, mode Mode) (Declared, []string, error) {
|
||||
return d, validate.Declaration(body), nil
|
||||
}
|
||||
|
||||
// composeWithoutStoreFetchers is resolution.Compose where a module that fetches from the artifact store while the node reaches
|
||||
// none (resolution.NoStoreError, whatever the shape: an image, a source, a tools bundle, a runtime program, a templates
|
||||
// archive) is left out of the declaration with its words and the rest composes again; the node is never refused whole for it
|
||||
// (design 47 G A-461, A-452). The rendering returned carries the modules so left out, for the filter and the rest to read.
|
||||
func composeWithoutStoreFetchers(plan catalogue.Resolution, with catalogue.Rendering) (catalogue.Composed, catalogue.Rendering, error) {
|
||||
for {
|
||||
composed, err := resolution.Compose(plan, with)
|
||||
var none *resolution.NoStoreError
|
||||
if !errors.As(err, &none) {
|
||||
return composed, with, err
|
||||
}
|
||||
if _, already := with.NotPlaced[none.Module]; already {
|
||||
return catalogue.Composed{}, with, err
|
||||
}
|
||||
left := make(map[string]string, len(with.NotPlaced)+1)
|
||||
for m, why := range with.NotPlaced {
|
||||
left[m] = why
|
||||
}
|
||||
left[none.Module] = none.Error()
|
||||
with.NotPlaced = left
|
||||
}
|
||||
}
|
||||
|
||||
// declaration is the controller's declarationWith over the plain Input.
|
||||
func (c *composer) declaration(nodeName string, mode Mode) (Declared, error) {
|
||||
resolved, err := c.planFor(nodeName)
|
||||
@@ -188,7 +212,7 @@ func (c *composer) declaration(nodeName string, mode Mode) (Declared, error) {
|
||||
with := rendered.Rendering
|
||||
with.Generators = gens
|
||||
plan := resolved.Plan
|
||||
composed, err := resolution.Compose(plan, with)
|
||||
composed, with, err := composeWithoutStoreFetchers(plan, with)
|
||||
if err != nil {
|
||||
return Declared{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user