A have waiting for a yes says whether the move changes the build alone: the composer composes the build the module runs with today's settings and secrets and the agent compares it with what runs, so a release's Approve answers it and a changed setting is still asked (ADR 0601 §1)
This commit is contained in:
@@ -1635,3 +1635,48 @@ func Transient(err error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ComposedToday is the digest of module composed at the build fp with today's settings and secrets, as this node would
|
||||
// compose it now beside its other modules at their wanted builds, the boxes it runs kept as compose keeps them, and whether
|
||||
// it composed (novox/hq ADR 0601 §1): the node agent compares it with what runs, to say whether a move to another build
|
||||
// changes the build alone. A module held, a node refused, or no placement: false, and the move is asked of a person.
|
||||
func (c *Composer) ComposedToday(ctx context.Context, module, fp string) (string, bool) {
|
||||
c.mu.Lock()
|
||||
fps, kept := map[string]string{}, map[string]string{}
|
||||
for m, w := range c.wants {
|
||||
if m == agent.NodeModule {
|
||||
continue
|
||||
}
|
||||
fps[m] = w.FP
|
||||
if mm, ok := c.modules[m]; ok && mm.FP2 != w.FP {
|
||||
kept[m] = w.FP
|
||||
}
|
||||
}
|
||||
fps[module] = fp
|
||||
delete(kept, module)
|
||||
if mm, ok := c.modules[module]; !ok || mm.FP2 != fp {
|
||||
kept[module] = fp
|
||||
}
|
||||
own, placed := c.placements[c.env.Node]
|
||||
inOwn := c.inOwnOf(own)
|
||||
c.mu.Unlock()
|
||||
if !placed {
|
||||
return "", false
|
||||
}
|
||||
var running []delivery.Composed
|
||||
if c.env.Running != nil {
|
||||
running = c.env.Running()
|
||||
}
|
||||
scope := frombus.Scope{Node: c.env.Node, KeptAt: kept, InOwn: inOwn, Running: running}
|
||||
comps, _, held, err := frombus.Compose(ctx, reader{c: c}, c.env.Mesh, scope, fps)
|
||||
if err != nil || held[module] != "" {
|
||||
return "", false
|
||||
}
|
||||
for _, comp := range comps {
|
||||
if comp.Module == module && comp.FP == fp {
|
||||
dig, err := delivery.ComposedDigestOf(c.keepRunning(comp, running))
|
||||
return dig, err == nil
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user