Compare commits
99
Commits
go/v0.1.155
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b50f6029e | ||
|
|
440c3c69ae | ||
|
|
41ca769fcb | ||
|
|
167eded5f1 | ||
|
|
e76e49e6a3 | ||
|
|
c0c6228ebb | ||
|
|
74bb7b4401 | ||
|
|
93d9d0ea13 | ||
|
|
3ae5fbdf1a | ||
|
|
2ce0acced1 | ||
|
|
da20b45a04 | ||
|
|
a5a7afdfa4 | ||
|
|
a2b916a896 | ||
|
|
1a19c5c4c1 | ||
|
|
367df6cadd | ||
|
|
a1379ef084 | ||
|
|
b53a3fd575 | ||
|
|
55ab8a82d0 | ||
|
|
bf18ae74cb | ||
|
|
ea5abba84d | ||
|
|
8614f0baf7 | ||
|
|
9afc8a160d | ||
|
|
600a4a99a5 | ||
|
|
6a550f59f6 | ||
|
|
b6702196b8 | ||
|
|
f6aff0182c | ||
|
|
ed0b905767 | ||
|
|
28726acaaf | ||
|
|
7bacccf562 | ||
|
|
29c4673ad1 | ||
|
|
a8240f5549 | ||
|
|
5792e83bc6 | ||
|
|
678d8fa5b3 | ||
|
|
b2d9d1ac90 | ||
|
|
6ffddedfbf | ||
|
|
146b9b4ff8 | ||
|
|
1d0a40592b | ||
|
|
7be95905f2 | ||
|
|
04fe2e30fe | ||
|
|
52ad5af1e9 | ||
|
|
cd16358b21 | ||
|
|
0c2ead025d | ||
|
|
5ab9bd9acc | ||
|
|
dc33ae26bb | ||
|
|
a096397928 | ||
|
|
5548fff81f | ||
|
|
52fa062e92 | ||
|
|
ef32d60a5e | ||
|
|
cfd2afe39c | ||
|
|
21daeb8893 | ||
|
|
ae1bf2098d | ||
|
|
f09bd2668a | ||
|
|
82156f8128 | ||
|
|
ffa58e51c4 | ||
|
|
cc1034630f | ||
|
|
73cb9ba690 | ||
|
|
fcac1fc5d0 | ||
|
|
db899d8ad4 | ||
|
|
4ca6e478a6 | ||
|
|
564fd5e0bb | ||
|
|
dc6dfef6f0 | ||
|
|
8eee17a368 | ||
|
|
2b79ee1593 | ||
|
|
9931d4f900 | ||
|
|
18136ce063 | ||
|
|
a5495bb15e | ||
|
|
5d3164b5b7 | ||
|
|
96d8136e2b | ||
|
|
c45f1621fb | ||
|
|
fd2cb13961 | ||
|
|
915a54f136 | ||
|
|
1c0309df23 | ||
|
|
7dd2891f32 | ||
|
|
b7e364e47b | ||
|
|
dca2545eb7 | ||
|
|
bd5852b817 | ||
|
|
1bfd54425b | ||
|
|
c6c86801ca | ||
|
|
33feb148ce | ||
|
|
f44442097c | ||
|
|
1f765ef17b | ||
|
|
203454b1a9 | ||
|
|
b691428ffc | ||
|
|
a41a7c2862 | ||
|
|
314a996ed9 | ||
|
|
7e103f3221 | ||
|
|
c37a7317b7 | ||
|
|
b2c9e60ac3 | ||
|
|
b77b70a66c | ||
|
|
7f5f175b05 | ||
|
|
1f33a4c04f | ||
|
|
49c656a4ce | ||
|
|
9005a2ee8e | ||
|
|
b914974b1d | ||
|
|
d151033dae | ||
|
|
3c742145d7 | ||
|
|
d557c0c2af | ||
|
|
c11c90348e | ||
|
|
1b177d5912 |
@@ -0,0 +1,152 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"maps"
|
||||||
|
"slices"
|
||||||
|
|
||||||
|
mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||||
|
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||||
|
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||||
|
mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||||
|
)
|
||||||
|
|
||||||
|
// assignmentDropTool drops one assignment key of a module no manifest names any more by hand (design 47 H2 H-A-509): a
|
||||||
|
// module key `<node>.<module>` of a retired module, as the clean state of the pass drops it, the act written in the
|
||||||
|
// hand-act log first.
|
||||||
|
const assignmentDropTool = "assigner_assignment_drop"
|
||||||
|
|
||||||
|
// assignmentLeft is why a module key `<node>.<module>` is not dropped, "" when it may be (H-A-509 and its second
|
||||||
|
// addendum, and the lead's answer of review round 1): only when no watched branch's catalog half holds the module (trunk, as
|
||||||
|
// world.trunk is) and the node key does not name it, since the node key is the commit of a write and a hand act never leaves
|
||||||
|
// one node's keys disagreeing; nothing while no half holds any module.
|
||||||
|
func assignmentLeft(node, module string, trunk map[string]bool, nodeRaw []byte, nodeFound bool) string {
|
||||||
|
switch {
|
||||||
|
case len(trunk) == 0:
|
||||||
|
return "no watched branch's catalog half holds a module yet, so no module is known to be retired"
|
||||||
|
case trunk[module]:
|
||||||
|
return "a watched branch's catalog half holds " + module
|
||||||
|
case !nodeFound:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
n, err := mmac.DecodeNode(nodeRaw)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("the node key of %s does not read, so whether it names %s is not known: %v", node, module, err)
|
||||||
|
}
|
||||||
|
if slices.ContainsFunc(n.Modules, func(r mma.AssignmentsByNodeNodeValueModulesItem) bool { return r.Module == module }) {
|
||||||
|
return "the node key of " + node + " still names " + module + ", so it stays placed there"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// dropAssignment deletes the module key of module on node, the act first recorded through the seat mesh-hand-acts; trunk
|
||||||
|
// answers every module a watched branch's catalog half holds.
|
||||||
|
func dropAssignment(st seatStore, ask func(string, any) (json.RawMessage, error), trunk func() (map[string]bool, error), node, module, why, by string) (any, error) {
|
||||||
|
switch {
|
||||||
|
case node == "" || module == "":
|
||||||
|
return nil, errors.New("name the node and the module whose assignment key is dropped")
|
||||||
|
case why == "":
|
||||||
|
return nil, errors.New("an assignment key dropped by hand says why")
|
||||||
|
case by == "" || by == stdio.Unproven:
|
||||||
|
return nil, errors.New("an assignment key dropped by hand names who drops it, and the runtime proved no caller")
|
||||||
|
}
|
||||||
|
key, err := mmac.ModuleKey(node, module)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nodeKey, err := mmac.NodeKey(node)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
raw, _, found, err := st.get(mma.StateAssignments, key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, fmt.Errorf("the assigner holds no assignment key %s", key)
|
||||||
|
}
|
||||||
|
modules, err := trunk()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("the watched branches' modules cannot be read, so %s stays: %w", key, err)
|
||||||
|
}
|
||||||
|
nodeRaw, _, nodeFound, err := st.get(mma.StateAssignments, nodeKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if left := assignmentLeft(node, module, modules, nodeRaw, nodeFound); left != "" {
|
||||||
|
return nil, fmt.Errorf("the assignment key %s stays: %s", key, left)
|
||||||
|
}
|
||||||
|
taken, err := meshhandactsclient.Recorder{Ask: ask}.Record(meshhandactsclient.Request{What: assignmentDropTool + " " + key, Why: why + " (" + by + ")", Cause: "assignment-drop"})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("the drop of %s is not recorded, so the key stays: %w", key, err)
|
||||||
|
}
|
||||||
|
if err := st.del(mma.StateAssignments, key); err != nil {
|
||||||
|
return nil, fmt.Errorf("the assignment key %s is not dropped: %w", key, err)
|
||||||
|
}
|
||||||
|
return map[string]any{"key": key, "dropped": json.RawMessage(raw), "by": by, "hand-act": taken.Log}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// watchedModules is every module any watched branch's catalog half holds, as the pass's world.trunk is (design 47 H2 H-A-509,
|
||||||
|
// the lead's answer of review round 1): the watched branches of the seat mesh-catalog's registrations, each branch's revision
|
||||||
|
// read whole through the verb revision, page by page; a branch with none yet holds none.
|
||||||
|
func watchedModules(call mcc.Call) func() (map[string]bool, error) {
|
||||||
|
return func() (map[string]bool, error) {
|
||||||
|
raw, err := call(mcc.RegistrationsVerb, meshcatalog.RegistrationsInput{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
answer, said, ok := buscalls.Unwrap(raw)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("%s answered: %s", mcc.RegistrationsVerb, said)
|
||||||
|
}
|
||||||
|
var regs meshcatalog.RegistrationsAnswer
|
||||||
|
if err := json.Unmarshal(answer, ®s); err != nil || regs.Registrations == nil {
|
||||||
|
return nil, fmt.Errorf("%s answered no registrations: %v", mcc.RegistrationsVerb, err)
|
||||||
|
}
|
||||||
|
branches := map[string]bool{}
|
||||||
|
for _, reg := range regs.Registrations {
|
||||||
|
for _, b := range reg.Branches {
|
||||||
|
branches[b] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out := map[string]bool{}
|
||||||
|
for _, branch := range slices.Sorted(maps.Keys(branches)) {
|
||||||
|
for after := ""; ; {
|
||||||
|
a, err := askCandidatePage(call, meshcatalog.RevisionInput{Branch: branch, After: after})
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("the catalog half of %s cannot be read: %w", branch, err)
|
||||||
|
}
|
||||||
|
if a.NoneYet {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for _, e := range a.Entries {
|
||||||
|
out[e.Module] = true
|
||||||
|
}
|
||||||
|
if a.Next == "" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
after = a.Next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignmentDropTools is the tool over the runtime's states.
|
||||||
|
func assignmentDropTools(st seatStore, ask func(string, any) (json.RawMessage, error), trunk func() (map[string]bool, error)) []stdio.Tool {
|
||||||
|
return []stdio.Tool{{Name: assignmentDropTool, Description: "Drop one assignment key by hand (design 47 H2 H-A-509): the module " +
|
||||||
|
"key <node>.<module> of the seat mesh-module-assigner's assignments, for a module no watched branch's catalog half holds any more " +
|
||||||
|
"(a retired module's key, which may predate the value's version), as the clean state of the pass drops it. Refused while a " +
|
||||||
|
"watched branch's catalog half holds the module, while the node key <node>.node still names it, or with no key there. Recorded as a " +
|
||||||
|
"hand act first.",
|
||||||
|
Input: schema(map[string]string{"node": "the node's name", "module": "the module's name", "why": "why the key is dropped"},
|
||||||
|
[]string{"node", "module", "why"}),
|
||||||
|
Run: func(a map[string]any) (any, error) {
|
||||||
|
return dropAssignment(st, ask, trunk, arg(a, "node"), arg(a, "module"), arg(a, "why"), stdio.CallerOf(a))
|
||||||
|
}}}
|
||||||
|
}
|
||||||
+175
@@ -0,0 +1,175 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||||
|
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
|
|
||||||
|
plc "mesh-delivery-assigner/internal/assignment"
|
||||||
|
)
|
||||||
|
|
||||||
|
// H-A-509 and its second addendum: a module key of a module no manifest of the trunk names, that the node key does not name,
|
||||||
|
// is dropped, by hand through assigner_assignment_drop (recorded as a hand act first) and at the pass's clean state (named in
|
||||||
|
// the journal); a key a manifest of the trunk still names, or the node key still names, stays; nothing goes while the trunk
|
||||||
|
// is empty.
|
||||||
|
func TestARetiredModulesAssignmentKeyIsDropped(t *testing.T) {
|
||||||
|
// novox places web; the key of the retired checker predates the value's version; the key of the retired old is still
|
||||||
|
// named by the node key.
|
||||||
|
values, err := mmac.AssignmentsValues(mma.Assignments{V: mmac.Version, Node: "novox", Modules: []mma.PlacedModule{{Module: "web"}, {Module: "old"}}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
values["novox.checker"] = []byte(`{"node":"novox"}`)
|
||||||
|
checker, web, old := "novox.checker", "novox.web", "novox.old"
|
||||||
|
trunkOf := func(names ...string) map[string]bool {
|
||||||
|
out := map[string]bool{}
|
||||||
|
for _, n := range names {
|
||||||
|
out[n] = true
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
copyOf := func() map[string][]byte {
|
||||||
|
out := map[string][]byte{}
|
||||||
|
for k, v := range values {
|
||||||
|
out[k] = v
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("by hand", func(t *testing.T) {
|
||||||
|
for _, c := range []struct {
|
||||||
|
name, module string
|
||||||
|
trunk map[string]bool
|
||||||
|
refuse error
|
||||||
|
dropped bool
|
||||||
|
}{
|
||||||
|
{"a retired module's key", "checker", trunkOf("web"), nil, true},
|
||||||
|
{"a manifest of the trunk names it", "web", trunkOf("web"), nil, false},
|
||||||
|
{"the node key still names it", "old", trunkOf("web"), nil, false},
|
||||||
|
{"the trunk is empty", "checker", trunkOf(), nil, false},
|
||||||
|
{"no key there", "gone", trunkOf("web"), nil, false},
|
||||||
|
{"not recorded", "checker", trunkOf("web"), errors.New("no responders"), false},
|
||||||
|
} {
|
||||||
|
st := memStore{mma.StateAssignments: &memKV{values: copyOf()}}
|
||||||
|
var asked []string
|
||||||
|
ask := func(verb string, body any) (json.RawMessage, error) {
|
||||||
|
raw, _ := json.Marshal(body)
|
||||||
|
asked = append(asked, verb+" "+string(raw))
|
||||||
|
return json.RawMessage(`{}`), c.refuse
|
||||||
|
}
|
||||||
|
trunk := func() (map[string]bool, error) { return c.trunk, nil }
|
||||||
|
out, err := dropAssignment(st, ask, trunk, "novox", c.module, "retired", "person.jochen")
|
||||||
|
key := "novox." + c.module
|
||||||
|
_, there := st[mma.StateAssignments].values[key]
|
||||||
|
switch {
|
||||||
|
case c.dropped && (err != nil || there || len(asked) != 1 || !strings.Contains(asked[0], assignmentDropTool+" "+key)):
|
||||||
|
t.Errorf("%s: %v, %v; the key left %v, asked %v", c.name, out, err, there, asked)
|
||||||
|
case !c.dropped && err == nil:
|
||||||
|
t.Errorf("%s: %v, want it refused", c.name, out)
|
||||||
|
case len(st[mma.StateAssignments].values) != len(values)-btoi(c.dropped):
|
||||||
|
t.Errorf("%s: %d keys left, want %d", c.name, len(st[mma.StateAssignments].values), len(values)-btoi(c.dropped))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := dropAssignment(memStore{mma.StateAssignments: &memKV{values: copyOf()}}, nil, func() (map[string]bool, error) { return trunkOf("web"), nil },
|
||||||
|
"novox", "checker", "", "person.jochen"); err == nil {
|
||||||
|
t.Error("a drop with no why is not refused")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// The tool judges against every watched branch's half, as the pass does (the lead's answer of review round 1): the branches
|
||||||
|
// of the registrations, each read page by page; a branch with none yet holds none.
|
||||||
|
t.Run("every watched branch", func(t *testing.T) {
|
||||||
|
call := func(verb string, body any) (json.RawMessage, error) {
|
||||||
|
switch verb {
|
||||||
|
case meshcatalogclient.RegistrationsVerb:
|
||||||
|
return json.Marshal(meshcatalog.RegistrationsAnswer{Registrations: []meshcatalog.Registration{{Module: "web", Branches: []string{"main", "feature"}}, {Module: "db", Branches: []string{"fresh"}}}})
|
||||||
|
case meshcatalogclient.RevisionVerb:
|
||||||
|
in := body.(meshcatalog.RevisionInput)
|
||||||
|
switch {
|
||||||
|
case in.Branch == "main" && in.After == "":
|
||||||
|
return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{}, Entries: []meshcatalog.CatalogEntry{{Module: "web"}}, Next: "web"})
|
||||||
|
case in.Branch == "main":
|
||||||
|
return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{}, Entries: []meshcatalog.CatalogEntry{{Module: "db"}}})
|
||||||
|
case in.Branch == "feature":
|
||||||
|
return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{}, Entries: []meshcatalog.CatalogEntry{{Module: "new"}}})
|
||||||
|
}
|
||||||
|
return json.Marshal(meshcatalog.RevisionAnswer{NoneYet: true})
|
||||||
|
}
|
||||||
|
return nil, errors.New("no such verb " + verb)
|
||||||
|
}
|
||||||
|
got, err := watchedModules(call)()
|
||||||
|
if err != nil || len(got) != 3 || !got["web"] || !got["db"] || !got["new"] {
|
||||||
|
t.Errorf("watchedModules = %v, %v; want web, db and new", got, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("at the pass", func(t *testing.T) {
|
||||||
|
for _, c := range []struct {
|
||||||
|
name string
|
||||||
|
trunk []string
|
||||||
|
gone []string
|
||||||
|
}{
|
||||||
|
{"a retired module's key goes, one the node key names stays", []string{"web"}, []string{checker}},
|
||||||
|
{"the trunk is empty", nil, nil},
|
||||||
|
} {
|
||||||
|
kv := &memKV{values: copyOf()}
|
||||||
|
p := newPasser(kvSet{plc.AssignmentsBucket(): kv}, time.Now())
|
||||||
|
var said []string
|
||||||
|
p.logf = func(f string, a ...any) { said = append(said, f) }
|
||||||
|
for k, v := range kv.values {
|
||||||
|
p.w.put(plc.AssignmentsBucket(), k, v)
|
||||||
|
}
|
||||||
|
// web is held by a watched branch that is not the trunk's first: the pass judges against every watched branch's half.
|
||||||
|
for _, n := range c.trunk {
|
||||||
|
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fpTest, Repository: "novox/" + n, Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath})
|
||||||
|
putModuleRaw(p.w, "feature", n, mod)
|
||||||
|
}
|
||||||
|
for range 2 {
|
||||||
|
p.wants(context.Background())
|
||||||
|
}
|
||||||
|
for _, key := range []string{checker, web, old, "novox.node"} {
|
||||||
|
_, there := kv.values[key]
|
||||||
|
if want := !contains(c.gone, key); there != want {
|
||||||
|
t.Errorf("%s: %s left = %v, want %v", c.name, key, there, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if dropped, left := countSaid(said, "is dropped"), countSaid(said, "is left"); len(c.gone) > 0 && (dropped != 1 || left != 1) {
|
||||||
|
t.Errorf("%s: said dropped %d and left %d times, want once each: %v", c.name, dropped, left, said)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func btoi(b bool) int {
|
||||||
|
if b {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func contains(list []string, s string) bool {
|
||||||
|
for _, x := range list {
|
||||||
|
if x == s {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func countSaid(said []string, words string) int {
|
||||||
|
n := 0
|
||||||
|
for _, s := range said {
|
||||||
|
if strings.Contains(s, words) {
|
||||||
|
n++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
@@ -154,6 +154,13 @@ func (b *builtEnds) madeOf(module, fp string) map[string]string {
|
|||||||
return parts
|
return parts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// releasedOf is the version released of module's done build at fp, the release whose parts are what its build.ended made (design
|
||||||
|
// 47 G A-421); false when no such release is heard.
|
||||||
|
func (w *world) releasedOf(module, fp string) (string, bool) {
|
||||||
|
k, ok := w.released.withParts(module, w.ends.madeOf(module, fp))
|
||||||
|
return k.Version, ok && k.Version != ""
|
||||||
|
}
|
||||||
|
|
||||||
// of is the version of module released from the source revision, with its parts' digests; false before it is heard.
|
// of is the version of module released from the source revision, with its parts' digests; false before it is heard.
|
||||||
func (r *releasedVersions) of(module string, source int64) (assign.KeptBuild, bool) {
|
func (r *releasedVersions) of(module string, source int64) (assign.KeptBuild, bool) {
|
||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import (
|
|||||||
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/testbus"
|
||||||
|
|
||||||
"mesh-delivery-assigner/internal/assign"
|
"mesh-delivery-assigner/internal/assign"
|
||||||
"mesh-delivery-assigner/internal/assigngraph"
|
"mesh-delivery-assigner/internal/assigngraph"
|
||||||
@@ -95,33 +96,62 @@ func TestTheWantsAreSaidWantedFromTheKeptAssignmentGraphRevision(t *testing.T) {
|
|||||||
if err := json.Unmarshal(events[len(events)-1].body, &w); err != nil || len(events) != 3 || !w.Removed || w.Fp != fpTest {
|
if err := json.Unmarshal(events[len(events)-1].body, &w); err != nil || len(events) != 3 || !w.Removed || w.Fp != fpTest {
|
||||||
t.Errorf("a removing want said %+v (%v), %d events", w, err, len(events))
|
t.Errorf("a removing want said %+v (%v), %d events", w, err, len(events))
|
||||||
}
|
}
|
||||||
// Design 47 H2 §813 (1), H-A-416: a want carries its run, its pipeline's source in decimal, or the newest source held for a
|
// Design 47 H2 §813 (1), H-A-504 corrected, its addendum and its third addendum: a want of a pipeline carries its run, the
|
||||||
// want of no pipeline; it is written by compare-and-set refusing a lower run, and one that differs only by its run stands.
|
// pipeline's sequence the want rule set, as information; a want of no pipeline the newest source held. The order is the bus's:
|
||||||
|
// a want is written by compare-and-set on the key's revision the pass read, whatever its run, and one that differs only by its
|
||||||
|
// run stands; a pass whose read the key has moved past writes nothing, says so once, and the next pass writes it.
|
||||||
t.Run("a want's run", func(t *testing.T) {
|
t.Run("a want's run", func(t *testing.T) {
|
||||||
wkey, _ := mwc.WantKey("g14", "db")
|
wkey, _ := mwc.WantKey("g14", "db")
|
||||||
stored := func() mwc.Want { w, _ := mwc.DecodeWant(kv.values[wkey]); return w }
|
stored := func() mwc.Want { w, _ := mwc.DecodeWant(kv.values[wkey]); return w }
|
||||||
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1})
|
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1, Run: "212"})
|
||||||
if w := stored(); w.Run != "12" || w.Pipeline != "main.12" {
|
if w := stored(); w.Run != "212" || w.Pipeline != "main.12" {
|
||||||
t.Fatalf("the want of pipeline main.12 is %+v, want run 12", w)
|
t.Fatalf("the want of pipeline main.12 is %+v, want run 212", w)
|
||||||
|
}
|
||||||
|
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.1", Pipeline: "main.11", Rank: 1, Run: "211"})
|
||||||
|
if w := stored(); w.Run != "211" || w.Version != "0.1.1" {
|
||||||
|
t.Errorf("a want of a lower run left %+v, want it written: the run is no gate", w)
|
||||||
}
|
}
|
||||||
puts := kv.puts
|
puts := kv.puts
|
||||||
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.1", Pipeline: "main.11", Rank: 1})
|
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.1", Pipeline: "main.11", Rank: 1, Run: "211"})
|
||||||
if w := stored(); w.Run != "12" || w.Version != "0.1.2" || kv.puts != puts {
|
|
||||||
t.Errorf("a want of a lower run replaced %+v (%d writes)", w, kv.puts-puts)
|
|
||||||
}
|
|
||||||
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1})
|
|
||||||
if kv.puts != puts {
|
if kv.puts != puts {
|
||||||
t.Error("a want that stands was written again")
|
t.Error("a want that stands was written again")
|
||||||
}
|
}
|
||||||
|
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1, Run: "212"})
|
||||||
skey, _ := mwc.WantKey("shanks", "db")
|
skey, _ := mwc.WantKey("shanks", "db")
|
||||||
p.putWant(ctx, "shanks", "db", mwc.Want{Fp: fpTest, Put: true, Words: "put: by hand"})
|
p.putWant(ctx, "shanks", "db", mwc.Want{Fp: fpTest, Put: true, Words: "put: by hand"})
|
||||||
if w, _ := mwc.DecodeWant(kv.values[skey]); w.Run != "9" {
|
if w, _ := mwc.DecodeWant(kv.values[skey]); w.Run != "9" {
|
||||||
t.Errorf("a put's want is %+v, want the newest source held, 9", w)
|
t.Errorf("a put's want is %+v, want the newest source held, 9", w)
|
||||||
}
|
}
|
||||||
// a placement's build after the delivery of run 12: the newest source held for it is the want's own, never refused
|
// a placement's build after the delivery of run 212: the newest source held for it is the want's own
|
||||||
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.0"})
|
p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.0"})
|
||||||
if w := stored(); w.Run != "12" || w.Version != "0.1.0" {
|
if w := stored(); w.Run != "212" || w.Version != "0.1.0" {
|
||||||
t.Errorf("a placement's want after run 12 is %+v, want it written at run 12", w)
|
t.Errorf("a placement's want after run 212 is %+v, want it written at run 212", w)
|
||||||
|
}
|
||||||
|
// Wants written before the sequence carry a revision number (322) as their run: a want of a lower sequence is written.
|
||||||
|
nkey, _ := mwc.WantKey("novox", "node-tools")
|
||||||
|
atNovox := func() mwc.Want { w, _ := mwc.DecodeWant(kv.values[nkey]); return w }
|
||||||
|
p.putWant(ctx, "novox", "node-tools", mwc.Want{Fp: fpTest, Version: "0.1.96", Pipeline: "main.265.again.2", Rank: 1, Run: "322"})
|
||||||
|
p.putWant(ctx, "novox", "node-tools", mwc.Want{Fp: fpTest, Version: "0.1.115", Pipeline: "main.320.again.1", Rank: 1, Run: "312"})
|
||||||
|
if w := atNovox(); w.Run != "312" || w.Version != "0.1.115" {
|
||||||
|
t.Errorf("seq 312 after run 322 left %+v, want 0.1.115 at run 312", w)
|
||||||
|
}
|
||||||
|
// A stale pass: another write moved the key past the revision this pass read; it loses, says so once, writes nothing.
|
||||||
|
var lines []string
|
||||||
|
p.logf = func(f string, a ...any) { lines = append(lines, fmt.Sprintf(f, a...)) }
|
||||||
|
defer func() { p.logf = t.Logf }()
|
||||||
|
newer, _ := mwc.EncodeWant(mwc.Want{Fp: fpTest, Version: "0.1.116", Pipeline: "main.321", Rank: 1, Run: "313"})
|
||||||
|
if _, err := kv.Update(ctx, nkey, newer, kv.revision(nkey)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
puts = kv.puts
|
||||||
|
p.putWant(ctx, "novox", "node-tools", mwc.Want{Fp: fpTest, Version: "0.1.114", Pipeline: "main.319", Rank: 1, Run: "311"})
|
||||||
|
if w := atNovox(); w.Version != "0.1.116" || kv.puts != puts || len(lines) != 1 || !strings.Contains(lines[0], "the newer write stands") {
|
||||||
|
t.Errorf("a stale pass left %+v (%d writes), said %q", w, kv.puts-puts, lines)
|
||||||
|
}
|
||||||
|
p.w.putEntry(buckets.Wants(), nkey, newer, kv.revision(nkey), at) // the watch hands the newer write
|
||||||
|
p.putWant(ctx, "novox", "node-tools", mwc.Want{Fp: fpTest, Version: "0.1.117", Pipeline: "main.322", Rank: 1, Run: "314"})
|
||||||
|
if w := atNovox(); w.Version != "0.1.117" || len(lines) != 1 {
|
||||||
|
t.Errorf("the next pass left %+v, said %q", w, lines)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -170,15 +200,21 @@ func TestTheWantsAreSaidWantedFromTheKeptAssignmentGraphRevision(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// blockedObjects is an object bucket whose listing waits while a gate stands: a keeping that does not end until it is opened.
|
// blockedObjects is an object bucket whose listing waits while a gate stands: a keeping that does not end until it is opened.
|
||||||
|
// A listing that meets the gate closes entered: the keeping took its need and runs it (H-A-476).
|
||||||
type blockedObjects struct {
|
type blockedObjects struct {
|
||||||
memObjects
|
memObjects
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
gate chan struct{}
|
gate chan struct{}
|
||||||
|
entered chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *blockedObjects) Names(ctx context.Context) ([]string, error) {
|
func (b *blockedObjects) Names(ctx context.Context) ([]string, error) {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
gate := b.gate
|
gate, entered := b.gate, b.entered
|
||||||
|
if gate != nil && entered != nil {
|
||||||
|
close(entered)
|
||||||
|
b.entered = nil
|
||||||
|
}
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
if gate != nil {
|
if gate != nil {
|
||||||
<-gate
|
<-gate
|
||||||
@@ -204,16 +240,33 @@ func (b *blockedObjects) Get(ctx context.Context, name string) ([]byte, error) {
|
|||||||
func (b *blockedObjects) block() func() {
|
func (b *blockedObjects) block() func() {
|
||||||
gate := make(chan struct{})
|
gate := make(chan struct{})
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
b.gate = gate
|
b.gate, b.entered = gate, make(chan struct{})
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
return func() {
|
return func() {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
b.gate = nil
|
b.gate, b.entered = nil, nil
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
close(gate)
|
close(gate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// awaitBlocked returns once a keeping meets the standing gate, so what the keeping took is read after it took it, and fails the
|
||||||
|
// test when none did within bound (H-A-476: a test waits on the signal of the work it reads after, never on an order it assumes).
|
||||||
|
func (b *blockedObjects) awaitBlocked(t *testing.T, bound time.Duration, what string) {
|
||||||
|
t.Helper()
|
||||||
|
b.mu.Lock()
|
||||||
|
entered := b.entered
|
||||||
|
b.mu.Unlock()
|
||||||
|
if entered == nil {
|
||||||
|
return // met already
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-entered:
|
||||||
|
case <-time.After(bound):
|
||||||
|
t.Fatalf("no keeping met the gate within %s: %s", bound, what)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Design 47 H-A-259, H-A-261: the keeping of the assignment graph runs off the pass loop. At the start, while the first keeping is
|
// Design 47 H-A-259, H-A-261: the keeping of the assignment graph runs off the pass loop. At the start, while the first keeping is
|
||||||
// blocked, a pass returns and writes no want; the keeping's end wakes a pass, which writes the passed pipeline's want. Later, while a
|
// blocked, a pass returns and writes no want; the keeping's end wakes a pass, which writes the passed pipeline's want. Later, while a
|
||||||
// keeping of new inputs is blocked, a pass writes the wants from the revision it holds, and a pass of the same inputs hands nothing
|
// keeping of new inputs is blocked, a pass writes the wants from the revision it holds, and a pass of the same inputs hands nothing
|
||||||
@@ -222,6 +275,7 @@ func TestAPassWritesWantsWhileAKeepingIsBlocked(t *testing.T) {
|
|||||||
fp := mcc.SourcePrefix2 + strings.Repeat("a", 64)
|
fp := mcc.SourcePrefix2 + strings.Repeat("a", 64)
|
||||||
wantsKV := &memKV{values: map[string][]byte{}}
|
wantsKV := &memKV{values: map[string][]byte{}}
|
||||||
p := newPasser(kvSet{buckets.Wants(): wantsKV, buckets.Asks(): &memKV{values: map[string][]byte{}}}, time.Now())
|
p := newPasser(kvSet{buckets.Wants(): wantsKV, buckets.Asks(): &memKV{values: map[string][]byte{}}}, time.Now())
|
||||||
|
bound := testbus.SetupBound(t) // every wait on a goroutine's work, never a value in the test (H-A-476)
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
var journal strings.Builder
|
var journal strings.Builder
|
||||||
p.logf = func(f string, a ...any) { mu.Lock(); fmt.Fprintf(&journal, f+"\n", a...); mu.Unlock() }
|
p.logf = func(f string, a ...any) { mu.Lock(); fmt.Fprintf(&journal, f+"\n", a...); mu.Unlock() }
|
||||||
@@ -252,7 +306,7 @@ func TestAPassWritesWantsWhileAKeepingIsBlocked(t *testing.T) {
|
|||||||
go func() { p.pass(context.Background()); close(done) }()
|
go func() { p.pass(context.Background()); close(done) }()
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
case <-time.After(10 * time.Second):
|
case <-time.After(bound):
|
||||||
t.Fatal("the pass waits on the keeping of the assignment graph")
|
t.Fatal("the pass waits on the keeping of the assignment graph")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +335,7 @@ func TestAPassWritesWantsWhileAKeepingIsBlocked(t *testing.T) {
|
|||||||
open()
|
open()
|
||||||
select {
|
select {
|
||||||
case <-woke:
|
case <-woke:
|
||||||
case <-time.After(10 * time.Second):
|
case <-time.After(bound):
|
||||||
t.Fatal("the first keeping's end wakes no pass")
|
t.Fatal("the first keeping's end wakes no pass")
|
||||||
}
|
}
|
||||||
pass()
|
pass()
|
||||||
@@ -292,7 +346,8 @@ func TestAPassWritesWantsWhileAKeepingIsBlocked(t *testing.T) {
|
|||||||
open = objects.block() // a keeping of new inputs is blocked
|
open = objects.block() // a keeping of new inputs is blocked
|
||||||
placeOn(t, p.w, "g14", "web")
|
placeOn(t, p.w, "g14", "web")
|
||||||
pass()
|
pass()
|
||||||
pass() // the same inputs again
|
pass() // the same inputs again
|
||||||
|
objects.awaitBlocked(t, bound, "the keeping of new inputs never took its need") // H-A-476: read the need once it was taken
|
||||||
if w, err := wantOf("g14"); err != nil || w.Fp != fp || w.Version != "0.1.2" {
|
if w, err := wantOf("g14"); err != nil || w.Fp != fp || w.Version != "0.1.2" {
|
||||||
t.Errorf("the want of web on g14 = %+v (%v), want the passed version while a keeping is blocked", w, err)
|
t.Errorf("the want of web on g14 = %+v (%v), want the passed version while a keeping is blocked", w, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ func (b *bed) ended(t *testing.T, source int64, outcome string, movers ...moverA
|
|||||||
if outcome != mpr.PipelineEndedOutcomePassed {
|
if outcome != mpr.PipelineEndedOutcomePassed {
|
||||||
step.Outcome = mpr.StepResultOutcomeFailed
|
step.Outcome = mpr.StepResultOutcomeFailed
|
||||||
}
|
}
|
||||||
e := mpr.PipelineEnded{V: 1, Pipeline: pipeline, Branch: trunkBranch, Source: source, Outcome: outcome}
|
e := mpr.PipelineEnded{V: 1, Pipeline: pipeline, Branch: trunkBranch, Source: source, Seq: 200 + source, Outcome: outcome}
|
||||||
for _, m := range movers {
|
for _, m := range movers {
|
||||||
e.Movers = append(e.Movers, mpr.MoverEnded{Module: m.module, Fingerprint: m.fp, Version: m.version, Tier: m.tier, Steps: []mpr.StepResult{step}})
|
e.Movers = append(e.Movers, mpr.MoverEnded{Module: m.module, Fingerprint: m.fp, Version: m.version, Tier: m.tier, Steps: []mpr.StepResult{step}})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -656,6 +656,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber,
|
|||||||
// once the first registrations are written (§95, §353).
|
// once the first registrations are written (§95, §353).
|
||||||
p.ends = newPipelineEnds(kvEnds{ctx, kv}, wake, logger.Printf)
|
p.ends = newPipelineEnds(kvEnds{ctx, kv}, wake, logger.Printf)
|
||||||
p.ends.trunk = w.trunkName
|
p.ends.trunk = w.trunkName
|
||||||
|
p.ends.releasedOf = w.releasedOf // a version released before its pipeline passed is taken at the pass (H-A-490)
|
||||||
p.ends.runEnded = func(group string) error { return p.dropCandidate(ctx, group) }
|
p.ends.runEnded = func(group string) error { return p.dropCandidate(ctx, group) }
|
||||||
if err := hearEnds(hub, p.ends); err != nil {
|
if err := hearEnds(hub, p.ends); err != nil {
|
||||||
logger.Printf("a pipeline's end is not heard, so the wants keep the trunk-only form until the assigner starts again: %v", err)
|
logger.Printf("a pipeline's end is not heard, so the wants keep the trunk-only form until the assigner starts again: %v", err)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||||
|
"maps"
|
||||||
"mesh-delivery-assigner/internal/buckets"
|
"mesh-delivery-assigner/internal/buckets"
|
||||||
"reflect"
|
"reflect"
|
||||||
"slices"
|
"slices"
|
||||||
@@ -14,6 +15,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||||
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
||||||
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks"
|
||||||
@@ -97,6 +99,9 @@ type passer struct {
|
|||||||
// saidWaits is the last said of the seat's wait for its states (sayWaits).
|
// saidWaits is the last said of the seat's wait for its states (sayWaits).
|
||||||
saidWaits string
|
saidWaits string
|
||||||
intended map[string]map[string]map[string]bool
|
intended map[string]map[string]map[string]bool
|
||||||
|
// assignmentLeftSaid is, by assignment key, the why last said that the clean state leaves a retired module's key (H-A-509),
|
||||||
|
// so each is said once per why.
|
||||||
|
assignmentLeftSaid map[string]string
|
||||||
// laidHere are the proposals whose candidates this process wrote (design 47 G A-317), by id.
|
// laidHere are the proposals whose candidates this process wrote (design 47 G A-317), by id.
|
||||||
laidHere map[string]bool
|
laidHere map[string]bool
|
||||||
// reads is the assigner's state engine-reads, what each node's engine said it reads (enginewords.go, design 47 H-A-104);
|
// reads is the assigner's state engine-reads, what each node's engine said it reads (enginewords.go, design 47 H-A-104);
|
||||||
@@ -222,6 +227,7 @@ func (p *passer) wants(ctx context.Context) {
|
|||||||
puts := p.putsByModule()
|
puts := p.putsByModule()
|
||||||
builds := placementBuilds(p.w.assignments())
|
builds := placementBuilds(p.w.assignments())
|
||||||
p.staleAsks(ctx, trunk)
|
p.staleAsks(ctx, trunk)
|
||||||
|
p.retiredAssignments(ctx, trunk)
|
||||||
names := map[string]bool{}
|
names := map[string]bool{}
|
||||||
for name := range trunk {
|
for name := range trunk {
|
||||||
names[name] = true
|
names[name] = true
|
||||||
@@ -312,15 +318,14 @@ func (p *passer) putWant(ctx context.Context, node, module string, want mwc.Want
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// runOf is the run a want carries (design 47 H2 §813 (1); H-A-355 (1), H-A-416): the source revision of the pipeline that
|
// runOf is the run a want carries (design 47 H2 §813 (1); H-A-355 (1), H-A-504 corrected and its addendum): the sequence of
|
||||||
// released it, `<branch>.<source>`, in decimal; for a want of no pipeline (a put, a placement's build, a removal) the newest
|
// the pipeline that released it, as its pipeline-ended said it, set on the want by the want rule; for a want of no pipeline (a
|
||||||
// source the assigner holds for it: the trunk's source of its kept assignment graph revision, or the run of the want written
|
// put, a placement's build, a removal) the newest source the assigner holds for it: the trunk's source of its kept assignment
|
||||||
// (held) when that is newer, so a person's put or placement after a delivery is never refused as older; "" when it holds none.
|
// graph revision, or the run of the want written (held) when that is newer, so a person's put or placement after a delivery is
|
||||||
|
// never refused as older; "" when it holds none.
|
||||||
func (p *passer) runOf(want mwc.Want, held *mwc.Want) string {
|
func (p *passer) runOf(want mwc.Want, held *mwc.Want) string {
|
||||||
if i := strings.LastIndexByte(want.Pipeline, '.'); i >= 0 {
|
if want.Run != "" {
|
||||||
if n, err := strconv.ParseInt(want.Pipeline[i+1:], 10, 64); err == nil && n > 0 {
|
return want.Run
|
||||||
return strconv.FormatInt(n, 10)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var newest int64
|
var newest int64
|
||||||
if p.graph != nil {
|
if p.graph != nil {
|
||||||
@@ -343,12 +348,16 @@ func runNumber(run string) int64 {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// wantWritten writes the want of module on node under key by compare-and-set, carrying its run (design 47 H2 §813 (1)): a want
|
// wantWritten writes the want of module on node under key, carrying its run as information (design 47 H2 §813 (1), H-A-504
|
||||||
// that differs from the one written only by its run is not written again (its run stays, so a node never composes again for
|
// third addendum): the order is the bus's own, a compare-and-set on the key's revision this pass read, so a stale pass loses to
|
||||||
// it), and one whose run is lower than the run written is refused, said in the journal. It answers whether it wrote.
|
// the newer write, said once in the journal, and the next pass judges the key again from what it then reads. The run is the
|
||||||
|
// pipeline's sequence for the why and the tools, never a gate. A want that differs from the one written only by its run is
|
||||||
|
// not written again (its run stays, so a node never composes again for it). It answers whether it wrote.
|
||||||
func (p *passer) wantWritten(ctx context.Context, node, module, key string, want mwc.Want) bool {
|
func (p *passer) wantWritten(ctx context.Context, node, module, key string, want mwc.Want) bool {
|
||||||
|
raw := p.w.value(buckets.Wants(), key)
|
||||||
|
read := p.w.metaOf(buckets.Wants(), key).revision
|
||||||
var held *mwc.Want
|
var held *mwc.Want
|
||||||
if raw := p.w.value(buckets.Wants(), key); raw != nil {
|
if raw != nil {
|
||||||
if h, err := mwc.DecodeWant(raw); err == nil {
|
if h, err := mwc.DecodeWant(raw); err == nil {
|
||||||
held = &h
|
held = &h
|
||||||
}
|
}
|
||||||
@@ -359,9 +368,6 @@ func (p *passer) wantWritten(ctx context.Context, node, module, key string, want
|
|||||||
same.Run = want.Run
|
same.Run = want.Run
|
||||||
if reflect.DeepEqual(same, want) {
|
if reflect.DeepEqual(same, want) {
|
||||||
want.Run = held.Run // it stands: nothing is written
|
want.Run = held.Run // it stands: nothing is written
|
||||||
} else if runNumber(held.Run) > runNumber(want.Run) {
|
|
||||||
p.logf("the want of %s on %s is not written: its run %q is lower than the run %q written (§813 (1))", module, node, want.Run, held.Run)
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value, err := mwc.EncodeWant(want)
|
value, err := mwc.EncodeWant(want)
|
||||||
@@ -369,20 +375,19 @@ func (p *passer) wantWritten(ctx context.Context, node, module, key string, want
|
|||||||
p.logf("%s %s is not written: %v", buckets.Wants(), key, err)
|
p.logf("%s %s is not written: %v", buckets.Wants(), key, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if held := p.w.value(buckets.Wants(), key); held != nil && bytes.Equal(held, value) {
|
if raw != nil && bytes.Equal(raw, value) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
kv := p.kvs[buckets.Wants()]
|
kv := p.kvs[buckets.Wants()]
|
||||||
entry, err := kv.Get(ctx, key)
|
var revision uint64
|
||||||
switch {
|
if raw == nil {
|
||||||
case errors.Is(err, jetstream.ErrKeyNotFound):
|
revision, err = kv.Create(ctx, key, value)
|
||||||
_, err = kv.Create(ctx, key, value)
|
} else {
|
||||||
case err == nil:
|
revision, err = kv.Update(ctx, key, value, read)
|
||||||
if h, derr := mwc.DecodeWant(entry.Value()); derr == nil && runNumber(h.Run) > runNumber(want.Run) {
|
}
|
||||||
p.logf("the want of %s on %s is not written: its run %q is lower than the run %q written (§813 (1))", module, node, want.Run, h.Run)
|
if errors.Is(err, jetstream.ErrKeyExists) || errors.Is(err, jetstream.ErrKeyRevisionMismatch) || (err != nil && isWrongSequence(err)) {
|
||||||
return false
|
p.logf("the want of %s on %s (run %q) is not written: its key moved past revision %d this pass read, and the newer write stands (§813 (1), H-A-504 third addendum); the next pass judges it again", module, node, want.Run, read)
|
||||||
}
|
return false
|
||||||
_, err = kv.Update(ctx, key, value, entry.Revision())
|
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(err, context.Canceled) {
|
if !errors.Is(err, context.Canceled) {
|
||||||
@@ -390,7 +395,7 @@ func (p *passer) wantWritten(ctx context.Context, node, module, key string, want
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
p.w.put(buckets.Wants(), key, value)
|
p.w.putEntry(buckets.Wants(), key, value, revision, p.clock())
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,6 +534,42 @@ func (p *passer) staleAsks(ctx context.Context, trunk map[string]meshcatalog.Mod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// retiredAssignments is the clean state of the assignments at the pass (design 47 H2 H-A-509 and its second addendum): each
|
||||||
|
// module key `<node>.<module>` of a module no manifest the trunk holds names, that the node key does not name, is deleted and
|
||||||
|
// named in the journal, whether its value reads or not; one the node key still names is left, said once per why. Nothing goes
|
||||||
|
// while the trunk is empty, or with no assignments bucket open.
|
||||||
|
func (p *passer) retiredAssignments(ctx context.Context, trunk map[string]meshcatalog.ModulesByModuleValue) {
|
||||||
|
if len(trunk) == 0 || p.kvs[plc.AssignmentsBucket()] == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
names := make(map[string]bool, len(trunk))
|
||||||
|
for name := range trunk {
|
||||||
|
names[name] = true
|
||||||
|
}
|
||||||
|
held := p.w.read(plc.AssignmentsBucket())
|
||||||
|
for _, key := range slices.Sorted(maps.Keys(held)) {
|
||||||
|
node, module, kind, err := mmac.ParseKey(key)
|
||||||
|
if err != nil || kind != mmac.ModuleKind || names[module] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
nodeKey, _ := mmac.NodeKey(node)
|
||||||
|
nodeRaw, nodeFound := held[nodeKey]
|
||||||
|
if left := assignmentLeft(node, module, names, nodeRaw, nodeFound); left != "" {
|
||||||
|
if p.assignmentLeftSaid[key] != left {
|
||||||
|
if p.assignmentLeftSaid == nil {
|
||||||
|
p.assignmentLeftSaid = map[string]string{}
|
||||||
|
}
|
||||||
|
p.assignmentLeftSaid[key] = left
|
||||||
|
p.logf("the assignment key %s is of a module no manifest of the trunk names, and is left: %s", key, left)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
delete(p.assignmentLeftSaid, key)
|
||||||
|
p.logf("the assignment key %s is of a module no manifest of the trunk names, and is dropped", key)
|
||||||
|
p.remove(ctx, plc.AssignmentsBucket(), key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// remove deletes one key of the assigner's own bucket when it holds it; a delete that fails is said and made again at the next
|
// remove deletes one key of the assigner's own bucket when it holds it; a delete that fails is said and made again at the next
|
||||||
// pass.
|
// pass.
|
||||||
func (p *passer) remove(ctx context.Context, bucket, key string) {
|
func (p *passer) remove(ctx context.Context, bucket, key string) {
|
||||||
|
|||||||
@@ -46,19 +46,39 @@ import (
|
|||||||
type memKV struct {
|
type memKV struct {
|
||||||
jetstream.KeyValue
|
jetstream.KeyValue
|
||||||
values map[string][]byte
|
values map[string][]byte
|
||||||
puts int // how many puts reached the bucket
|
puts int // how many puts reached the bucket
|
||||||
|
revs map[string]uint64 // each key's revision, as the bus numbers its writes (a key set by hand has none: its length stands in)
|
||||||
|
seq uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// written gives key the bucket's next revision, as a write on the bus does.
|
||||||
|
func (m *memKV) written(key string) uint64 {
|
||||||
|
if m.revs == nil {
|
||||||
|
m.revs = map[string]uint64{}
|
||||||
|
}
|
||||||
|
m.seq++
|
||||||
|
m.revs[key] = m.seq
|
||||||
|
return m.seq
|
||||||
|
}
|
||||||
|
|
||||||
|
// revision is key's revision as the bucket holds it.
|
||||||
|
func (m *memKV) revision(key string) uint64 {
|
||||||
|
if r, ok := m.revs[key]; ok {
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
return uint64(len(m.values[key]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memKV) Put(_ context.Context, key string, value []byte) (uint64, error) {
|
func (m *memKV) Put(_ context.Context, key string, value []byte) (uint64, error) {
|
||||||
m.values[key] = value
|
m.values[key] = value
|
||||||
m.puts++
|
m.puts++
|
||||||
return uint64(len(m.values)), nil
|
return m.written(key), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memKV) Create(_ context.Context, key string, value []byte, _ ...jetstream.KVCreateOpt) (uint64, error) {
|
func (m *memKV) Create(_ context.Context, key string, value []byte, _ ...jetstream.KVCreateOpt) (uint64, error) {
|
||||||
m.values[key] = value
|
m.values[key] = value
|
||||||
m.puts++ // a write that reaches the bucket (the wants' compare-and-set, design 47 H2 §813 (1))
|
m.puts++ // a write that reaches the bucket (the wants' compare-and-set, design 47 H2 §813 (1))
|
||||||
return uint64(len(m.values)), nil
|
return m.written(key), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *memKV) Delete(_ context.Context, key string, _ ...jetstream.KVDeleteOpt) error {
|
func (m *memKV) Delete(_ context.Context, key string, _ ...jetstream.KVDeleteOpt) error {
|
||||||
@@ -247,15 +267,15 @@ func (m *memKV) Get(_ context.Context, key string) (jetstream.KeyValueEntry, err
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, jetstream.ErrKeyNotFound
|
return nil, jetstream.ErrKeyNotFound
|
||||||
}
|
}
|
||||||
return memEntry{value: v, revision: uint64(len(v))}, nil
|
return memEntry{value: v, revision: m.revision(key)}, nil
|
||||||
}
|
}
|
||||||
func (m *memKV) Update(_ context.Context, key string, value []byte, revision uint64) (uint64, error) {
|
func (m *memKV) Update(_ context.Context, key string, value []byte, revision uint64) (uint64, error) {
|
||||||
if uint64(len(m.values[key])) != revision {
|
if m.revision(key) != revision {
|
||||||
return 0, errors.New("wrong last sequence")
|
return 0, fmt.Errorf("wrong last sequence: %w", jetstream.ErrKeyRevisionMismatch)
|
||||||
}
|
}
|
||||||
m.values[key] = value
|
m.values[key] = value
|
||||||
m.puts++
|
m.puts++
|
||||||
return uint64(len(value)), nil
|
return m.written(key), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// memStore is the runtime's states for the put's tools, over the same memKVs a pass writes.
|
// memStore is the runtime's states for the put's tools, over the same memKVs a pass writes.
|
||||||
@@ -266,7 +286,7 @@ func (s memStore) get(state, key string) ([]byte, uint64, bool, error) {
|
|||||||
return nil, 0, false, nil
|
return nil, 0, false, nil
|
||||||
}
|
}
|
||||||
v, ok := s[state].values[key]
|
v, ok := s[state].values[key]
|
||||||
return v, uint64(len(v)), ok, nil
|
return v, s[state].revision(key), ok, nil
|
||||||
}
|
}
|
||||||
func (s memStore) put(state, key string, value []byte) error {
|
func (s memStore) put(state, key string, value []byte) error {
|
||||||
s[state].values[key] = value
|
s[state].values[key] = value
|
||||||
@@ -409,7 +429,12 @@ func putOfTheBus(t *testing.T) {
|
|||||||
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: mdigest, Repository: "novox/mesh-catalog", Commit: strings.Repeat("c", 40)})
|
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: mdigest, Repository: "novox/mesh-catalog", Commit: strings.Repeat("c", 40)})
|
||||||
putModuleRaw(p.w, trunkBranch, "nats", mod)
|
putModuleRaw(p.w, trunkBranch, "nats", mod)
|
||||||
p.w.manifests[mdigest] = parsed{module: "nats", manifest: catalogue.Manifest{Module: "nats", Provides: []catalogue.Offer{{Name: "mesh-bus"}}}}
|
p.w.manifests[mdigest] = parsed{module: "nats", manifest: catalogue.Manifest{Module: "nats", Provides: []catalogue.Offer{{Name: "mesh-bus"}}}}
|
||||||
endDone(t, p.w, "nats", fp, mdigest)
|
// The build and its release (H-A-490 addendum): the put's want names the version released at its parts.
|
||||||
|
built, _ := json.Marshal(builds.BuildEnded{Module: "nats", Fingerprint: fp, Outcome: builds.BuildDone, Manifest: mdigest, Made: map[string]string{"program": "sha256:5"}})
|
||||||
|
rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "nats", Source: 8, Version: "2.10.1", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "nats:program", Digest: "sha256:5"}}})
|
||||||
|
if p.w.ends.put(built) != nil || p.w.released.put(rel) != nil {
|
||||||
|
t.Fatal("the build or its release is not heard")
|
||||||
|
}
|
||||||
hkey, _ := nodeengineclient.HaveKey("novox", "nats")
|
hkey, _ := nodeengineclient.HaveKey("novox", "nats")
|
||||||
before, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
before, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
||||||
world(buckets.Have, hkey, before)
|
world(buckets.Have, hkey, before)
|
||||||
@@ -489,7 +514,7 @@ func putOfTheBus(t *testing.T) {
|
|||||||
<-woke
|
<-woke
|
||||||
got = step()
|
got = step()
|
||||||
w, err := mwc.DecodeWant(wantsKV.values["want.novox.nats"])
|
w, err := mwc.DecodeWant(wantsKV.values["want.novox.nats"])
|
||||||
if got.Step != puts.Wanted || err != nil || w.Fp != fp || !w.Put || !w.Hold {
|
if got.Step != puts.Wanted || err != nil || w.Fp != fp || w.Version != "2.10.1" || !w.Put || !w.Hold {
|
||||||
t.Fatalf("snapshotted, the put stands at %s (%s); the want %+v, %v", got.Step, got.Words, w, err)
|
t.Fatalf("snapshotted, the put stands at %s (%s); the want %+v, %v", got.Step, got.Words, w, err)
|
||||||
}
|
}
|
||||||
if call := <-bus.calls; !strings.HasPrefix(call, "seat:mesh-hand-acts.warranted ") || !strings.Contains(call, a.Ask.ID) { // ADR 0565 §11: into the seat
|
if call := <-bus.calls; !strings.HasPrefix(call, "seat:mesh-hand-acts.warranted ") || !strings.Contains(call, a.Ask.ID) { // ADR 0565 §11: into the seat
|
||||||
@@ -740,12 +765,12 @@ func aPlacedNodesWantsNameTheBuildAloneAndItsYesComesFromItsHave(t *testing.T) {
|
|||||||
wkey, _ := mwc.WantKey("g14", "web")
|
wkey, _ := mwc.WantKey("g14", "web")
|
||||||
want, _ := mwc.EncodeWant(mwc.Want{Fp: fpOld, Version: "0.1.1", Pipeline: trunkBranch + ".1", Rank: 1})
|
want, _ := mwc.EncodeWant(mwc.Want{Fp: fpOld, Version: "0.1.1", Pipeline: trunkBranch + ".1", Rank: 1})
|
||||||
wantsKV.values[wkey] = want
|
wantsKV.values[wkey] = want
|
||||||
put(buckets.Wants(), wkey, want)
|
sync := func() { // as the watch hands the wants, with their revisions
|
||||||
sync := func() {
|
|
||||||
for k, v := range wantsKV.values {
|
for k, v := range wantsKV.values {
|
||||||
put(buckets.Wants(), k, v)
|
p.w.putEntry(buckets.Wants(), k, v, wantsKV.revision(k), time.Now())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sync()
|
||||||
|
|
||||||
p.wants(context.Background())
|
p.wants(context.Background())
|
||||||
p.nodeWants(context.Background())
|
p.nodeWants(context.Background())
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
mprc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient"
|
mprc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshpipelinerunnerclient"
|
||||||
mpcat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
mpcat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/pipelinekey"
|
||||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||||
@@ -43,8 +44,11 @@ const pipelineEndedSubject = "mesh.seat." + mpr.Seat + ".event." + mpr.EventPipe
|
|||||||
type End struct {
|
type End struct {
|
||||||
Pipeline string `json:"pipeline"`
|
Pipeline string `json:"pipeline"`
|
||||||
Source int64 `json:"source"`
|
Source int64 `json:"source"`
|
||||||
Fp string `json:"fp"`
|
// Seq is the pipeline's sequence its pipeline-ended said, written as the run of its wants (design 47 H2 §813 (1), H-A-504
|
||||||
Version string `json:"version"`
|
// addendum).
|
||||||
|
Seq int64 `json:"seq,omitempty"`
|
||||||
|
Fp string `json:"fp"`
|
||||||
|
Version string `json:"version"`
|
||||||
// Rank is the mover's tier in the pipeline's delivery order, from 1 (§746, §750).
|
// Rank is the mover's tier in the pipeline's delivery order, from 1 (§746, §750).
|
||||||
Rank int64 `json:"rank"`
|
Rank int64 `json:"rank"`
|
||||||
}
|
}
|
||||||
@@ -140,6 +144,8 @@ type pipelineEnds struct {
|
|||||||
// firsts is, by module, the first watched branch of its registration, the branch of a placement that names none (design
|
// firsts is, by module, the first watched branch of its registration, the branch of a placement that names none (design
|
||||||
// 47 G §14).
|
// 47 G §14).
|
||||||
firsts map[string]string
|
firsts map[string]string
|
||||||
|
// noSeq is, by module and pipeline, the ends kept without a sequence already said (H-A-504 second addendum).
|
||||||
|
noSeq map[string]bool
|
||||||
// runEnded is told a run on request's pipeline-ended, its group `run-<id>`, to drop the run's candidate (A-235, H-A-58); nil
|
// runEnded is told a run on request's pipeline-ended, its group `run-<id>`, to drop the run's candidate (A-235, H-A-58); nil
|
||||||
// drops nothing.
|
// drops nothing.
|
||||||
runEnded func(group string) error
|
runEnded func(group string) error
|
||||||
@@ -152,6 +158,10 @@ type pipelineEnds struct {
|
|||||||
trunk func() string
|
trunk func() string
|
||||||
// now is the clock of the tier progress (tiers.go); nil is time.Now.
|
// now is the clock of the tier progress (tiers.go); nil is time.Now.
|
||||||
now func() time.Time
|
now func() time.Time
|
||||||
|
// releasedOf is the version released of module's build at fp, matched by the parts its build.ended made (world.releasedOf):
|
||||||
|
// a mover whose version was released before its pipeline passed gets its want at the pass (design 47 H2 H-A-490). nil
|
||||||
|
// matches none.
|
||||||
|
releasedOf func(module, fp string) (string, bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPipelineEnds(st endStore, wake func(), logf func(string, ...any)) *pipelineEnds {
|
func newPipelineEnds(st endStore, wake func(), logf func(string, ...any)) *pipelineEnds {
|
||||||
@@ -161,11 +171,25 @@ func newPipelineEnds(st endStore, wake func(), logf func(string, ...any)) *pipel
|
|||||||
// take keeps, for each mover of a passed pipeline that released a version, that version as the newest of its module on the
|
// take keeps, for each mover of a passed pipeline that released a version, that version as the newest of its module on the
|
||||||
// pipeline's branch, by compare-and-set on a newer version (design 47 H §750): an older version, or the same one again, writes
|
// pipeline's branch, by compare-and-set on a newer version (design 47 H §750): an older version, or the same one again, writes
|
||||||
// nothing. A passed mover with no version yet is said in the journal and taken when the runner says the end again naming it
|
// nothing. A passed mover with no version yet is said in the journal and taken when the runner says the end again naming it
|
||||||
// (H-A-270); it holds its tier in the pipeline's tier progress meanwhile (H-A-277 (1)). It says whether any key changed.
|
// (H-A-270); it holds its tier in the pipeline's tier progress meanwhile (H-A-277 (1)). A mover whose build's version was
|
||||||
|
// released before the pass is taken at the pass with that version (H-A-490). It says whether any key changed.
|
||||||
func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) {
|
func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) {
|
||||||
if p.Outcome != mpr.PipelineEndedOutcomePassed || p.Run != "" {
|
if p.Outcome != mpr.PipelineEndedOutcomePassed || p.Run != "" {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
// The pipeline's key is read by the one parse of the runner's seat's key forms (design 47 H2 H-A-485): a key it does not
|
||||||
|
// know is refused loudly, and nothing of the pipeline is kept, never an empty tier progress.
|
||||||
|
if _, err := pipelinekey.Parse(p.Pipeline); err != nil {
|
||||||
|
e.logf("the pipeline-ended of %s is refused, and none of its movers' versions is kept: %v", p.Pipeline, err)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
// Its sequence is its wants' run (design 47 H2 §813 (1), H-A-504 addendum): an end without one, of an older runner, is
|
||||||
|
// refused loudly and writes no want.
|
||||||
|
if p.Seq <= 0 {
|
||||||
|
e.logf("the pipeline-ended of %s is refused, and none of its movers' versions is kept: it carries no seq, the run its "+
|
||||||
|
"wants would carry (a runner older than H-A-504's addendum); the runner's end-again of %s, once it says seq, keeps them", p.Pipeline, p.Pipeline)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
changed := false
|
changed := false
|
||||||
var kept []tierMover
|
var kept []tierMover
|
||||||
versioned := map[string]bool{}
|
versioned := map[string]bool{}
|
||||||
@@ -178,6 +202,14 @@ func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) {
|
|||||||
if m.Fingerprint == "" || !moverPassed(m) {
|
if m.Fingerprint == "" || !moverPassed(m) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if m.Version == "" && e.releasedOf != nil {
|
||||||
|
// A version released before its pipeline passed (an again pipeline on a built, published key) is never written
|
||||||
|
// on the mover, nor its end said again: it is judged at the pass, matched by its build's parts (H-A-490).
|
||||||
|
if v, ok := e.releasedOf(m.Module, m.Fingerprint); ok {
|
||||||
|
e.logf("%s: %s passed; its version %s was released before the pass, taken now", p.Pipeline, m.Module, v)
|
||||||
|
m.Version = v
|
||||||
|
}
|
||||||
|
}
|
||||||
if m.Version == "" {
|
if m.Version == "" {
|
||||||
// The runner writes a mover's version at its release's version-released, and says this end again once it does
|
// The runner writes a mover's version at its release's version-released, and says this end again once it does
|
||||||
// (H-A-270 (1), (2)): the skip is said, never silent.
|
// (H-A-270 (1), (2)): the skip is said, never silent.
|
||||||
@@ -199,7 +231,7 @@ func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) {
|
|||||||
break // an older version, or this one again
|
break // an older version, or this one again
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
value, err := json.Marshal(End{Pipeline: p.Pipeline, Source: p.Source, Fp: m.Fingerprint, Version: m.Version, Rank: max(m.Tier, 1)})
|
value, err := json.Marshal(End{Pipeline: p.Pipeline, Source: p.Source, Seq: p.Seq, Fp: m.Fingerprint, Version: m.Version, Rank: max(m.Tier, 1)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return changed, err
|
return changed, err
|
||||||
}
|
}
|
||||||
@@ -216,6 +248,22 @@ func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) {
|
|||||||
return changed, nil
|
return changed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// noSeqOnce says, once per module and pipeline, that the end kept for module from pipeline carries no sequence and writes
|
||||||
|
// no want, naming the recovery (H-A-504 second addendum).
|
||||||
|
func (e *pipelineEnds) noSeqOnce(module, pipeline string) {
|
||||||
|
e.mu.Lock()
|
||||||
|
if e.noSeq == nil {
|
||||||
|
e.noSeq = map[string]bool{}
|
||||||
|
}
|
||||||
|
said := e.noSeq[module+" "+pipeline]
|
||||||
|
e.noSeq[module+" "+pipeline] = true
|
||||||
|
e.mu.Unlock()
|
||||||
|
if !said && e.logf != nil {
|
||||||
|
e.logf("no want of %s is written: its end kept from %s carries no seq, the run its want would carry (kept before "+
|
||||||
|
"H-A-504's addendum); the runner's end-again of %s, or %s's next pipeline, writes it", module, pipeline, pipeline, module)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// endOf is the end kept for module on branch: the newest version released there whose pipeline passed.
|
// endOf is the end kept for module on branch: the newest version released there whose pipeline passed.
|
||||||
func (e *pipelineEnds) endOf(module, branch string) (End, bool) {
|
func (e *pipelineEnds) endOf(module, branch string) (End, bool) {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
@@ -237,7 +285,13 @@ func (e *pipelineEnds) target(module, branch string) (assign.Target, bool) {
|
|||||||
if !ok || !e.tierWritten(end) {
|
if !ok || !e.tierWritten(end) {
|
||||||
return assign.Target{}, false
|
return assign.Target{}, false
|
||||||
}
|
}
|
||||||
return assign.Target{Fp: end.Fp, Version: end.Version, Pipeline: end.Pipeline, Rank: end.Rank}, true
|
if end.Seq <= 0 {
|
||||||
|
// An end kept before pipeline-ended carried its sequence has no run for its wants (design 47 H2 §813 (1), H-A-504
|
||||||
|
// second addendum): it writes no want, said once.
|
||||||
|
e.noSeqOnce(module, end.Pipeline)
|
||||||
|
return assign.Target{}, false
|
||||||
|
}
|
||||||
|
return assign.Target{Fp: end.Fp, Version: end.Version, Pipeline: end.Pipeline, Rank: end.Rank, Seq: end.Seq}, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// hearPipeline takes a pipeline-ended: a passed one's released versions are kept (take), and a run on request's drops the
|
// hearPipeline takes a pipeline-ended: a passed one's released versions are kept (take), and a run on request's drops the
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
|
||||||
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||||
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
mwc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient"
|
mwc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
@@ -67,9 +68,9 @@ func mover(module, fp, version string, tier int64, outcome string) mpr.MoverEnde
|
|||||||
Steps: []mpr.StepResult{{Step: "unit", Status: mpr.StepResultStatusRequired, Outcome: outcome, Module: module}}}
|
Steps: []mpr.StepResult{{Step: "unit", Status: mpr.StepResultStatusRequired, Outcome: outcome, Module: module}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ended is the pipeline-ended of the take-in of source on branch, its movers given.
|
// ended is the pipeline-ended of the take-in of source on branch, its movers given, its sequence 200 + source.
|
||||||
func ended(branch string, source int64, outcome string, movers ...mpr.MoverEnded) mpr.PipelineEnded {
|
func ended(branch string, source int64, outcome string, movers ...mpr.MoverEnded) mpr.PipelineEnded {
|
||||||
return mpr.PipelineEnded{V: 1, Branch: branch, Source: source, EndCount: 1, Outcome: outcome, Movers: movers,
|
return mpr.PipelineEnded{V: 1, Branch: branch, Source: source, Seq: 200 + source, EndCount: 1, Outcome: outcome, Movers: movers,
|
||||||
Pipeline: fmt.Sprintf("%s.%d", branch, source)}
|
Pipeline: fmt.Sprintf("%s.%d", branch, source)}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,17 +86,34 @@ func TestThePassedVersionIsKept(t *testing.T) {
|
|||||||
want *End // nil: none kept for web on main
|
want *End // nil: none kept for web on main
|
||||||
}{
|
}{
|
||||||
{"a passed pipeline keeps its version", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 2, ok))},
|
{"a passed pipeline keeps its version", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 2, ok))},
|
||||||
&End{Pipeline: "main.5", Source: 5, Fp: "fp1", Version: "0.1.2", Rank: 2}},
|
&End{Pipeline: "main.5", Source: 5, Seq: 205, Fp: "fp1", Version: "0.1.2", Rank: 2}},
|
||||||
{"nothing to run counts as passed", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, nothing))},
|
{"nothing to run counts as passed", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, nothing))},
|
||||||
&End{Pipeline: "main.5", Source: 5, Fp: "fp1", Version: "0.1.2", Rank: 1}},
|
&End{Pipeline: "main.5", Source: 5, Seq: 205, Fp: "fp1", Version: "0.1.2", Rank: 1}},
|
||||||
{"a failed pipeline keeps nothing, a passed mover in it neither", []mpr.PipelineEnded{ended("main", 5, fail, mover("web", "fp1", "0.1.2", 1, ok),
|
{"a failed pipeline keeps nothing, a passed mover in it neither", []mpr.PipelineEnded{ended("main", 5, fail, mover("web", "fp1", "0.1.2", 1, ok),
|
||||||
mover("db", "fp9", "0.3.0", 1, failed))}, nil},
|
mover("db", "fp9", "0.3.0", 1, failed))}, nil},
|
||||||
{"a mover whose required step failed keeps nothing", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, failed))}, nil},
|
{"a mover whose required step failed keeps nothing", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, failed))}, nil},
|
||||||
{"no version released keeps nothing", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "", 1, ok))}, nil},
|
{"no version released keeps nothing", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "", 1, ok))}, nil},
|
||||||
{"an older end heard after a newer one keeps the newer", []mpr.PipelineEnded{ended("main", 6, pass, mover("web", "fp2", "0.1.3", 1, ok)),
|
{"an older end heard after a newer one keeps the newer", []mpr.PipelineEnded{ended("main", 6, pass, mover("web", "fp2", "0.1.3", 1, ok)),
|
||||||
ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Fp: "fp2", Version: "0.1.3", Rank: 1}},
|
ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Seq: 206, Fp: "fp2", Version: "0.1.3", Rank: 1}},
|
||||||
{"a newer version replaces", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok)),
|
{"a newer version replaces", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok)),
|
||||||
ended("main", 6, pass, mover("web", "fp2", "0.1.10", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Fp: "fp2", Version: "0.1.10", Rank: 1}},
|
ended("main", 6, pass, mover("web", "fp2", "0.1.10", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Seq: 206, Fp: "fp2", Version: "0.1.10", Rank: 1}},
|
||||||
|
// H-A-485: an again pipeline's end is kept as a take-in's; a key of no form the runner's seat defines is refused, nothing kept.
|
||||||
|
{"an again pipeline keeps its version", []mpr.PipelineEnded{func() mpr.PipelineEnded {
|
||||||
|
p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 2, ok))
|
||||||
|
p.Pipeline = "main.5.again.2"
|
||||||
|
return p
|
||||||
|
}()}, &End{Pipeline: "main.5.again.2", Source: 5, Seq: 205, Fp: "fp1", Version: "0.1.2", Rank: 2}},
|
||||||
|
{"a key of no form is refused", []mpr.PipelineEnded{func() mpr.PipelineEnded {
|
||||||
|
p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 2, ok))
|
||||||
|
p.Pipeline = "main.5.later.2"
|
||||||
|
return p
|
||||||
|
}()}, nil},
|
||||||
|
// H-A-504 addendum: an end without its sequence, of an older runner, is refused and keeps nothing.
|
||||||
|
{"an end without seq keeps nothing", []mpr.PipelineEnded{func() mpr.PipelineEnded {
|
||||||
|
p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok))
|
||||||
|
p.Seq = 0
|
||||||
|
return p
|
||||||
|
}()}, nil},
|
||||||
{"a run on request keeps nothing", []mpr.PipelineEnded{func() mpr.PipelineEnded {
|
{"a run on request keeps nothing", []mpr.PipelineEnded{func() mpr.PipelineEnded {
|
||||||
p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok))
|
p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok))
|
||||||
p.Run = "r1"
|
p.Run = "r1"
|
||||||
@@ -109,6 +127,9 @@ func TestThePassedVersionIsKept(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
got, kept := e.endOf("web", "main")
|
got, kept := e.endOf("web", "main")
|
||||||
|
if ks, _ := e.st.keys(); c.name == "a key of no form is refused" && len(ks) != 0 {
|
||||||
|
t.Errorf("%s: the state written holds %v, want nothing (no empty tier progress)", c.name, ks)
|
||||||
|
}
|
||||||
switch {
|
switch {
|
||||||
case c.want == nil && kept:
|
case c.want == nil && kept:
|
||||||
t.Errorf("%s: kept %+v", c.name, got)
|
t.Errorf("%s: kept %+v", c.name, got)
|
||||||
@@ -142,10 +163,15 @@ func TestThePassedVersionIsKept(t *testing.T) {
|
|||||||
// A6/AC1, A5/AC1 (design 47 H §750): a pass writes, on every node the module is assigned to, the want naming the newest version
|
// A6/AC1, A5/AC1 (design 47 H §750): a pass writes, on every node the module is assigned to, the want naming the newest version
|
||||||
// released on its branch whose pipeline passed, with the pipeline and the rank; with none passed it writes none. No grant,
|
// released on its branch whose pipeline passed, with the pipeline and the rank; with none passed it writes none. No grant,
|
||||||
// canary, provider or composition is asked for. H-A-270 (1): a passed end whose mover names no version yet writes no want and
|
// canary, provider or composition is asked for. H-A-270 (1): a passed end whose mover names no version yet writes no want and
|
||||||
// says so in the journal; the same end said again naming the version writes it.
|
// says so in the journal; the same end said again naming the version writes it. H-A-490: a version released before its pipeline
|
||||||
|
// passed (an again pipeline on a built, published key) gets its want at the pass, matched to the mover's build by its parts.
|
||||||
func TestAPassWritesTheWantOfThePassedVersion(t *testing.T) {
|
func TestAPassWritesTheWantOfThePassedVersion(t *testing.T) {
|
||||||
fp := meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64)
|
fp := meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64)
|
||||||
for _, passed := range []bool{false, true} {
|
for _, c := range []struct {
|
||||||
|
name string
|
||||||
|
passed, releasedBefore bool
|
||||||
|
}{{"no pipeline passed", false, false}, {"passed, then its version released", true, false}, {"released, then its pipeline passed", true, true}} {
|
||||||
|
passed := c.passed
|
||||||
wantsKV := &memKV{values: map[string][]byte{}}
|
wantsKV := &memKV{values: map[string][]byte{}}
|
||||||
p := newPasser(kvSet{buckets.Wants(): wantsKV, buckets.Asks(): &memKV{values: map[string][]byte{}}}, time.Now())
|
p := newPasser(kvSet{buckets.Wants(): wantsKV, buckets.Asks(): &memKV{values: map[string][]byte{}}}, time.Now())
|
||||||
p.say = func(oc.Condition) error { return nil }
|
p.say = func(oc.Condition) error { return nil }
|
||||||
@@ -158,7 +184,16 @@ func TestAPassWritesTheWantOfThePassedVersion(t *testing.T) {
|
|||||||
var journal []string
|
var journal []string
|
||||||
p.ends = newPipelineEnds(newMemEnds(), func() {}, func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) })
|
p.ends = newPipelineEnds(newMemEnds(), func() {}, func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) })
|
||||||
p.ends.trunk = p.w.trunkName
|
p.ends.trunk = p.w.trunkName
|
||||||
if passed {
|
p.ends.releasedOf = p.w.releasedOf
|
||||||
|
if c.releasedBefore {
|
||||||
|
// Built and released in an earlier pipeline that failed: the runner's again pipeline ends naming no version.
|
||||||
|
rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "web", Source: 4, Version: "0.1.2", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "web:image", Digest: "sha256:7"}}})
|
||||||
|
built, _ := json.Marshal(builds.BuildEnded{Module: "web", Fingerprint: fp, Outcome: builds.BuildDone, Made: map[string]string{"image": "sha256:7"}})
|
||||||
|
if err := p.w.released.put(rel); err != nil || p.w.ends.put(built) != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
_, _ = p.ends.take(ended(trunkBranch, 5, mpr.PipelineEndedOutcomePassed, mover("web", fp, "", 2, mpr.StepResultOutcomePassed)))
|
||||||
|
} else if passed {
|
||||||
_, _ = p.ends.take(ended(trunkBranch, 5, mpr.PipelineEndedOutcomePassed, mover("web", fp, "", 2, mpr.StepResultOutcomePassed)))
|
_, _ = p.ends.take(ended(trunkBranch, 5, mpr.PipelineEndedOutcomePassed, mover("web", fp, "", 2, mpr.StepResultOutcomePassed)))
|
||||||
p.wants(context.Background())
|
p.wants(context.Background())
|
||||||
if len(wantsKV.values) != 0 || !slices.Contains(journal, trunkBranch+".5: web passed with no version yet: taken again when its version is written") {
|
if len(wantsKV.values) != 0 || !slices.Contains(journal, trunkBranch+".5: web passed with no version yet: taken again when its version is written") {
|
||||||
@@ -171,14 +206,14 @@ func TestAPassWritesTheWantOfThePassedVersion(t *testing.T) {
|
|||||||
key, _ := mwc.WantKey(node, "web")
|
key, _ := mwc.WantKey(node, "web")
|
||||||
raw, got := wantsKV.values[key]
|
raw, got := wantsKV.values[key]
|
||||||
if got != passed {
|
if got != passed {
|
||||||
t.Errorf("passed %v: a want on %s written = %v", passed, node, got)
|
t.Errorf("%s: a want on %s written = %v", c.name, node, got)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !passed {
|
if !passed {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if w, err := mwc.DecodeWant(raw); err != nil || w.Fp != fp || w.Version != "0.1.2" || w.Pipeline != trunkBranch+".5" || w.Rank != 2 {
|
if w, err := mwc.DecodeWant(raw); err != nil || w.Fp != fp || w.Version != "0.1.2" || w.Pipeline != trunkBranch+".5" || w.Rank != 2 || w.Run != "205" {
|
||||||
t.Errorf("the want on %s = %+v (%v)", node, w, err)
|
t.Errorf("%s: the want on %s = %+v (%v)", c.name, node, w, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,8 +241,25 @@ func TestARegistrationNamesTheDefaultBranch(t *testing.T) {
|
|||||||
if woken == 0 || endsKept() != 1 || e.branchOf("web", "") != "beta" || e.branchOf("other", "") != trunkBranch {
|
if woken == 0 || endsKept() != 1 || e.branchOf("web", "") != "beta" || e.branchOf("other", "") != trunkBranch {
|
||||||
t.Errorf("ends kept %d, default branch %q: an unwatched branch's end stayed, or the default is wrong", endsKept(), e.branchOf("web", ""))
|
t.Errorf("ends kept %d, default branch %q: an unwatched branch's end stayed, or the default is wrong", endsKept(), e.branchOf("web", ""))
|
||||||
}
|
}
|
||||||
if tg, ok := e.target("web", ""); !ok || tg.Fp != "fp2" {
|
if tg, ok := e.target("web", ""); !ok || tg.Fp != "fp2" || tg.Seq != 205 {
|
||||||
t.Errorf("the default branch's target = %+v %v", tg, ok)
|
t.Errorf("the default branch's target = %+v %v, want fp2 at seq 205", tg, ok)
|
||||||
|
}
|
||||||
|
// H-A-504 second addendum: an end kept without a sequence (before pipeline-ended said it) writes no want, said once.
|
||||||
|
raw, rev, _ := st.get(endKey("web", "beta"))
|
||||||
|
var old End
|
||||||
|
_ = json.Unmarshal(raw, &old)
|
||||||
|
old.Seq = 0
|
||||||
|
raw, _ = json.Marshal(old)
|
||||||
|
_ = st.swap(endKey("web", "beta"), raw, rev)
|
||||||
|
var said []string
|
||||||
|
e.logf = func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) }
|
||||||
|
for range 2 {
|
||||||
|
if tg, ok := e.target("web", ""); ok {
|
||||||
|
t.Errorf("an end kept without seq is the target %+v", tg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(said) != 1 || !strings.Contains(said[0], "beta.5") || !strings.Contains(said[0], "end-again") {
|
||||||
|
t.Errorf("an end kept without seq said %q, want once, naming the pipeline and end-again", said)
|
||||||
}
|
}
|
||||||
e.registered(mpcat.Registration{Module: "web"}, true)
|
e.registered(mpcat.Registration{Module: "web"}, true)
|
||||||
if endsKept() != 0 {
|
if endsKept() != 0 {
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ func newOrderFixture(t *testing.T, mods []orderMod, history ...map[string]string
|
|||||||
_, _ = p.ends.take(ended(trunkBranch, 1, mpr.PipelineEndedOutcomePassed, mover(m.name, m.trunk, "0.1.1", 1, mpr.StepResultOutcomePassed)))
|
_, _ = p.ends.take(ended(trunkBranch, 1, mpr.PipelineEndedOutcomePassed, mover(m.name, m.trunk, "0.1.1", 1, mpr.StepResultOutcomePassed)))
|
||||||
wkey, _ := mwc.WantKey("ace", m.name)
|
wkey, _ := mwc.WantKey("ace", m.name)
|
||||||
old, _ := mwc.EncodeWant(mwc.Want{Fp: m.run, Self: true})
|
old, _ := mwc.EncodeWant(mwc.Want{Fp: m.run, Self: true})
|
||||||
p.w.put(buckets.Wants(), wkey, old)
|
|
||||||
f.wants.values[wkey] = old
|
f.wants.values[wkey] = old
|
||||||
|
p.w.putEntry(buckets.Wants(), wkey, old, f.wants.revision(wkey), time.Now()) // as the watch hands it, with its revision
|
||||||
}
|
}
|
||||||
composes(t, p.w, "ace", digest)
|
composes(t, p.w, "ace", digest)
|
||||||
values, err := mmac.AssignmentsValues(pl)
|
values, err := mmac.AssignmentsValues(pl)
|
||||||
|
|||||||
@@ -181,6 +181,7 @@ func (p *passer) putWorld(node, module string, put puts.Put, manifest catalogue.
|
|||||||
if e, ok := p.w.ends.endOf(module, put.FP); ok { // the build's end heard (A-181): none heard, no state
|
if e, ok := p.w.ends.endOf(module, put.FP); ok { // the build's end heard (A-181): none heard, no state
|
||||||
w.Build, w.BuildWords = e.Outcome, e.Error
|
w.Build, w.BuildWords = e.Outcome, e.Error
|
||||||
}
|
}
|
||||||
|
w.Version, _ = p.w.releasedOf(module, put.FP) // matched by its build's parts, as the pass matches a mover's (H-A-490 addendum)
|
||||||
w.Composed, w.Granted = p.composedFor(node, module, put.FP)
|
w.Composed, w.Granted = p.composedFor(node, module, put.FP)
|
||||||
if d := w.Composed; d != nil {
|
if d := w.Composed; d != nil {
|
||||||
policy := d.Policy
|
policy := d.Policy
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
||||||
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/pipelinekey"
|
||||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||||
"git.novox.be/novox/mesh-sdk/go/views"
|
"git.novox.be/novox/mesh-sdk/go/views"
|
||||||
|
|
||||||
@@ -58,10 +60,16 @@ type tierProgress struct {
|
|||||||
// tierKey is the key of pipeline's tier progress; pipeline is the runner's key `<branch>.<source>`, its branch escaped.
|
// tierKey is the key of pipeline's tier progress; pipeline is the runner's key `<branch>.<source>`, its branch escaped.
|
||||||
func tierKey(pipeline string) string { return tierPrefix + pipeline }
|
func tierKey(pipeline string) string { return tierPrefix + pipeline }
|
||||||
|
|
||||||
// isTierKey says whether a key of the state written is a pipeline's tier progress: three parts, the first `pipeline` (a module's
|
// isTierKey says whether a key of the state written is a pipeline's tier progress: `pipeline.` and a pipeline's key of any form
|
||||||
// end has two).
|
// the runner's seat defines, read by the one parse (design 47 H2 H-A-485), so an again pipeline's progress is one as a take-in's
|
||||||
|
// is (a module's end, `<module>.<branch>`, is none).
|
||||||
func isTierKey(key string) bool {
|
func isTierKey(key string) bool {
|
||||||
return strings.HasPrefix(key, tierPrefix) && strings.Count(key, ".") == 2
|
rest, ok := strings.CutPrefix(key, tierPrefix)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
_, err := pipelinekey.Parse(rest)
|
||||||
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// startTiers writes the tier progress of a passed pipeline, holding every passed mover, versioned or not, its first tier the
|
// startTiers writes the tier progress of a passed pipeline, holding every passed mover, versioned or not, its first tier the
|
||||||
@@ -166,11 +174,11 @@ func (p *passer) tiers(n assign.Nodes, placedOn func(module, branch string) []st
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pipeline := strings.TrimPrefix(key, tierPrefix)
|
pipeline := strings.TrimPrefix(key, tierPrefix)
|
||||||
branchEsc, number, _ := strings.Cut(pipeline, ".")
|
pk, err := pipelinekey.Parse(pipeline)
|
||||||
branch, err := keys.UnescapeName(branchEsc)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
branch, number := pk.Branch, strconv.FormatInt(pk.Revision, 10)
|
||||||
for {
|
for {
|
||||||
t, rev, ok := p.ends.tiersOf(pipeline)
|
t, rev, ok := p.ends.tiersOf(pipeline)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -28,7 +28,12 @@ import (
|
|||||||
// tier-bound: the finding tier-late names it and its machine, pipeline-wanted says tier-late, and no consumer want is written.
|
// tier-bound: the finding tier-late names it and its machine, pipeline-wanted says tier-late, and no consumer want is written.
|
||||||
func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
||||||
db, web := meshcatalogclient.SourcePrefix2+strings.Repeat("d", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("c", 64)
|
db, web := meshcatalogclient.SourcePrefix2+strings.Repeat("d", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("c", 64)
|
||||||
for _, runs := range []bool{true, false} {
|
// H-A-485: a pipeline started again at the head, keyed `<branch>.<revision>.again.<n>`, moves tier by tier as a take-in's does.
|
||||||
|
for _, c := range []struct {
|
||||||
|
runs bool
|
||||||
|
pipeline string
|
||||||
|
}{{true, trunkBranch + ".5"}, {false, trunkBranch + ".5"}, {true, trunkBranch + ".5.again.2"}, {false, trunkBranch + ".5.again.2"}} {
|
||||||
|
runs, pipeline := c.runs, c.pipeline
|
||||||
start := time.Date(2026, 11, 20, 4, 0, 0, 0, time.UTC)
|
start := time.Date(2026, 11, 20, 4, 0, 0, 0, time.UTC)
|
||||||
now := start
|
now := start
|
||||||
wantsKV := &memKV{values: map[string][]byte{}}
|
wantsKV := &memKV{values: map[string][]byte{}}
|
||||||
@@ -41,7 +46,7 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
|||||||
var said []meshwants.PipelineWanted
|
var said []meshwants.PipelineWanted
|
||||||
p.publishWants = func(event string, body any, _ string) error {
|
p.publishWants = func(event string, body any, _ string) error {
|
||||||
if b, ok := body.(meshwants.PipelineWantedEvent); ok {
|
if b, ok := body.(meshwants.PipelineWantedEvent); ok {
|
||||||
if event != "pipeline-wanted."+trunkBranch+".5" {
|
if event != "pipeline-wanted."+pipeline {
|
||||||
t.Errorf("pipeline-wanted said as %s", event)
|
t.Errorf("pipeline-wanted said as %s", event)
|
||||||
}
|
}
|
||||||
said = append(said, b)
|
said = append(said, b)
|
||||||
@@ -65,7 +70,7 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
|||||||
// The pipeline of revision 5 (its key's number) of source 4: a re-pin's revision (H-A-213, H-A-216).
|
// The pipeline of revision 5 (its key's number) of source 4: a re-pin's revision (H-A-213, H-A-216).
|
||||||
e := ended(trunkBranch, 5, mpr.PipelineEndedOutcomePassed, mover("db", db, "0.2.0", 1, mpr.StepResultOutcomePassed),
|
e := ended(trunkBranch, 5, mpr.PipelineEndedOutcomePassed, mover("db", db, "0.2.0", 1, mpr.StepResultOutcomePassed),
|
||||||
mover("web", web, "0.1.2", 2, mpr.StepResultOutcomePassed))
|
mover("web", web, "0.1.2", 2, mpr.StepResultOutcomePassed))
|
||||||
e.Source = 4
|
e.Source, e.Pipeline = 4, pipeline
|
||||||
if _, err := p.ends.take(e); err != nil {
|
if _, err := p.ends.take(e); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -76,7 +81,7 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
|||||||
}
|
}
|
||||||
p.wants(context.Background())
|
p.wants(context.Background())
|
||||||
if !wanted("g14", "db") || !wanted("ace", "db") || wanted("g14", "web") || wanted("ace", "web") {
|
if !wanted("g14", "db") || !wanted("ace", "db") || wanted("g14", "web") || wanted("ace", "web") {
|
||||||
t.Fatalf("runs %v: tier 1 alone is not what is wanted first: %v", runs, wantsKV.values)
|
t.Fatalf("%s runs %v: tier 1 alone is not what is wanted first: %v", pipeline, runs, wantsKV.values)
|
||||||
}
|
}
|
||||||
if runs {
|
if runs {
|
||||||
raw, _ := json.Marshal(nodeengine.Running{Node: "g14", Module: "db", Fingerprint: db})
|
raw, _ := json.Marshal(nodeengine.Running{Node: "g14", Module: "db", Fingerprint: db})
|
||||||
@@ -86,15 +91,15 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
|||||||
now = start.Add(time.Minute)
|
now = start.Add(time.Minute)
|
||||||
p.wants(context.Background())
|
p.wants(context.Background())
|
||||||
if !wanted("g14", "web") || !wanted("ace", "web") {
|
if !wanted("g14", "web") || !wanted("ace", "web") {
|
||||||
t.Fatalf("the consumer's want is not written once its provider runs: %v", wantsKV.values)
|
t.Fatalf("%s: the consumer's want is not written once its provider runs: %v", pipeline, wantsKV.values)
|
||||||
}
|
}
|
||||||
raw, _ = json.Marshal(nodeengine.Running{Node: "g14", Module: "web", Fingerprint: web})
|
raw, _ = json.Marshal(nodeengine.Running{Node: "g14", Module: "web", Fingerprint: web})
|
||||||
_ = p.w.hearRunning("running.g14.web", raw)
|
_ = p.w.hearRunning("running.g14.web", raw)
|
||||||
p.wants(context.Background())
|
p.wants(context.Background())
|
||||||
if len(said) != 1 || said[0].Outcome != meshwants.PipelineWantedOutcomeRunning || said[0].Revision != 5 || said[0].Source != 4 || len(findings) != 0 {
|
if len(said) != 1 || said[0].Outcome != meshwants.PipelineWantedOutcomeRunning || said[0].Revision != 5 || said[0].Source != 4 || len(findings) != 0 {
|
||||||
t.Errorf("every tier runs: said %+v, findings %v", said, findings)
|
t.Errorf("%s: every tier runs: said %+v, findings %v", pipeline, said, findings)
|
||||||
}
|
}
|
||||||
if _, _, ok := p.ends.tiersOf(trunkBranch + ".5"); ok {
|
if _, _, ok := p.ends.tiersOf(pipeline); ok {
|
||||||
t.Error("the tier progress stands after every tier ran")
|
t.Error("the tier progress stands after every tier ran")
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -107,7 +112,7 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
|||||||
now = start.Add(30 * time.Minute)
|
now = start.Add(30 * time.Minute)
|
||||||
p.wants(context.Background())
|
p.wants(context.Background())
|
||||||
p.wants(context.Background())
|
p.wants(context.Background())
|
||||||
f, ok := findings["delivery."+assign.KeyID(trunkBranch+".5")+".tier-late"]
|
f, ok := findings["delivery."+assign.KeyID(pipeline)+".tier-late"]
|
||||||
if !ok || !strings.Contains(f.Summary, "db on g14") || strings.Contains(f.Summary, "ace") {
|
if !ok || !strings.Contains(f.Summary, "db on g14") || strings.Contains(f.Summary, "ace") {
|
||||||
t.Errorf("tier-late is not raised naming db on g14 alone: %v", findings)
|
t.Errorf("tier-late is not raised naming db on g14 alone: %v", findings)
|
||||||
}
|
}
|
||||||
@@ -116,7 +121,7 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) {
|
|||||||
t.Errorf("pipeline-wanted tier-late is not said once, naming revision 5 of source 4: %+v", said)
|
t.Errorf("pipeline-wanted tier-late is not said once, naming revision 5 of source 4: %+v", said)
|
||||||
}
|
}
|
||||||
// A tier progress kept before it held its source says the key's number as both (H-A-216).
|
// A tier progress kept before it held its source says the key's number as both (H-A-216).
|
||||||
p.sayPipelineWanted(trunkBranch+".5", trunkBranch, "5", 0, meshwants.PipelineWantedOutcomeRunning, nil)
|
p.sayPipelineWanted(pipeline, trunkBranch, "5", 0, meshwants.PipelineWantedOutcomeRunning, nil)
|
||||||
if len(said) != 2 || said[1].Revision != 5 || said[1].Source != 5 {
|
if len(said) != 2 || said[1].Revision != 5 || said[1].Source != 5 {
|
||||||
t.Errorf("a progress with no source: said %+v, want revision and source 5", said)
|
t.Errorf("a progress with no source: said %+v, want revision and source 5", said)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -417,6 +417,7 @@ func serveTools() error {
|
|||||||
tools = append(tools, whyTools(runtimeStore{})...)
|
tools = append(tools, whyTools(runtimeStore{})...)
|
||||||
tools = append(tools, askAgainTools(runtimeStore{}, stdio.Ask, time.Now)...)
|
tools = append(tools, askAgainTools(runtimeStore{}, stdio.Ask, time.Now)...)
|
||||||
tools = append(tools, wantDropTools(runtimeStore{}, stdio.Ask)...)
|
tools = append(tools, wantDropTools(runtimeStore{}, stdio.Ask)...)
|
||||||
|
tools = append(tools, assignmentDropTools(runtimeStore{}, stdio.Ask, watchedModules(stdio.Ask))...) // a retired module's assignment key (H-A-509)
|
||||||
tools = append(tools, asksTools(stdio.QueueWaiting, stdio.State(process.TakenState), stdio.Ask)...) // the seat's work queue (§777)
|
tools = append(tools, asksTools(stdio.QueueWaiting, stdio.State(process.TakenState), stdio.Ask)...) // the seat's work queue (§777)
|
||||||
tools = append(tools, keepNowTools(stdio.Ask)...)
|
tools = append(tools, keepNowTools(stdio.Ask)...)
|
||||||
tools = append(tools, validateBeforeTools(runtimeStore{})...) // what a validate step did not count (§814) // the keeping by hand (§813 (2))
|
tools = append(tools, validateBeforeTools(runtimeStore{})...) // what a validate step did not count (§814) // the keeping by hand (§813 (2))
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ type PutWorld struct {
|
|||||||
Build, BuildWords string
|
Build, BuildWords string
|
||||||
// Newest is the module's newest fingerprint at the trunk, which the builder builds by itself.
|
// Newest is the module's newest fingerprint at the trunk, which the builder builds by itself.
|
||||||
Newest string
|
Newest string
|
||||||
|
// Version is the version released at the put's fingerprint, matched by its build's parts as the pass matches a mover's;
|
||||||
|
// "" when none is released (design 47 H2 H-A-490 addendum).
|
||||||
|
Version string
|
||||||
// Composed is the composition of the module for the node at the fingerprint, as its writer holds it; nil when there is
|
// Composed is the composition of the module for the node at the fingerprint, as its writer holds it; nil when there is
|
||||||
// none. Granted says the grant at the fingerprint names the node's accounts. Both are read, never asked for (clause 4).
|
// none. Granted says the grant at the fingerprint names the node's accounts. Both are read, never asked for (clause 4).
|
||||||
Composed *ComposedDigest
|
Composed *ComposedDigest
|
||||||
@@ -87,7 +90,10 @@ func StepPut(w PutWorld) PutNext {
|
|||||||
if h := w.Have; h == nil || h.Fp != p.FP || h.Composed == "" {
|
if h := w.Have; h == nil || h.Fp != p.FP || h.Composed == "" {
|
||||||
return say(puts.Refused, "%s runs %s at %s, and its have names no composition at that fingerprint, so the want cannot name what runs", w.Node, w.Module, fp)
|
return say(puts.Refused, "%s runs %s at %s, and its have names no composition at that fingerprint, so the want cannot name what runs", w.Node, w.Module, fp)
|
||||||
}
|
}
|
||||||
p.Composed = w.Have.Composed
|
if w.Version == "" {
|
||||||
|
return say(puts.Refused, "no version released at %s: build or release it first", fp)
|
||||||
|
}
|
||||||
|
p.Composed, p.Version = w.Have.Composed, w.Version
|
||||||
words := fmt.Sprintf("the want of %s on %s names %s, the build it runs now (composition %s), from its running statement; the builder's store is not asked",
|
words := fmt.Sprintf("the want of %s on %s names %s, the build it runs now (composition %s), from its running statement; the builder's store is not asked",
|
||||||
w.Module, w.Node, fp, short(p.Composed))
|
w.Module, w.Node, fp, short(p.Composed))
|
||||||
if p.Hold {
|
if p.Hold {
|
||||||
@@ -115,6 +121,14 @@ func StepPut(w PutWorld) PutNext {
|
|||||||
default:
|
default:
|
||||||
return say(puts.Build, "waits for the builder's build of %s at %s, which is %s", w.Module, fp, w.Build)
|
return say(puts.Build, "waits for the builder's build of %s at %s, which is %s", w.Module, fp, w.Build)
|
||||||
}
|
}
|
||||||
|
if p.Step != puts.Wanted && p.Step != puts.Holding {
|
||||||
|
// The want names the build's released version beside its fingerprint, which the node-engine composes from (H-A-490
|
||||||
|
// addendum): a build with none released is refused, never wanted by its fingerprint alone.
|
||||||
|
if w.Version == "" {
|
||||||
|
return say(puts.Refused, "no version released at %s: build or release it first", fp)
|
||||||
|
}
|
||||||
|
p.Version = w.Version
|
||||||
|
}
|
||||||
if w.Composed == nil || !w.Granted {
|
if w.Composed == nil || !w.Granted {
|
||||||
missing := fmt.Sprintf("no composition of %s for %s at %s is written", w.Module, w.Node, fp)
|
missing := fmt.Sprintf("no composition of %s for %s at %s is written", w.Module, w.Node, fp)
|
||||||
if w.Composed != nil {
|
if w.Composed != nil {
|
||||||
@@ -212,9 +226,10 @@ func needsPerson(w PutWorld, d ComposedDigest) bool {
|
|||||||
return d.Judgement == JudgedRecreates || d.Judgement == JudgedMovesData || d.Judgement == JudgedCannot
|
return d.Judgement == JudgedRecreates || d.Judgement == JudgedMovesData || d.Judgement == JudgedCannot
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutWant is the want a put writes once it is wanted: the fingerprint, marked put, and held when it holds.
|
// PutWant is the want a put writes once it is wanted: the fingerprint and the version released at it, marked put, and held when
|
||||||
|
// it holds.
|
||||||
func PutWant(p puts.Put) mwc.Want {
|
func PutWant(p puts.Put) mwc.Want {
|
||||||
return mwc.Want{Fp: p.FP, Put: true, Hold: p.Hold, Words: "put: " + p.Why}
|
return mwc.Want{Fp: p.FP, Version: p.Version, Put: true, Hold: p.Hold, Words: "put: " + p.Why}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PutOwns says what a put does to the node's want: owns says the rules pass over it, want the want it writes (nil: what
|
// PutOwns says what a put does to the node's want: owns says the rules pass over it, want the want it writes (nil: what
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package assign
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
||||||
@@ -28,6 +29,9 @@ type Target struct {
|
|||||||
Version string
|
Version string
|
||||||
Pipeline string
|
Pipeline string
|
||||||
Rank int64
|
Rank int64
|
||||||
|
// Seq is the pipeline's sequence, the want's run in decimal (design 47 H2 §813 (1), H-A-504 addendum); 0 for a placement's
|
||||||
|
// build.
|
||||||
|
Seq int64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Module is what the want rule reads of one module: the nodes it is assigned to, the build each node's want names, the puts
|
// Module is what the want rule reads of one module: the nodes it is assigned to, the build each node's want names, the puts
|
||||||
@@ -105,7 +109,7 @@ func Wants(m Module, wants map[string]mwc.Want) Outcome {
|
|||||||
if !put && had && before.Put && before.Hold {
|
if !put && had && before.Put && before.Hold {
|
||||||
// The want is the truth (ADR 0546 clause 5): a want marked put and held stands while its put is not heard; only a put
|
// The want is the truth (ADR 0546 clause 5): a want marked put and held stands while its put is not heard; only a put
|
||||||
// heard released gives it back to the rule.
|
// heard released gives it back to the rule.
|
||||||
p, put = puts.Put{FP: before.Fp, Hold: true, Why: strings.TrimPrefix(before.Words, "put: "), Step: puts.Holding}, true
|
p, put = puts.Put{FP: before.Fp, Version: before.Version, Hold: true, Why: strings.TrimPrefix(before.Words, "put: "), Step: puts.Holding}, true
|
||||||
}
|
}
|
||||||
if put {
|
if put {
|
||||||
if want, owns := PutOwns(p); owns {
|
if want, owns := PutOwns(p); owns {
|
||||||
@@ -123,6 +127,9 @@ func Wants(m Module, wants map[string]mwc.Want) Outcome {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
next := mwc.Want{Fp: t.Fp, Version: t.Version, Pipeline: t.Pipeline, Rank: t.Rank, Self: m.selfOn(node)}
|
next := mwc.Want{Fp: t.Fp, Version: t.Version, Pipeline: t.Pipeline, Rank: t.Rank, Self: m.selfOn(node)}
|
||||||
|
if t.Seq > 0 {
|
||||||
|
next.Run = strconv.FormatInt(t.Seq, 10)
|
||||||
|
}
|
||||||
if had && !before.Removed && !before.Put && before.Fp == t.Fp {
|
if had && !before.Removed && !before.Put && before.Fp == t.Fp {
|
||||||
// The answers the want carries stay while its build does: a failed backup's (ADR 0539 §16), a held revert's, the yes.
|
// The answers the want carries stay while its build does: a failed backup's (ADR 0539 §16), a held revert's, the yes.
|
||||||
next.Backup, next.Words, next.Revert, next.Yes, next.Release = before.Backup, before.Words, before.Revert, before.Yes, before.Release
|
next.Backup, next.Words, next.Revert, next.Yes, next.Release = before.Backup, before.Words, before.Revert, before.Yes, before.Release
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ func TestAWantNamesTheNewestPassedVersion(t *testing.T) {
|
|||||||
// want stands, marked put and held, and once released the rule writes the passed version again.
|
// want stands, marked put and held, and once released the rule writes the passed version again.
|
||||||
func TestAPutOwnsItsNodesWant(t *testing.T) {
|
func TestAPutOwnsItsNodesWant(t *testing.T) {
|
||||||
m := released()
|
m := released()
|
||||||
put := puts.Put{FP: fNew, Hold: true, Why: "the bus's user list", Composed: dig(fNew)}
|
put := puts.Put{FP: fNew, Version: "1.2.3", Hold: true, Why: "the bus's user list", Composed: dig(fNew)}
|
||||||
for _, c := range []struct {
|
for _, c := range []struct {
|
||||||
name string
|
name string
|
||||||
step string
|
step string
|
||||||
@@ -100,7 +100,7 @@ func TestAPutOwnsItsNodesWant(t *testing.T) {
|
|||||||
want *mwc.Want // nil: nothing written on ace
|
want *mwc.Want // nil: nothing written on ace
|
||||||
}{
|
}{
|
||||||
{"waiting for the operator", puts.Person, wantedOld(), nil},
|
{"waiting for the operator", puts.Person, wantedOld(), nil},
|
||||||
{"wanted", puts.Wanted, wantedOld(), &mwc.Want{Fp: fNew, Put: true, Hold: true, Words: "put: the bus's user list"}},
|
{"wanted", puts.Wanted, wantedOld(), &mwc.Want{Fp: fNew, Version: "1.2.3", Put: true, Hold: true, Words: "put: the bus's user list"}},
|
||||||
{"holding, written already", puts.Holding, map[string]mwc.Want{"ace": PutWant(put)}, nil},
|
{"holding, written already", puts.Holding, map[string]mwc.Want{"ace": PutWant(put)}, nil},
|
||||||
{"released: the rule again", puts.Released, map[string]mwc.Want{"ace": PutWant(put)}, &mwc.Want{Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2}},
|
{"released: the rule again", puts.Released, map[string]mwc.Want{"ace": PutWant(put)}, &mwc.Want{Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2}},
|
||||||
{"not heard: a held want at an older fingerprint stands", "", map[string]mwc.Want{"ace": {Fp: fOld, Put: true, Hold: true, Words: "put: back"}}, nil},
|
{"not heard: a held want at an older fingerprint stands", "", map[string]mwc.Want{"ace": {Fp: fOld, Put: true, Hold: true, Words: "put: back"}}, nil},
|
||||||
@@ -144,7 +144,7 @@ func stepsOfAPut(t *testing.T) {
|
|||||||
running := nodeengine.HaveByNodeModuleValue{Fp: fOld, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}
|
running := nodeengine.HaveByNodeModuleValue{Fp: fOld, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}
|
||||||
bus := func() PutWorld {
|
bus := func() PutWorld {
|
||||||
return PutWorld{Node: "novox", Module: "nats", Put: base, Assigned: true, Bus: true, Build: builds.BuildDone, Newest: fNew,
|
return PutWorld{Node: "novox", Module: "nats", Put: base, Assigned: true, Bus: true, Build: builds.BuildDone, Newest: fNew,
|
||||||
Composed: &d, Granted: true, Have: &running, Now: now}
|
Version: "1.2.3", Composed: &d, Granted: true, Have: &running, Now: now}
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -172,6 +172,16 @@ func stepsOfAPut(t *testing.T) {
|
|||||||
w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew}
|
w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew}
|
||||||
return w
|
return w
|
||||||
}, puts.Refused, "names no composition", false, false, false},
|
}, puts.Refused, "names no composition", false, false, false},
|
||||||
|
// H-A-490 (addendum): a want names the build's released version, so a done build with none released is refused, and so
|
||||||
|
// is the build the node runs now when no release names its parts.
|
||||||
|
{"a done build with no released version: refused", func() PutWorld { w := bus(); w.Version = ""; return w }, puts.Refused, "no version released at", false, false, false},
|
||||||
|
{"the build the node runs now, no version released: refused", func() PutWorld {
|
||||||
|
w := bus()
|
||||||
|
w.Build, w.Newest, w.Version = "", fpOf('c'), ""
|
||||||
|
w.Running = &nodeengine.Running{Node: "novox", Module: "nats", Fingerprint: fNew}
|
||||||
|
w.Have = &nodeengine.HaveByNodeModuleValue{Fp: fNew, Composed: dig(fNew), Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}
|
||||||
|
return w
|
||||||
|
}, puts.Refused, "build or release it first", false, false, false},
|
||||||
{"a failed build", func() PutWorld { w := bus(); w.Build, w.BuildWords = builds.BuildFailed, "go vet"; return w }, puts.Refused, "go vet", false, false, false},
|
{"a failed build", func() PutWorld { w := bus(); w.Build, w.BuildWords = builds.BuildFailed, "go vet"; return w }, puts.Refused, "go vet", false, false, false},
|
||||||
{"no composition yet: waits", func() PutWorld { w := bus(); w.Composed = nil; return w }, puts.Compose, "no composition of nats for novox", false, false, false},
|
{"no composition yet: waits", func() PutWorld { w := bus(); w.Composed = nil; return w }, puts.Compose, "no composition of nats for novox", false, false, false},
|
||||||
{"composed, grant not naming the node", func() PutWorld { w := bus(); w.Granted = false; return w }, puts.Compose, "does not name novox", false, false, false},
|
{"composed, grant not naming the node", func() PutWorld { w := bus(); w.Granted = false; return w }, puts.Compose, "does not name novox", false, false, false},
|
||||||
@@ -256,6 +266,9 @@ func stepsOfAPut(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
next := StepPut(c.world())
|
next := StepPut(c.world())
|
||||||
|
if (next.Put.Step == puts.Wanted || next.Put.Step == puts.Holding) && c.world().Put.Step == puts.Asked && next.Put.Version != "1.2.3" {
|
||||||
|
t.Errorf("put, %s: its want names version %q, want the build's released 1.2.3", c.name, next.Put.Version)
|
||||||
|
}
|
||||||
if next.Put.Step != c.step || !strings.Contains(next.Put.Words, c.says) {
|
if next.Put.Step != c.step || !strings.Contains(next.Put.Words, c.says) {
|
||||||
t.Errorf("put, %s: at %s, %q; want %s saying %q", c.name, next.Put.Step, next.Put.Words, c.step, c.says)
|
t.Errorf("put, %s: at %s, %q; want %s saying %q", c.name, next.Put.Step, next.Put.Words, c.step, c.says)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ type Put struct {
|
|||||||
V int `json:"v"`
|
V int `json:"v"`
|
||||||
// FP is the fingerprint put, of the new form.
|
// FP is the fingerprint put, of the new form.
|
||||||
FP string `json:"fp"`
|
FP string `json:"fp"`
|
||||||
|
// Version is the version released at FP, which the want names beside it, once the put found it (design 47 H2 H-A-490
|
||||||
|
// addendum).
|
||||||
|
Version string `json:"version,omitempty"`
|
||||||
// Hold keeps the want at FP until released.
|
// Hold keeps the want at FP until released.
|
||||||
Hold bool `json:"hold,omitempty"`
|
Hold bool `json:"hold,omitempty"`
|
||||||
Why string `json:"why"`
|
Why string `json:"why"`
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ func TestManifest(t *testing.T) {
|
|||||||
// which lists and asks again what each node's engine reads.
|
// which lists and asks again what each node's engine reads.
|
||||||
if !slices.Equal(m.Tools, []string{"assigner_put", "assigner_release", "assigner_puts", "assigner_waits", "assigner_inputs", "assigner_inputs_drop", "assigner_compositions", "assigner_compositions_drop", "assignments", "seat-holders", "wants", "asks",
|
if !slices.Equal(m.Tools, []string{"assigner_put", "assigner_release", "assigner_puts", "assigner_waits", "assigner_inputs", "assigner_inputs_drop", "assigner_compositions", "assigner_compositions_drop", "assignments", "seat-holders", "wants", "asks",
|
||||||
"assigner_read_assignments", "assigner_read_seat_holders", "assigner_read_wants", "assigner_read_findings", "assigner_read_differences", "assigner_read_copies",
|
"assigner_read_assignments", "assigner_read_seat_holders", "assigner_read_wants", "assigner_read_findings", "assigner_read_differences", "assigner_read_copies",
|
||||||
"assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_want_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before"}) {
|
"assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_want_drop", "assigner_assignment_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before"}) {
|
||||||
t.Errorf("the assigner serves tools %v, want its three put tools, three first views, six read tools, assigner_engine_reads, the seat list's two (ADR 0636 §7) assigner_ask_again (ADR 0668 §5) and assigner_why (design 47 G A-439)", m.Tools)
|
t.Errorf("the assigner serves tools %v, want its three put tools, three first views, six read tools, assigner_engine_reads, the seat list's two (ADR 0636 §7) assigner_ask_again (ADR 0668 §5), assigner_why (design 47 G A-439) and assigner_assignment_drop after assigner_want_drop (design 47 H2 H-A-509)", m.Tools)
|
||||||
}
|
}
|
||||||
if m.RunsAs != m.Module || m.SecretsOwner != m.RunsAs {
|
if m.RunsAs != m.Module || m.SecretsOwner != m.RunsAs {
|
||||||
t.Errorf("runs-as = %q: the bundle runs on the assigner's own account (ADR 0621 §1)", m.RunsAs)
|
t.Errorf("runs-as = %q: the bundle runs on the assigner's own account (ADR 0621 §1)", m.RunsAs)
|
||||||
|
|||||||
@@ -134,6 +134,7 @@
|
|||||||
"assigner_written",
|
"assigner_written",
|
||||||
"assigner_why",
|
"assigner_why",
|
||||||
"assigner_want_drop",
|
"assigner_want_drop",
|
||||||
|
"assigner_assignment_drop",
|
||||||
"assigner_asks",
|
"assigner_asks",
|
||||||
"assigner_ask_drop",
|
"assigner_ask_drop",
|
||||||
"assigner_keep_now",
|
"assigner_keep_now",
|
||||||
|
|||||||
@@ -5,9 +5,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"mesh-delivery-builder/internal/build"
|
"mesh-delivery-builder/internal/build"
|
||||||
|
|
||||||
|
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
)
|
)
|
||||||
@@ -54,3 +57,14 @@ func TestABuildSeatsStepsAreReadInItsHoldersState(t *testing.T) {
|
|||||||
t.Errorf("a seat with no holder reads %v; want an error naming it", err)
|
t.Errorf("a seat with no holder reads %v; want an error naming it", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// H-A-487: a build key's time is its entry's own write time, read with the key and no history.
|
||||||
|
func TestABuildKeysTimeIsItsEntrysOwnWriteTime(t *testing.T) {
|
||||||
|
at := time.Date(2026, 11, 22, 20, 45, 0, 0, time.UTC)
|
||||||
|
raw, rev, got, err := entryOf(func(key string) (*stdio.StateEntry, error) {
|
||||||
|
return &stdio.StateEntry{Key: key, Value: json.RawMessage(`{}`), Revision: 4, At: at}, nil
|
||||||
|
})("k")
|
||||||
|
if err != nil || string(raw) != "{}" || rev != 4 || !got.Equal(at) {
|
||||||
|
t.Errorf("entry = %s rev %d at %v (%v); want the entry's own write time %v", raw, rev, got, err, at)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ func main() {
|
|||||||
return a, json.Unmarshal(raw, &a)
|
return a, json.Unmarshal(raw, &a)
|
||||||
}
|
}
|
||||||
tools := Tools(r, put, askQueue(stdio.State(build.QueuesState), 25*time.Second), buildAgain, stdio.Log(builds.BuilderLog).Since, time.Now, vr, fr, ofr, reserve)
|
tools := Tools(r, put, askQueue(stdio.State(build.QueuesState), 25*time.Second), buildAgain, stdio.Log(builds.BuilderLog).Since, time.Now, vr, fr, ofr, reserve)
|
||||||
tools = append(tools, buildTool(&build.BuildReader{Builds: read(stdio.State("builds")), Entry: entryOf(stdio.State("builds")), Asked: read(stdio.State("asked")),
|
tools = append(tools, buildTool(&build.BuildReader{Builds: read(stdio.State("builds")), Entry: entryOf(stdio.State("builds").Get), Asked: read(stdio.State("asked")),
|
||||||
Newest: newestVia(stdio.Ask), Steps: r}))
|
Newest: newestVia(stdio.Ask), Steps: r}))
|
||||||
tools = append(tools, reservedTools(rr, buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
tools = append(tools, reservedTools(rr, buildAgain, time.Now, meshhandactsclient.Recorder{Ask: stdio.Ask})...)
|
||||||
as := stdio.State(versions.ActedState)
|
as := stdio.State(versions.ActedState)
|
||||||
@@ -481,13 +481,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// entryOf reads a key with its revision and when it was written.
|
// entryOf reads a key with its revision and when it was written, the entry's own write time: no key's history is read
|
||||||
func entryOf(s stdio.KeptState) func(key string) (json.RawMessage, uint64, time.Time, error) {
|
// (design 47 H2 H-A-487).
|
||||||
|
func entryOf(get func(key string) (*stdio.StateEntry, error)) func(key string) (json.RawMessage, uint64, time.Time, error) {
|
||||||
return func(key string) (json.RawMessage, uint64, time.Time, error) {
|
return func(key string) (json.RawMessage, uint64, time.Time, error) {
|
||||||
e, err := s.Get(key)
|
e, err := get(key)
|
||||||
if err != nil || e == nil {
|
if err != nil || e == nil {
|
||||||
return nil, 0, time.Time{}, err
|
return nil, 0, time.Time{}, err
|
||||||
}
|
}
|
||||||
return e.Value, e.Revision, written(s, key, e.Revision), nil
|
return e.Value, e.Revision, e.At, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ func publishQueueVia(ask func(key string, body any) (json.RawMessage, error)) fu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// publishActTools are builder_publish_drop and builder_publish_first (design 47 H2 §793): hand acts, recorded in the hand-act log
|
// publishActTools are builder_publish_drop (design 47 H2 §793; builder_publish_first is retired, H-A-483 third addendum): hand acts, recorded in the hand-act log
|
||||||
// first, then written to reasks for the builder, which owns the work queue, to perform and answer.
|
// first, then written to reasks for the builder, which owns the work queue, to perform and answer.
|
||||||
func publishActTools(ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
func publishActTools(ask queueAsker, now func() time.Time, acts meshhandactsclient.Recorder) []stdio.Tool {
|
||||||
str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) }
|
str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) }
|
||||||
@@ -108,7 +108,6 @@ func publishActTools(ask queueAsker, now func() time.Time, acts meshhandactsclie
|
|||||||
}
|
}
|
||||||
return []stdio.Tool{
|
return []stdio.Tool{
|
||||||
tool(versions.PublishDropTool, build.ModePublishDrop, versions.PublishDropDescription, "dropped the publish of"),
|
tool(versions.PublishDropTool, build.ModePublishDrop, versions.PublishDropDescription, "dropped the publish of"),
|
||||||
tool(versions.PublishFirstTool, build.ModePublishFirst, versions.PublishFirstDescription, "put first the publish of"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ func TestAStateIsReadInOnePage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Design 47 H2 §793, H-A-454: builder_publish_queue asks the seat mesh-builds' verb publish-queue, which the builder serves from
|
// Design 47 H2 §793, H-A-454: builder_publish_queue asks the seat mesh-builds' verb publish-queue, which the builder serves from
|
||||||
// its own stream, and answers its counts, list and cap with the states beside them; builder_publish_drop and
|
// its own stream, and answers its counts, list and cap with the states beside them; builder_publish_drop records the hand act
|
||||||
// builder_publish_first record the hand act first, then write their reasks value.
|
// first, then writes its reasks value; builder_publish_first is retired (H-A-483, third addendum).
|
||||||
t.Run("the queue is the builder's verb publish-queue", func(t *testing.T) {
|
t.Run("the queue is the builder's verb publish-queue", func(t *testing.T) {
|
||||||
var asked []string
|
var asked []string
|
||||||
ask := func(key string, body any) (json.RawMessage, error) {
|
ask := func(key string, body any) (json.RawMessage, error) {
|
||||||
@@ -123,7 +123,7 @@ func TestAStateIsReadInOnePage(t *testing.T) {
|
|||||||
t.Errorf("asked %v, answered %+v (%v): want each holder asked in turn at its node, answered together, the silent one with why", asked, hs, err)
|
t.Errorf("asked %v, answered %+v (%v): want each holder asked in turn at its node, answered together, the silent one with why", asked, hs, err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.Run("drop and first record the hand act, then ask the builder", func(t *testing.T) {
|
t.Run("drop records the hand act, then asks the builder; first is retired", func(t *testing.T) {
|
||||||
var order []string
|
var order []string
|
||||||
ask := func(key string, value []byte) (json.RawMessage, error) {
|
ask := func(key string, value []byte) (json.RawMessage, error) {
|
||||||
order = append(order, "ask "+key)
|
order = append(order, "ask "+key)
|
||||||
@@ -141,8 +141,8 @@ func TestAStateIsReadInOnePage(t *testing.T) {
|
|||||||
t.Fatalf("%s: %v", tool.Name, err)
|
t.Fatalf("%s: %v", tool.Name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(tools) != 2 || fmt.Sprint(order) != "[record ask publish-drop.5000000000 record ask publish-first.5000000000]" {
|
if len(tools) != 1 || tools[0].Name != versions.PublishDropTool || fmt.Sprint(order) != "[record ask publish-drop.5000000000]" {
|
||||||
t.Errorf("tools %d, order %v: want each hand act recorded before its reasks value", len(tools), order)
|
t.Errorf("tools %d, order %v: want builder_publish_drop alone, its hand act recorded before its reasks value", len(tools), order)
|
||||||
}
|
}
|
||||||
if _, err := tools[0].Run(map[string]any{"module": "m", "why": "no version"}); err == nil {
|
if _, err := tools[0].Run(map[string]any{"module": "m", "why": "no version"}); err == nil {
|
||||||
t.Error("a drop naming no version is not refused")
|
t.Error("a drop naming no version is not refused")
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import (
|
|||||||
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||||
"git.novox.be/novox/mesh-sdk/go/process"
|
"git.novox.be/novox/mesh-sdk/go/process"
|
||||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/testbus"
|
||||||
"git.novox.be/novox/mesh-sdk/go/views/viewstest"
|
"git.novox.be/novox/mesh-sdk/go/views/viewstest"
|
||||||
|
|
||||||
"mesh-delivery-builder/internal/build"
|
"mesh-delivery-builder/internal/build"
|
||||||
@@ -578,7 +579,10 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
|||||||
first := "src2:" + strings.Repeat("1", 64)
|
first := "src2:" + strings.Repeat("1", 64)
|
||||||
b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, commit, first, 1)
|
b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, commit, first, 1)
|
||||||
digest := b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, commit, fp, 2)
|
digest := b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, commit, fp, 2)
|
||||||
b.start(t, "n1", map[string]string{"MESH_BUILDER_STEP_BOUND": "1s"})
|
// H-A-473 (addendum): the builds that must end done run under the level bound's set-up share, never a bound a loaded
|
||||||
|
// node cannot meet; the hung step's part below starts the builder again at a short bound of its own.
|
||||||
|
doneBound := map[string]string{"MESH_BUILDER_STEP_BOUND": testbus.SetupBound(t).String()}
|
||||||
|
b.start(t, "n1", doneBound)
|
||||||
v := b.await(t, "netcheck", isState(builds.BuildDone))
|
v := b.await(t, "netcheck", isState(builds.BuildDone))
|
||||||
for _, a := range []string{"tools-go", "tools-typescript"} {
|
for _, a := range []string{"tools-go", "tools-typescript"} {
|
||||||
es := reg.of(t, "netcheck/"+a)
|
es := reg.of(t, "netcheck/"+a)
|
||||||
@@ -693,6 +697,8 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
|||||||
}
|
}
|
||||||
// DLV-B10: a build module's bound running out fails the trunk build, which is the builder's finding build-failed; the
|
// DLV-B10: a build module's bound running out fails the trunk build, which is the builder's finding build-failed; the
|
||||||
// fingerprint built again clears it with its done build, numbering nothing of the builder's own (H-A-159).
|
// fingerprint built again clears it with its done build, numbering nothing of the builder's own (H-A-159).
|
||||||
|
b.stop()
|
||||||
|
b.start(t, "n1", map[string]string{"MESH_BUILDER_STEP_BOUND": "1s"}) // a step that never ends runs out of any bound
|
||||||
release := make(chan struct{})
|
release := make(chan struct{})
|
||||||
b.fake.hang.Store(&release)
|
b.fake.hang.Store(&release)
|
||||||
third := "src2:" + strings.Repeat("4", 64)
|
third := "src2:" + strings.Repeat("4", 64)
|
||||||
@@ -713,6 +719,8 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
|||||||
reg.awaitFinding(t, failed, true)
|
reg.awaitFinding(t, failed, true)
|
||||||
b.fake.hang.Store(nil)
|
b.fake.hang.Store(nil)
|
||||||
close(release)
|
close(release)
|
||||||
|
b.stop() // the build again must end done
|
||||||
|
b.start(t, "n1", doneBound)
|
||||||
b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, "89abcdef0123456789abcdef0123456789abcdef", third, 3) // the entry moves to a later commit, same fingerprint
|
b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, "89abcdef0123456789abcdef0123456789abcdef", third, 3) // the entry moves to a later commit, same fingerprint
|
||||||
b.awaitFP(t, "netcheck", third, isState(builds.BuildDone))
|
b.awaitFP(t, "netcheck", third, isState(builds.BuildDone))
|
||||||
reg.awaitFinding(t, failed, false)
|
reg.awaitFinding(t, failed, false)
|
||||||
|
|||||||
@@ -233,6 +233,12 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
b.PackageWait = time.Duration(packageWait) * time.Minute
|
b.PackageWait = time.Duration(packageWait) * time.Minute
|
||||||
|
// A version's digests are recorded under the builder's own bound, never the build's (H-A-492); it is record-bound-seconds.
|
||||||
|
recordBound, err := numberFile(getenv("MESH_BUILDER_RECORD_BOUND_FILE"), int(build.DefaultRecordBound/time.Second))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b.RecordBound = time.Duration(recordBound) * time.Second
|
||||||
// Before it waits for an unpinned package, the build reads what the Go package registry seat holds of it (H-A-194).
|
// Before it waits for an unpinned package, the build reads what the Go package registry seat holds of it (H-A-194).
|
||||||
b.PublishedVersions = publishedVersionsVia(calls.Call)
|
b.PublishedVersions = publishedVersionsVia(calls.Call)
|
||||||
waitsBucket := process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.WaitsState), "the toolchain waits are kept in memory only, and builder_waits shows none", logger.Printf)
|
waitsBucket := process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.WaitsState), "the toolchain waits are kept in memory only, and builder_waits shows none", logger.Printf)
|
||||||
@@ -254,11 +260,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
}
|
}
|
||||||
// A package's number reserved is said as the seat mesh-builds' version-reserved, so the indexer re-pins at the reservation (§805).
|
// A package's number reserved is said as the seat mesh-builds' version-reserved, so the indexer re-pins at the reservation (§805).
|
||||||
reserved.names = versions.NamesFrom(versions.EntriesOf(branches))
|
reserved.names = versions.NamesFrom(versions.EntriesOf(branches))
|
||||||
reserved.r.Names = reserved.names // a Go package's module path names its tag's directory (§796)
|
|
||||||
reserved.sayReserved = sayReservedOn(js, cred)
|
reserved.sayReserved = sayReservedOn(js, cred)
|
||||||
b.Reserved = reserved
|
b.Reserved = reserved
|
||||||
// A take-over of a series' reservation by another fingerprint withdraws the older build (H-A-225).
|
// A take-over of a series' reservation by another fingerprint withdraws the older build (H-A-225).
|
||||||
reserved.withdraw = b.Withdraw
|
reserved.withdraw = b.Withdraw
|
||||||
|
reserved.recordAgain = b.RecordAgain // a done build's digests its end did not record are recorded at the start (H-A-492)
|
||||||
// The last versions-filled the stream keeps is read at the start (design 47 G §369, §372): a restart does not lose it.
|
// The last versions-filled the stream keeps is read at the start (design 47 G §369, §372): a restart does not lose it.
|
||||||
reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps)
|
reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps)
|
||||||
// A state bound later numbers the builds looked at without it.
|
// A state bound later numbers the builds looked at without it.
|
||||||
@@ -273,7 +279,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
Entry: entryVia(calls.Call), Send: sendVia(calls.CallKeptAsk),
|
Entry: entryVia(calls.Call), Send: sendVia(calls.CallKeptAsk),
|
||||||
Unreleased: reserved.unreleasedWords, Logf: logger.Printf,
|
Unreleased: reserved.unreleasedWords, Logf: logger.Printf,
|
||||||
Holders: holders, // a registry seat's holder from the seat-holders view, from the start (design 47 G A-416, A-416a)
|
Holders: holders, // a registry seat's holder from the seat-holders view, from the start (design 47 G A-416, A-416a)
|
||||||
Started: time.Now()} // a build ended from now on is of the live class, sent first (H-A-290 (1))
|
Started: time.Now()} // a build ended from now on is of the live class (H-A-290 (1))
|
||||||
// A number a registry seat already holds is never reserved (H-A-275): read before reserving, through the seats' verb versions.
|
// A number a registry seat already holds is never reserved (H-A-275): read before reserving, through the seats' verb versions.
|
||||||
reserved.r.HeldNumbers = func(ctx context.Context, module, fp string, refs []string) ([]string, error) {
|
reserved.r.HeldNumbers = func(ctx context.Context, module, fp string, refs []string) ([]string, error) {
|
||||||
return republish.HeldNumbers(ctx, module, fp, refs, registryVersionsVia(calls.Call))
|
return republish.HeldNumbers(ctx, module, fp, refs, registryVersionsVia(calls.Call))
|
||||||
@@ -322,15 +328,17 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
// A version that never publishes (withdrawn or taken over) has its publish item ended by the queue too (H-A-290 (2)).
|
// A version that never publishes (withdrawn or taken over) has its publish item ended by the queue too (H-A-290 (2)).
|
||||||
republish.Ended = items.Ended
|
republish.Ended = items.Ended
|
||||||
pq.take = items.take
|
pq.take = items.take
|
||||||
reasksKV.Ready(func(jetstream.KeyValue) { items.AskAllDone(ctx) })
|
// At the start, a built reservation the catalog holds released is taken in as its version-released would (H-A-484 addendum),
|
||||||
|
// before the publish items of the rest are asked.
|
||||||
|
reasksKV.Ready(func(jetstream.KeyValue) {
|
||||||
|
reserved.releasedAtStart(ctx)
|
||||||
|
items.AskAllDone(ctx)
|
||||||
|
})
|
||||||
wirePublishItems(reserved, items, awaitedReserved{awaitedVersions{b: actedKV, bucket: own.acted}}, releasedKept)
|
wirePublishItems(reserved, items, awaitedReserved{awaitedVersions{b: actedKV, bucket: own.acted}}, releasedKept)
|
||||||
acts.Republish = republish.Republish
|
acts.Republish = republish.Republish
|
||||||
acts.PublishDrop = func(ctx context.Context, module, version, by, why string) (string, error) {
|
acts.PublishDrop = func(ctx context.Context, module, version, by, why string) (string, error) {
|
||||||
return pq.drop(ctx, items, module, version, by, why)
|
return pq.drop(ctx, items, module, version, by, why)
|
||||||
}
|
}
|
||||||
acts.PublishFirst = func(ctx context.Context, module, version, _, _ string) (string, error) {
|
|
||||||
return pq.first(ctx, items, module, version)
|
|
||||||
}
|
|
||||||
// builder_reserve_done: a done trunk build that reserved none is given a version, and its publish queued as publish again does.
|
// builder_reserve_done: a done trunk build that reserved none is given a version, and its publish queued as publish again does.
|
||||||
acts.ReserveDone = reserveDoneAct(b.ReserveDone, republish.Republish, logger.Printf)
|
acts.ReserveDone = reserveDoneAct(b.ReserveDone, republish.Republish, logger.Printf)
|
||||||
// The operator is asked once a key's event builds are spent (design 47 G §568): the builder's asker on the seat operator-channel.
|
// The operator is asked once a key's event builds are spent (design 47 G §568): the builder's asker on the seat operator-channel.
|
||||||
|
|||||||
+413
-266
@@ -22,19 +22,21 @@ import (
|
|||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
"git.novox.be/novox/mesh-sdk/go/process"
|
"git.novox.be/novox/mesh-sdk/go/process"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/testbus"
|
||||||
"git.novox.be/novox/mesh-sdk/go/views"
|
"git.novox.be/novox/mesh-sdk/go/views"
|
||||||
|
|
||||||
"mesh-delivery-builder/internal/versions"
|
"mesh-delivery-builder/internal/versions"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Design 47 H2 §793 (whole, against the bus): the builder's work queue publishes, its pull consumers made as it learns a holder.
|
// Design 47 H2 §793 (whole, against the bus): the builder's work queue publishes, one pull consumer made as it learns a holder
|
||||||
// A live publish enqueued behind 100 again items while the builder was away is sent first; a dropped item is never sent, and
|
// (H-A-483 and its addenda), the class durables of an earlier release retired. No item is lost, a failed send comes back after
|
||||||
// put again within the duplicates window is not stored; the move of the old state run twice puts each item once, and the
|
// its pause behind an item put meanwhile, and a dropped item never comes back; 100 again items and a live one put while the
|
||||||
// builder removes the old state's bucket itself (H-A-461 (1)). The seat mesh-builds' verb publish-queue reads the stream: counts
|
// builder was away are all sent, the dropped one never, and put again within the duplicates window it is not stored; the move
|
||||||
// per holder and class, the oldest and newest, the live item listed first (H-A-454). Then §796's tag at another commit, its
|
// of the old state run twice puts each item once, and the builder removes the old state's bucket itself (H-A-461 (1)). The seat
|
||||||
// reservation's version-reserved waited on by name (§821), and
|
// mesh-builds' verb publish-queue reads the stream: counts per holder and class, the oldest and newest, the items listed in
|
||||||
// §794's backlog held six minutes, as steps (H-A-453 (3)).
|
// stream order (H-A-454; H-A-483, third addendum). Then §796's tag at another commit, its reservation's version-reserved waited on by name (§821), and §794's
|
||||||
func TestThePublishQueueSendsLiveFirstAndNeverADroppedItem(t *testing.T) {
|
// backlog held six minutes, as steps (H-A-453 (3)).
|
||||||
|
func TestThePublishQueueLosesNoItemAndNeverSendsADroppedItem(t *testing.T) {
|
||||||
b := startBed(t)
|
b := startBed(t)
|
||||||
ctx := b.ctx
|
ctx := b.ctx
|
||||||
// The stream as the manifest's old streams section declares it: the module's own, retention work-queue, duplicates 24 hours.
|
// The stream as the manifest's old streams section declares it: the module's own, retention work-queue, duplicates 24 hours.
|
||||||
@@ -43,281 +45,426 @@ func TestThePublishQueueSendsLiveFirstAndNeverADroppedItem(t *testing.T) {
|
|||||||
Retention: jetstream.WorkQueuePolicy, Discard: jetstream.DiscardNew, Duplicates: 24 * time.Hour, MaxAge: 7 * 24 * time.Hour}); err != nil {
|
Retention: jetstream.WorkQueuePolicy, Discard: jetstream.DiscardNew, Duplicates: 24 * time.Hour, MaxAge: 7 * 24 * time.Hour}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
kv := &itemKV{vals: map[string][]byte{}, revs: map[string]uint64{}}
|
// One consumer per holder (H-A-483 and its addenda): the holder's class durables of an earlier release are retired, the item
|
||||||
var mu sync.Mutex
|
// one of them held unacknowledged reaches the one consumer; no item is lost; a failed send comes back after its pause, and a
|
||||||
var sent []string
|
// live item put while it waits is sent before it returns; a dropped item never comes back.
|
||||||
published := map[string]bool{} // the modules whose publish is heard
|
t.Run("one consumer", func(t *testing.T) {
|
||||||
sentCh := make(chan string, 200)
|
const holder, pause = "paused", 3 * time.Second // the pause is far longer than a send of an item put now
|
||||||
items := &publishItems{reasks: func() jetstream.KeyValue { return kv }, set: publishSettings{Pause: time.Second, PauseMax: time.Minute, Tries: 5},
|
bound := testbus.SetupBound(t)
|
||||||
now: time.Now, logf: t.Logf,
|
kv := &itemKV{vals: map[string][]byte{}, revs: map[string]uint64{}}
|
||||||
reserved: func(_ context.Context, m, v string) (versions.ReservedVersion, bool, error) {
|
type send struct {
|
||||||
|
module string
|
||||||
|
at time.Time
|
||||||
|
}
|
||||||
|
var mu sync.Mutex
|
||||||
|
published, failed := map[string]bool{}, map[string]bool{}
|
||||||
|
sentCh := make(chan send, 16)
|
||||||
|
items := &publishItems{reasks: func() jetstream.KeyValue { return kv }, set: publishSettings{Pause: pause, PauseMax: time.Minute, Tries: 5},
|
||||||
|
now: time.Now, logf: t.Logf,
|
||||||
|
reserved: func(_ context.Context, m, v string) (versions.ReservedVersion, bool, error) {
|
||||||
|
mu.Lock()
|
||||||
|
defer mu.Unlock()
|
||||||
|
return versions.ReservedVersion{Module: m, Version: v, Artifacts: map[string]string{m + ":a": "sha256:a"}, Published: map[string]bool{m + ":a": published[m]}, BuiltAt: time.Now()}, true, nil
|
||||||
|
},
|
||||||
|
send: func(_ context.Context, q versions.QueuedPublish) versions.SendFate {
|
||||||
|
sentCh <- send{q.Module, time.Now()}
|
||||||
|
mu.Lock()
|
||||||
|
defer mu.Unlock()
|
||||||
|
if (q.Module == "fail" || q.Module == "dropme") && !failed[q.Module] { // the first send of each fails
|
||||||
|
failed[q.Module] = true
|
||||||
|
return versions.SendFate{Failed: "the registry is down"}
|
||||||
|
}
|
||||||
|
published[q.Module] = true
|
||||||
|
return versions.SendFate{Sent: true}
|
||||||
|
}}
|
||||||
|
pq := &publishQueue{js: b.js, ackWait: time.Minute, logf: t.Logf, take: items.take, binding: publishesOf("mesh-delivery-builder")}
|
||||||
|
put := func(module, class string) {
|
||||||
|
q := versions.QueuedPublish{V: 1, Holder: holder, Module: module, Version: "0.1.0", Artifacts: map[string]string{module + ":a": "sha256:a"}, Class: class, Queued: time.Now()}
|
||||||
|
data, _ := json.Marshal(q)
|
||||||
|
if _, err := b.js.Publish(ctx, pq.subject(bind, q), data); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hear := func() { // each publish sent is heard: its item acknowledged once it is held
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
var done []string
|
||||||
return versions.ReservedVersion{Module: m, Version: v, Artifacts: map[string]string{m + ":a": "sha256:a"}, Published: map[string]bool{m + ":a": published[m]}, BuiltAt: time.Now()}, true, nil
|
for m, ok := range published {
|
||||||
},
|
if ok {
|
||||||
send: func(_ context.Context, q versions.QueuedPublish) versions.SendFate {
|
done = append(done, m)
|
||||||
mu.Lock()
|
}
|
||||||
sent = append(sent, q.Module)
|
}
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
sentCh <- q.Module
|
for _, m := range done {
|
||||||
return versions.SendFate{Sent: true}
|
items.heard(ctx, m, "0.1.0")
|
||||||
}}
|
}
|
||||||
pq := &publishQueue{js: b.js, ackWait: time.Minute, logf: t.Logf, take: items.take, binding: publishesOf("mesh-delivery-builder")}
|
}
|
||||||
item := func(module, class string) versions.QueuedPublish {
|
next := func() send {
|
||||||
return versions.QueuedPublish{V: 1, Holder: "oci", Module: module, Version: "0.1.0", Artifacts: map[string]string{module + ":a": "sha256:a"}, Class: class, Queued: time.Now()}
|
t.Helper()
|
||||||
}
|
select {
|
||||||
away := func(q versions.QueuedPublish) { // put while the builder was away: no holder learnt, nothing pulled
|
case s := <-sentCh:
|
||||||
data, _ := json.Marshal(q)
|
hear()
|
||||||
if _, err := b.js.Publish(ctx, pq.subject(bind, q), data, jetstream.WithMsgID(versions.PublishMsgID(q.Holder, q.Class, q.Module, q.Version))); err != nil {
|
return s
|
||||||
|
case <-time.After(bound):
|
||||||
|
t.Fatal("no item was sent within the level's set-up share")
|
||||||
|
}
|
||||||
|
return send{}
|
||||||
|
}
|
||||||
|
// The two class durables an earlier release made, the live one holding an item given and not acknowledged.
|
||||||
|
for _, class := range []string{versions.PublishClassLive, versions.PublishClassStart} {
|
||||||
|
if _, err := b.js.CreateOrUpdateConsumer(ctx, bind.Stream, jetstream.ConsumerConfig{Durable: publishesConsumer(holder) + "-" + class,
|
||||||
|
FilterSubject: bind.Subject + ".publish." + holder + "." + class + ".>", AckPolicy: jetstream.AckExplicitPolicy, AckWait: time.Hour}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
put("given", versions.PublishClassLive)
|
||||||
|
old, err := b.js.Consumer(ctx, bind.Stream, publishesConsumer(holder)+"-"+versions.PublishClassLive)
|
||||||
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
if m, err := old.Next(); err != nil {
|
||||||
for i := range 100 {
|
t.Fatal(err)
|
||||||
away(item(fmt.Sprintf("a%03d", i), versions.PublishClassStart))
|
} else if md, _ := m.Metadata(); md.NumDelivered != 1 {
|
||||||
}
|
t.Fatalf("the old live durable gave %+v", md)
|
||||||
away(item("dropme", versions.PublishClassStart))
|
|
||||||
away(item("live", versions.PublishClassLive))
|
|
||||||
if answer, err := pq.drop(ctx, items, "dropme", "0.1.0", "op@node", "a test drops it"); err != nil {
|
|
||||||
t.Fatalf("drop: %v", err)
|
|
||||||
} else {
|
|
||||||
t.Log(answer)
|
|
||||||
}
|
|
||||||
if dup, err := pq.put(ctx, item("dropme", versions.PublishClassStart)); err != nil || !dup {
|
|
||||||
t.Errorf("a dropped item put again within the window: duplicate %v (%v), want it not stored", dup, err)
|
|
||||||
}
|
|
||||||
raw, err := publishQueueVerb(ctx, pq)("op@node", json.RawMessage(`{}`))
|
|
||||||
if a, ok := raw.(meshbuilds.PublishQueueAnswer); err != nil || !ok || a.Total != 101 || len(a.Counts) != 2 || a.Counts[0].Class != versions.PublishClassStart ||
|
|
||||||
a.Counts[0].Count != 100 || a.Counts[1].Count != 1 || a.Counts[0].Oldest.After(a.Counts[0].Newest) || len(a.Queue) != versions.PublishQueueListCap ||
|
|
||||||
a.Queue[0].Module != "live" || a.Capped {
|
|
||||||
t.Errorf("publish-queue answered %+v (%v), want 101 items, oci's 100 again and 1 live, fifty listed, the live first", raw, err)
|
|
||||||
}
|
|
||||||
if err := pq.learnAll(ctx); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case first := <-sentCh:
|
|
||||||
if first != "live" {
|
|
||||||
t.Errorf("the first item sent is %s, want the live one, enqueued behind 100 again items", first)
|
|
||||||
}
|
}
|
||||||
case <-time.After(30 * time.Second):
|
pq.learn(ctx, holder)
|
||||||
t.Fatal("nothing was sent")
|
stream, err := b.js.Stream(ctx, bind.Stream)
|
||||||
}
|
if err != nil {
|
||||||
for range 4 { // the again items in flight: at most four held unacknowledged, their publish unheard
|
t.Fatal(err)
|
||||||
select {
|
}
|
||||||
case <-sentCh:
|
var names []string
|
||||||
case <-time.After(30 * time.Second):
|
for n := range stream.ConsumerNames(ctx).Name() {
|
||||||
t.Fatal("the again items were not sent")
|
if strings.HasPrefix(n, publishesConsumer(holder)) {
|
||||||
|
names = append(names, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !slices.Equal(names, []string{publishesConsumer(holder)}) {
|
||||||
|
t.Fatalf("the consumers of %s are %v, want only %s: the class durables retired", holder, names, publishesConsumer(holder))
|
||||||
|
}
|
||||||
|
if s := next(); s.module != "given" {
|
||||||
|
t.Fatalf("sent %s first, want the item the old durable held unacknowledged", s.module)
|
||||||
|
}
|
||||||
|
put("fail", versions.PublishClassStart)
|
||||||
|
put("dropme", versions.PublishClassStart)
|
||||||
|
var firstFail time.Time
|
||||||
|
for range 2 {
|
||||||
|
if s := next(); s.module == "fail" {
|
||||||
|
firstFail = s.at
|
||||||
|
}
|
||||||
|
}
|
||||||
|
put("live", versions.PublishClassLive) // put while both failed items wait out their pause
|
||||||
|
if s := next(); s.module != "live" {
|
||||||
|
t.Fatalf("sent %s, want the live item put while the failed ones wait their pause", s.module)
|
||||||
|
}
|
||||||
|
if answer, err := pq.drop(ctx, items, "dropme", "0.1.0", "op@node", "a test drops it"); err != nil {
|
||||||
|
t.Fatalf("drop: %v", err)
|
||||||
|
} else {
|
||||||
|
t.Log(answer)
|
||||||
|
}
|
||||||
|
if s := next(); s.module != "fail" || s.at.Sub(firstFail) < pause {
|
||||||
|
t.Fatalf("sent %s %s after the failed send, want fail again after its pause %s", s.module, s.at.Sub(firstFail), pause)
|
||||||
|
}
|
||||||
|
// Every item is acknowledged and the dropped one is gone: nothing is left to come back.
|
||||||
|
c, err := b.js.Consumer(ctx, bind.Stream, publishesConsumer(holder))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
st, err := b.js.Stream(ctx, bind.Stream)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for deadline := time.Now().Add(bound); ; {
|
||||||
|
hear()
|
||||||
|
info, err := c.Info(ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
sinfo, err := st.Info(ctx, jetstream.WithSubjectFilter(bind.Subject+".publish."+holder+".>"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if info.NumAckPending == 0 && info.NumPending == 0 && len(sinfo.State.Subjects) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if time.Now().After(deadline) {
|
||||||
|
t.Fatalf("the queue of %s holds %v, its consumer %d pending and %d unacknowledged: want every item acknowledged and the dropped one gone", holder, sinfo.State.Subjects, info.NumPending, info.NumAckPending)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case s := <-sentCh:
|
||||||
|
t.Fatalf("sent %s again, want nothing more", s.module)
|
||||||
|
case <-time.After(10 * time.Millisecond):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("the queue, the move, tags and backlog", func(t *testing.T) {
|
||||||
|
kv := &itemKV{vals: map[string][]byte{}, revs: map[string]uint64{}}
|
||||||
|
var mu sync.Mutex
|
||||||
|
var sent []string
|
||||||
|
published := map[string]bool{} // the modules whose publish is heard
|
||||||
|
sentCh := make(chan string, 200)
|
||||||
|
items := &publishItems{reasks: func() jetstream.KeyValue { return kv }, set: publishSettings{Pause: time.Second, PauseMax: time.Minute, Tries: 5},
|
||||||
|
now: time.Now, logf: t.Logf,
|
||||||
|
reserved: func(_ context.Context, m, v string) (versions.ReservedVersion, bool, error) {
|
||||||
|
mu.Lock()
|
||||||
|
defer mu.Unlock()
|
||||||
|
return versions.ReservedVersion{Module: m, Version: v, Artifacts: map[string]string{m + ":a": "sha256:a"}, Published: map[string]bool{m + ":a": published[m]}, BuiltAt: time.Now()}, true, nil
|
||||||
|
},
|
||||||
|
send: func(_ context.Context, q versions.QueuedPublish) versions.SendFate {
|
||||||
|
mu.Lock()
|
||||||
|
sent = append(sent, q.Module)
|
||||||
|
mu.Unlock()
|
||||||
|
sentCh <- q.Module
|
||||||
|
return versions.SendFate{Sent: true}
|
||||||
|
}}
|
||||||
|
pq := &publishQueue{js: b.js, ackWait: time.Minute, logf: t.Logf, take: items.take, binding: publishesOf("mesh-delivery-builder")}
|
||||||
|
item := func(module, class string) versions.QueuedPublish {
|
||||||
|
return versions.QueuedPublish{V: 1, Holder: "oci", Module: module, Version: "0.1.0", Artifacts: map[string]string{module + ":a": "sha256:a"}, Class: class, Queued: time.Now()}
|
||||||
|
}
|
||||||
|
away := func(q versions.QueuedPublish) { // put while the builder was away: no holder learnt, nothing pulled
|
||||||
|
data, _ := json.Marshal(q)
|
||||||
|
if _, err := b.js.Publish(ctx, pq.subject(bind, q), data, jetstream.WithMsgID(versions.PublishMsgID(q.Holder, q.Class, q.Module, q.Version))); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := range 100 {
|
||||||
|
away(item(fmt.Sprintf("a%03d", i), versions.PublishClassStart))
|
||||||
|
}
|
||||||
|
away(item("dropme", versions.PublishClassStart))
|
||||||
|
away(item("live", versions.PublishClassLive))
|
||||||
|
if answer, err := pq.drop(ctx, items, "dropme", "0.1.0", "op@node", "a test drops it"); err != nil {
|
||||||
|
t.Fatalf("drop: %v", err)
|
||||||
|
} else {
|
||||||
|
t.Log(answer)
|
||||||
|
}
|
||||||
|
if dup, err := pq.put(ctx, item("dropme", versions.PublishClassStart)); err != nil || !dup {
|
||||||
|
t.Errorf("a dropped item put again within the window: duplicate %v (%v), want it not stored", dup, err)
|
||||||
|
}
|
||||||
|
raw, err := publishQueueVerb(ctx, pq)("op@node", json.RawMessage(`{}`))
|
||||||
|
if a, ok := raw.(meshbuilds.PublishQueueAnswer); err != nil || !ok || a.Total != 101 || len(a.Counts) != 2 || a.Counts[0].Class != versions.PublishClassStart ||
|
||||||
|
a.Counts[0].Count != 100 || a.Counts[1].Count != 1 || a.Counts[0].Oldest.After(a.Counts[0].Newest) || len(a.Queue) != versions.PublishQueueListCap ||
|
||||||
|
a.Queue[0].Module != "a000" || a.Capped {
|
||||||
|
t.Errorf("publish-queue answered %+v (%v), want 101 items, oci's 100 again and 1 live, fifty listed in stream order, a000 first", raw, err)
|
||||||
|
}
|
||||||
|
if err := pq.learnAll(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for range 4 { // the items in flight: at most four held unacknowledged, their publish unheard
|
||||||
|
select {
|
||||||
|
case <-sentCh:
|
||||||
|
case <-time.After(30 * time.Second):
|
||||||
|
t.Fatal("the again items were not sent")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deadline := time.After(60 * time.Second)
|
||||||
|
for { // each publish sent is heard: its item acknowledged, the next sent
|
||||||
|
mu.Lock()
|
||||||
|
n, done := len(sent), slices.Clone(sent)
|
||||||
|
for _, m := range done {
|
||||||
|
published[m] = true
|
||||||
|
}
|
||||||
|
mu.Unlock()
|
||||||
|
if n >= 101 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for _, m := range done {
|
||||||
|
items.heard(ctx, m, "0.1.0")
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-sentCh:
|
||||||
|
case <-deadline:
|
||||||
|
t.Fatalf("sent %d of 101", n)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
deadline := time.After(60 * time.Second)
|
|
||||||
for { // each publish sent is heard: its item acknowledged, the next sent
|
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
n, done := len(sent), slices.Clone(sent)
|
if slices.Contains(sent, "dropme") || len(sent) != 101 {
|
||||||
for _, m := range done {
|
t.Errorf("sent %d items (dropme among them: %v), want the 101 and never the dropped one", len(sent), slices.Contains(sent, "dropme"))
|
||||||
published[m] = true
|
|
||||||
}
|
}
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
if n >= 101 {
|
|
||||||
break
|
// The move of the old state, run twice, puts each item once (at another holder, so the pull of oci is not asked).
|
||||||
|
old, err := b.js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: builds.StateBucket("mesh-delivery-builder", versions.PublishQueueState)})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, m := range done {
|
var tagsWritten []string
|
||||||
items.heard(ctx, m, "0.1.0")
|
call := func(tool string, body any) (json.RawMessage, error) {
|
||||||
|
switch tool {
|
||||||
|
case "seat:" + gitseat.Seat + "." + gitseat.VerbTags: // m4's 0.2.0 is tagged at another commit, never read (H-A-494)
|
||||||
|
tagsWritten = append(tagsWritten, "read "+body.(gitseat.TagsInput).Prefix)
|
||||||
|
return json.Marshal(gitseat.TagsAnswer{Form: 2, Tags: []gitseat.Tag{{Tag: "modules/m4/v0.2.0", Commit: "c-other"}}})
|
||||||
|
case "seat:" + gitseat.Seat + ".tag":
|
||||||
|
tagsWritten = append(tagsWritten, body.(gitseat.TagInput).Tag+"@"+body.(gitseat.TagInput).Commit)
|
||||||
|
return json.Marshal(gitseat.TagAnswer{Performed: true})
|
||||||
|
}
|
||||||
|
return json.Marshal(meshcatalog.VersionsAnswer{Module: "m"})
|
||||||
|
}
|
||||||
|
found := &memFindings{vals: map[string][]byte{}}
|
||||||
|
rv := newReservations(&memReserve{vals: map[string][]byte{}, revs: map[string]uint64{}}, call, func() jetstream.KeyValue { return &boundsKV{keys: map[string]bool{}} },
|
||||||
|
&findings{module: builds.BuilderModule, w: found, logf: t.Logf, now: time.Now}, nil, t.Logf)
|
||||||
|
rv.filled.Store(true)
|
||||||
|
type oldItem struct {
|
||||||
|
key string
|
||||||
|
raw []byte
|
||||||
|
}
|
||||||
|
var olds []oldItem
|
||||||
|
for _, m := range []string{"m1", "m2", "m3"} {
|
||||||
|
v, err := rv.Reserve(ctx, m, "0.1", []string{m + ":a"}, versions.Source{Fingerprint: "src2:" + m})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := rv.Built(ctx, m, v.Version, map[string]string{m + ":a": "sha256:a"}, nil); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
raw, _ := json.Marshal(versions.QueuedPublish{V: 1, Holder: "go", Module: m, Version: v.Version, Artifacts: map[string]string{m + ":a": "sha256:a"}, Class: "asked-again-at-start"})
|
||||||
|
if _, err := old.Put(ctx, versions.QueueKey("go", m, v.Version), raw); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
olds = append(olds, oldItem{versions.QueueKey("go", m, v.Version), raw})
|
||||||
|
}
|
||||||
|
rp := &versions.Republisher{Reserved: rv.r, Put: func(ctx context.Context, q versions.QueuedPublish) (bool, error) {
|
||||||
|
data, _ := json.Marshal(q)
|
||||||
|
ack, err := b.js.Publish(ctx, pq.subject(bind, q), data, jetstream.WithMsgID(versions.PublishMsgID(q.Holder, q.Class, q.Module, q.Version)))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return ack.Duplicate, nil
|
||||||
|
}, Started: time.Now(), Logf: t.Logf}
|
||||||
|
oldBucket := builds.StateBucket("mesh-delivery-builder", versions.PublishQueueState)
|
||||||
|
moveOld(ctx, b.js, oldBucket, rp, t.Logf)
|
||||||
|
if _, err := b.js.KeyValue(ctx, oldBucket); !errors.Is(err, jetstream.ErrBucketNotFound) {
|
||||||
|
t.Errorf("after the move the old state's bucket answers %v, want it removed by the builder (H-A-461 (1))", err)
|
||||||
|
}
|
||||||
|
// A start that stopped before the removal moves the same items again: the duplicates window keeps each once.
|
||||||
|
again, err := b.js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: oldBucket})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for _, e := range olds {
|
||||||
|
if _, err := again.Put(ctx, e.key, e.raw); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
moveOld(ctx, b.js, oldBucket, rp, t.Logf)
|
||||||
|
moveOld(ctx, b.js, oldBucket, rp, t.Logf) // no bucket left: nothing moves
|
||||||
|
if _, err := b.js.KeyValue(ctx, oldBucket); !errors.Is(err, jetstream.ErrBucketNotFound) {
|
||||||
|
t.Errorf("after the second move the old state's bucket answers %v, want it removed", err)
|
||||||
|
}
|
||||||
|
st, err := b.js.Stream(ctx, bind.Stream)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
info, err := st.Info(ctx, jetstream.WithSubjectFilter(bind.Subject+".publish.go.>"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(info.State.Subjects) != 3 || info.State.Subjects[bind.Subject+".publish.go.again.m1.0=2E1=2E0"] != 1 {
|
||||||
|
t.Errorf("the move run twice left %v on the work queue: want each of the three once, as again", info.State.Subjects)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Design 47 H2 H-A-494: no git tag is read before a reserve nor written at a release: m4's 0.2.0, which the seat git would
|
||||||
|
// answer tagged at another commit, is reserved, no finding raised, and its version-released writes no tag.
|
||||||
|
// Design 47 H2 §821, §805: the reservation is said as the seat mesh-builds' version-reserved, said as the process says it
|
||||||
|
// (sayReservedOn), and waited on by the seat and the event's name.
|
||||||
|
rv.names = func(context.Context, string, string) (string, bool, error) {
|
||||||
|
return "git.example/o/r/modules/m4", true, nil
|
||||||
|
}
|
||||||
|
rv.sayReserved = sayReservedOn(b.js, process.Account{Module: builds.BuilderModule, Node: "n1"})
|
||||||
|
said, err := nats.Connect(b.srvURL, nats.UserInfo("ctl", "pw"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer said.Close()
|
||||||
|
reservedCh := make(chan *nats.Msg, 4)
|
||||||
|
rs, err := said.ChanSubscribe(meshbuilds.SubjectVersionReserved, reservedCh)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer rs.Unsubscribe()
|
||||||
|
if err := said.Flush(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
v4, err := rv.Reserve(ctx, "m4", "0.2", []string{"m4:lib"}, versions.Source{Fingerprint: "src2:m4",
|
||||||
|
Repository: "o/r", Commit: "c-mine", Branch: "main", CatalogRevision: 1})
|
||||||
|
elsewhere := views.FindingKey(meshconditionsclient.ScopeModule, "m4", versions.VersionTaggedElsewhere)
|
||||||
|
if _, raised := found.vals[elsewhere]; err != nil || v4.Version != "0.2.0" || v4.Tag != "" || raised {
|
||||||
|
t.Fatalf("m4 reserved %+v (%v), %s raised %v: want 0.2.0 naming no tag, no tag read and no finding", v4, err, elsewhere, raised)
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case <-sentCh:
|
case m := <-reservedCh:
|
||||||
case <-deadline:
|
ev, _, err := meshbuilds.DecodeVersionReservedEvent(m.Data)
|
||||||
t.Fatalf("sent %d of 101", n)
|
if err != nil || ev.Module != "m4" || ev.Artifact != "m4:lib" || ev.Path != "git.example/o/r/modules/m4" || ev.Version != "0.2.0" ||
|
||||||
|
ev.Fingerprint != "src2:m4" || ev.Revision != "main.1" || m.Header.Get("x-source") != builds.BuilderModule {
|
||||||
|
t.Errorf("version-reserved = %+v (%v) from %q, want m4:lib at 0.2.0, its path, fingerprint src2:m4 and revision main.1, said by the builder", ev, err, m.Header.Get("x-source"))
|
||||||
|
}
|
||||||
|
case <-time.After(10 * time.Second):
|
||||||
|
t.Fatal("no version-reserved of m4's reservation within 10 s on " + meshbuilds.SubjectVersionReserved)
|
||||||
|
}
|
||||||
|
catalogEvents, err := b.js.StreamNameBySubject(ctx, meshcatalog.SubjectVersionReleased) // the bed's stream of the catalog's events
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
evs, err := b.js.CreateOrUpdateConsumer(ctx, catalogEvents, jetstream.ConsumerConfig{Durable: "builder-events", AckPolicy: jetstream.AckExplicitPolicy,
|
||||||
|
FilterSubject: meshcatalog.SubjectVersionReleased, DeliverPolicy: jetstream.DeliverNewPolicy})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
next := func(module, version string) jetstream.Msg {
|
||||||
|
t.Helper()
|
||||||
|
data, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: module, Version: version})
|
||||||
|
if _, err := b.js.Publish(ctx, meshcatalog.SubjectVersionReleased, data); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
m, err := evs.Next(jetstream.FetchMaxWait(10 * time.Second))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
if !rv.heard(ctx, next("m4", "0.2.0")) {
|
||||||
|
t.Fatal("the reservations did not take version-released")
|
||||||
|
}
|
||||||
|
if _, standing, _ := rv.r.Of(ctx, "m4", "0.2.0"); standing || len(tagsWritten) != 0 {
|
||||||
|
t.Errorf("after version-released m4 0.2.0 standing %v, tags read or written %v: want it released and no tag read or written", standing, tagsWritten)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
mu.Lock()
|
|
||||||
if slices.Contains(sent, "dropme") || len(sent) != 101 {
|
|
||||||
t.Errorf("sent %d items (dropme among them: %v), want the 101 and never the dropped one", len(sent), slices.Contains(sent, "dropme"))
|
|
||||||
}
|
|
||||||
mu.Unlock()
|
|
||||||
|
|
||||||
// The move of the old state, run twice, puts each item once (at another holder, so the pull of oci is not asked).
|
// Design 47 H2 §794 (whole, H-A-453 (3), H-A-462): a message the builder's handler leaves unacknowledged is kept on its
|
||||||
old, err := b.js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: builds.StateBucket("mesh-delivery-builder", versions.PublishQueueState)})
|
// consumer's ledger in the state consumers on the bus; held six minutes, the health names that backlog, and within five
|
||||||
if err != nil {
|
// minutes it does not.
|
||||||
t.Fatal(err)
|
consumers, err := b.js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: builds.StateBucket(builds.BuilderModule, process.ConsumersState)})
|
||||||
}
|
|
||||||
var tagsWritten []string
|
|
||||||
call := func(tool string, body any) (json.RawMessage, error) {
|
|
||||||
switch tool {
|
|
||||||
case "seat:" + gitseat.Seat + "." + gitseat.VerbTags: // m4's 0.2.0 is tagged at another commit (§796)
|
|
||||||
return json.Marshal(gitseat.TagsAnswer{Form: 2, Tags: []gitseat.Tag{{Tag: "modules/m4/v0.2.0", Commit: "c-other"}}})
|
|
||||||
case "seat:" + gitseat.Seat + ".tag":
|
|
||||||
tagsWritten = append(tagsWritten, body.(gitseat.TagInput).Tag+"@"+body.(gitseat.TagInput).Commit)
|
|
||||||
return json.Marshal(gitseat.TagAnswer{Performed: true})
|
|
||||||
}
|
|
||||||
return json.Marshal(meshcatalog.VersionsAnswer{Module: "m"})
|
|
||||||
}
|
|
||||||
found := &memFindings{vals: map[string][]byte{}}
|
|
||||||
rv := newReservations(&memReserve{vals: map[string][]byte{}, revs: map[string]uint64{}}, call, func() jetstream.KeyValue { return &boundsKV{keys: map[string]bool{}} },
|
|
||||||
&findings{module: builds.BuilderModule, w: found, logf: t.Logf, now: time.Now}, nil, t.Logf)
|
|
||||||
rv.filled.Store(true)
|
|
||||||
type oldItem struct {
|
|
||||||
key string
|
|
||||||
raw []byte
|
|
||||||
}
|
|
||||||
var olds []oldItem
|
|
||||||
for _, m := range []string{"m1", "m2", "m3"} {
|
|
||||||
v, err := rv.Reserve(ctx, m, "0.1", []string{m + ":a"}, versions.Source{Fingerprint: "src2:" + m})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := rv.Built(ctx, m, v.Version, map[string]string{m + ":a": "sha256:a"}, nil); err != nil {
|
held := time.Now()
|
||||||
t.Fatal(err)
|
hub := &oneHandler{}
|
||||||
|
aged := agedHub{hub: hub, ledgers: &ledgers{logf: t.Logf, now: func() time.Time { return held },
|
||||||
|
sink: consumersSink(process.AwaitBucket(ctx, b.js, nil, builds.StateBucket(builds.BuilderModule, process.ConsumersState), "", t.Logf))}}
|
||||||
|
_ = aged.Handle(meshcatalog.SubjectVersionReleased, func(m jetstream.Msg) { _ = m.Nak() }) // a handler standing still: asked again
|
||||||
|
hub.handle(next("m5", "0.1.0"))
|
||||||
|
state := versions.Reader{Keys: func() ([]string, error) {
|
||||||
|
l, err := consumers.ListKeys(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var keys []string
|
||||||
|
for k := range l.Keys() {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
return keys, nil
|
||||||
|
}, Get: func(k string) (json.RawMessage, bool, error) {
|
||||||
|
e, err := consumers.Get(ctx, k)
|
||||||
|
if errors.Is(err, jetstream.ErrKeyNotFound) {
|
||||||
|
return nil, false, nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
return e.Value(), true, nil
|
||||||
|
}}
|
||||||
|
if a := versions.BuilderHealth(state, held.Add(6*time.Minute), 5*time.Minute); a.Healthy || !strings.Contains(a.Why, "builder-events (its oldest unacknowledged message waits 6m0s") {
|
||||||
|
t.Errorf("the health with a backlog held six minutes = %+v, want unhealthy naming builder-events", a)
|
||||||
}
|
}
|
||||||
raw, _ := json.Marshal(versions.QueuedPublish{V: 1, Holder: "go", Module: m, Version: v.Version, Artifacts: map[string]string{m + ":a": "sha256:a"}, Class: "asked-again-at-start"})
|
if a := versions.BuilderHealth(state, held.Add(4*time.Minute), 5*time.Minute); !a.Healthy {
|
||||||
if _, err := old.Put(ctx, versions.QueueKey("go", m, v.Version), raw); err != nil {
|
t.Errorf("the health four minutes in = %+v, want healthy", a)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
}
|
||||||
olds = append(olds, oldItem{versions.QueueKey("go", m, v.Version), raw})
|
})
|
||||||
}
|
|
||||||
rp := &versions.Republisher{Reserved: rv.r, Put: func(ctx context.Context, q versions.QueuedPublish) (bool, error) {
|
|
||||||
data, _ := json.Marshal(q)
|
|
||||||
ack, err := b.js.Publish(ctx, pq.subject(bind, q), data, jetstream.WithMsgID(versions.PublishMsgID(q.Holder, q.Class, q.Module, q.Version)))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return ack.Duplicate, nil
|
|
||||||
}, Started: time.Now(), Logf: t.Logf}
|
|
||||||
oldBucket := builds.StateBucket("mesh-delivery-builder", versions.PublishQueueState)
|
|
||||||
moveOld(ctx, b.js, oldBucket, rp, t.Logf)
|
|
||||||
if _, err := b.js.KeyValue(ctx, oldBucket); !errors.Is(err, jetstream.ErrBucketNotFound) {
|
|
||||||
t.Errorf("after the move the old state's bucket answers %v, want it removed by the builder (H-A-461 (1))", err)
|
|
||||||
}
|
|
||||||
// A start that stopped before the removal moves the same items again: the duplicates window keeps each once.
|
|
||||||
again, err := b.js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: oldBucket})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
for _, e := range olds {
|
|
||||||
if _, err := again.Put(ctx, e.key, e.raw); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
moveOld(ctx, b.js, oldBucket, rp, t.Logf)
|
|
||||||
moveOld(ctx, b.js, oldBucket, rp, t.Logf) // no bucket left: nothing moves
|
|
||||||
if _, err := b.js.KeyValue(ctx, oldBucket); !errors.Is(err, jetstream.ErrBucketNotFound) {
|
|
||||||
t.Errorf("after the second move the old state's bucket answers %v, want it removed", err)
|
|
||||||
}
|
|
||||||
st, err := b.js.Stream(ctx, bind.Stream)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
info, err := st.Info(ctx, jetstream.WithSubjectFilter(bind.Subject+".publish.go.>"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if len(info.State.Subjects) != 3 || info.State.Subjects[bind.Subject+".publish.go.again.m1.0=2E1=2E0"] != 1 {
|
|
||||||
t.Errorf("the move run twice left %v on the work queue: want each of the three once, as again", info.State.Subjects)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Design 47 H2 §796 (whole, H-A-453 (3)): a module's tags are read before it reserves; a number whose tag stands at another
|
|
||||||
// commit is skipped, the next number taken and version-tagged-elsewhere raised; the release tags <directory>/v<version> at
|
|
||||||
// the build's commit, and the module's version-released clears the finding.
|
|
||||||
rv.r.Names = func(context.Context, string, string) (string, bool, error) {
|
|
||||||
return "git.example/o/r/modules/m4", true, nil
|
|
||||||
}
|
|
||||||
// Design 47 H2 §821, §805: the reservation is said as the seat mesh-builds' version-reserved, said as the process says it
|
|
||||||
// (sayReservedOn), and waited on by the seat and the event's name.
|
|
||||||
rv.names, rv.sayReserved = rv.r.Names, sayReservedOn(b.js, process.Account{Module: builds.BuilderModule, Node: "n1"})
|
|
||||||
said, err := nats.Connect(b.srvURL, nats.UserInfo("ctl", "pw"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer said.Close()
|
|
||||||
reservedCh := make(chan *nats.Msg, 4)
|
|
||||||
rs, err := said.ChanSubscribe(meshbuilds.SubjectVersionReserved, reservedCh)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer rs.Unsubscribe()
|
|
||||||
if err := said.Flush(); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
v4, err := rv.Reserve(ctx, "m4", "0.2", []string{"m4:lib"}, versions.Source{Fingerprint: "src2:m4", GoPackage: true, GoArtifact: "lib",
|
|
||||||
Repository: "o/r", Commit: "c-mine", Branch: "main", CatalogRevision: 1})
|
|
||||||
elsewhere := views.FindingKey(meshconditionsclient.ScopeModule, "m4", versions.VersionTaggedElsewhere)
|
|
||||||
if _, raised := found.vals[elsewhere]; err != nil || v4.Version != "0.2.1" || v4.Tag != "modules/m4/v0.2.1" || !raised {
|
|
||||||
t.Fatalf("m4 reserved %+v (%v), %s raised %v: want 0.2.1 past 0.2.0's tag at another commit, its tag modules/m4/v0.2.1, and the finding", v4, err, elsewhere, raised)
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case m := <-reservedCh:
|
|
||||||
ev, _, err := meshbuilds.DecodeVersionReservedEvent(m.Data)
|
|
||||||
if err != nil || ev.Module != "m4" || ev.Artifact != "m4:lib" || ev.Path != "git.example/o/r/modules/m4" || ev.Version != "0.2.1" ||
|
|
||||||
ev.Fingerprint != "src2:m4" || ev.Revision != "main.1" || m.Header.Get("x-source") != builds.BuilderModule {
|
|
||||||
t.Errorf("version-reserved = %+v (%v) from %q, want m4:lib at 0.2.1, its path, fingerprint src2:m4 and revision main.1, said by the builder", ev, err, m.Header.Get("x-source"))
|
|
||||||
}
|
|
||||||
case <-time.After(10 * time.Second):
|
|
||||||
t.Fatal("no version-reserved of m4's reservation within 10 s on " + meshbuilds.SubjectVersionReserved)
|
|
||||||
}
|
|
||||||
catalogEvents, err := b.js.StreamNameBySubject(ctx, meshcatalog.SubjectVersionReleased) // the bed's stream of the catalog's events
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
evs, err := b.js.CreateOrUpdateConsumer(ctx, catalogEvents, jetstream.ConsumerConfig{Durable: "builder-events", AckPolicy: jetstream.AckExplicitPolicy,
|
|
||||||
FilterSubject: meshcatalog.SubjectVersionReleased, DeliverPolicy: jetstream.DeliverNewPolicy})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
next := func(module, version string) jetstream.Msg {
|
|
||||||
t.Helper()
|
|
||||||
data, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: module, Version: version})
|
|
||||||
if _, err := b.js.Publish(ctx, meshcatalog.SubjectVersionReleased, data); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
m, err := evs.Next(jetstream.FetchMaxWait(10 * time.Second))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
if !rv.heard(ctx, next("m4", "0.2.1")) {
|
|
||||||
t.Fatal("the reservations did not take version-released")
|
|
||||||
}
|
|
||||||
if _, raised := found.vals[elsewhere]; raised || !slices.Equal(tagsWritten, []string{"modules/m4/v0.2.1@c-mine"}) {
|
|
||||||
t.Errorf("after version-released %s raised %v, tags written %v: want it cleared and modules/m4/v0.2.1 written at c-mine, no tag moved", elsewhere, raised, tagsWritten)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Design 47 H2 §794 (whole, H-A-453 (3), H-A-462): a message the builder's handler leaves unacknowledged is kept on its
|
|
||||||
// consumer's ledger in the state consumers on the bus; held six minutes, the health names that backlog, and within five
|
|
||||||
// minutes it does not.
|
|
||||||
consumers, err := b.js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: builds.StateBucket(builds.BuilderModule, process.ConsumersState)})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
held := time.Now()
|
|
||||||
hub := &oneHandler{}
|
|
||||||
aged := agedHub{hub: hub, ledgers: &ledgers{logf: t.Logf, now: func() time.Time { return held },
|
|
||||||
sink: consumersSink(process.AwaitBucket(ctx, b.js, nil, builds.StateBucket(builds.BuilderModule, process.ConsumersState), "", t.Logf))}}
|
|
||||||
_ = aged.Handle(meshcatalog.SubjectVersionReleased, func(m jetstream.Msg) { _ = m.Nak() }) // a handler standing still: asked again
|
|
||||||
hub.handle(next("m5", "0.1.0"))
|
|
||||||
state := versions.Reader{Keys: func() ([]string, error) {
|
|
||||||
l, err := consumers.ListKeys(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var keys []string
|
|
||||||
for k := range l.Keys() {
|
|
||||||
keys = append(keys, k)
|
|
||||||
}
|
|
||||||
return keys, nil
|
|
||||||
}, Get: func(k string) (json.RawMessage, bool, error) {
|
|
||||||
e, err := consumers.Get(ctx, k)
|
|
||||||
if errors.Is(err, jetstream.ErrKeyNotFound) {
|
|
||||||
return nil, false, nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, false, err
|
|
||||||
}
|
|
||||||
return e.Value(), true, nil
|
|
||||||
}}
|
|
||||||
if a := versions.BuilderHealth(state, held.Add(6*time.Minute), 5*time.Minute); a.Healthy || !strings.Contains(a.Why, "builder-events (its oldest unacknowledged message waits 6m0s") {
|
|
||||||
t.Errorf("the health with a backlog held six minutes = %+v, want unhealthy naming builder-events", a)
|
|
||||||
}
|
|
||||||
if a := versions.BuilderHealth(state, held.Add(4*time.Minute), 5*time.Minute); !a.Healthy {
|
|
||||||
t.Errorf("the health four minutes in = %+v, want healthy", a)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -531,9 +530,9 @@ func builtOf(all []versions.ReservedVersion) []versions.ReservedVersion {
|
|||||||
// the manifest's old streams section with the work-queue retention, the module's own, consumed by the module's one process on the
|
// the manifest's old streams section with the work-queue retention, the module's own, consumed by the module's one process on the
|
||||||
// module's account (H-A-464), which declares no bus and so is the stream's one reader by the module's shape; each item on
|
// module's account (H-A-464), which declares no bus and so is the stream's one reader by the module's shape; each item on
|
||||||
// `mesh.stream.<module>.event.publish.<holder>.<class>.<module>.<version>` under the message id
|
// `mesh.stream.<module>.event.publish.<holder>.<class>.<module>.<version>` under the message id
|
||||||
// `<holder>.<class>.<module>.<version>`. The builder makes the pull consumers at run time as it learns a holder,
|
// `<holder>.<class>.<module>.<version>`. The builder makes one pull consumer at run time as it learns a holder,
|
||||||
// `publishes-<holder>-<class>`, with ack wait publish-pause-max, max ack pending four and max deliveries ten, and pulls the live
|
// `publishes-<holder>`, with ack wait publish-pause-max, max ack pending four and max deliveries ten, and sends its items in the
|
||||||
// class first, at most four sends at once per holder.
|
// order the consumer gives them, at most four at once per holder (H-A-483 and its addenda).
|
||||||
type publishQueue struct {
|
type publishQueue struct {
|
||||||
js jetstream.JetStream
|
js jetstream.JetStream
|
||||||
binding func() (publishesStream, error)
|
binding func() (publishesStream, error)
|
||||||
@@ -555,16 +554,16 @@ func publishesOf(module string) func() (publishesStream, error) {
|
|||||||
return func() (publishesStream, error) { return b, nil }
|
return func() (publishesStream, error) { return b, nil }
|
||||||
}
|
}
|
||||||
|
|
||||||
// The consumers' numbers (H-A-446 (2)): at most four sends in flight per holder and class, and ten deliveries, the work queue's
|
// The consumer's numbers (H-A-446 (2)): at most four sends in flight per holder, and ten deliveries, the work queue's largest;
|
||||||
// largest; the builder ends an item at publish-tries anyway.
|
// the builder ends an item at publish-tries anyway.
|
||||||
const (
|
const (
|
||||||
publishesMaxAckPending = versions.PublishSendsAtOnce
|
publishesMaxAckPending = versions.PublishSendsAtOnce
|
||||||
publishesMaxDeliver = 10
|
publishesMaxDeliver = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
// publishesConsumer is the durable consumer of holder's items of class.
|
// publishesConsumer is the one durable consumer of holder's items (H-A-483 addendum).
|
||||||
func publishesConsumer(holder, class string) string {
|
func publishesConsumer(holder string) string {
|
||||||
return versions.PublishesLocal + "-" + holder + "-" + class
|
return versions.PublishesLocal + "-" + holder
|
||||||
}
|
}
|
||||||
|
|
||||||
// subject is the item's subject on the bus.
|
// subject is the item's subject on the bus.
|
||||||
@@ -616,8 +615,15 @@ func (pq *publishQueue) learnAll(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// learn starts holder's pull once.
|
// learn starts holder's pull once. A holder is a module name, so one ending in -live or -again, the class durables an earlier
|
||||||
|
// release made, is refused, said (H-A-483, third addendum): its consumer would be another holder's old durable.
|
||||||
func (pq *publishQueue) learn(ctx context.Context, holder string) {
|
func (pq *publishQueue) learn(ctx context.Context, holder string) {
|
||||||
|
for _, class := range []string{versions.PublishClassLive, versions.PublishClassStart} {
|
||||||
|
if strings.HasSuffix(holder, "-"+class) {
|
||||||
|
pq.logf("the publishes of %s are refused: a holder is a module name, and one ending in -%s names the class durable of an earlier release (H-A-483)", holder, class)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
pq.mu.Lock()
|
pq.mu.Lock()
|
||||||
if pq.pulling == nil {
|
if pq.pulling == nil {
|
||||||
pq.pulling = map[string]bool{}
|
pq.pulling = map[string]bool{}
|
||||||
@@ -636,94 +642,71 @@ func (pq *publishQueue) learn(ctx context.Context, holder string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pull makes holder's two consumers and dispatches their items, the live class first, at most four sends at once: an again item
|
// pull makes holder's one consumer and dispatches its items (design 47 H2 §793, H-A-483 and its addenda): first it retires the
|
||||||
// waits while a live one waits on the queue.
|
// holder's class durables an earlier release made (`-live`, `-again`), whose filters a work queue refuses beside the one; their
|
||||||
|
// unacknowledged items stay on the queue and reach the one consumer.
|
||||||
func (pq *publishQueue) pull(ctx context.Context, holder string) error {
|
func (pq *publishQueue) pull(ctx context.Context, holder string) error {
|
||||||
b, err := pq.binding()
|
b, err := pq.binding()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
chans := map[string]chan jetstream.Msg{}
|
for _, class := range []string{versions.PublishClassLive, versions.PublishClassStart} {
|
||||||
var live jetstream.Consumer
|
old := publishesConsumer(holder) + "-" + class
|
||||||
for _, class := range []string{versions.PublishClassStart, versions.PublishClassLive} { // the again first: the live is first by the dispatch, not by luck
|
err := pq.js.DeleteConsumer(ctx, b.Stream, old)
|
||||||
c, err := pq.js.CreateOrUpdateConsumer(ctx, b.Stream, jetstream.ConsumerConfig{Durable: publishesConsumer(holder, class),
|
switch {
|
||||||
FilterSubject: b.Subject + ".publish." + versions.EscapeToken(holder) + "." + class + ".>", AckPolicy: jetstream.AckExplicitPolicy,
|
case err == nil:
|
||||||
AckWait: pq.ackWait, MaxAckPending: publishesMaxAckPending, MaxDeliver: publishesMaxDeliver})
|
pq.logf("the consumer %s of an earlier release is removed: the publishes of %s have one consumer (H-A-483)", old, holder)
|
||||||
if err != nil {
|
case !errors.Is(err, jetstream.ErrConsumerNotFound):
|
||||||
return fmt.Errorf("the consumer %s: %w", publishesConsumer(holder, class), err)
|
return fmt.Errorf("the consumer %s of an earlier release is not removed: %w", old, err)
|
||||||
}
|
|
||||||
ch := make(chan jetstream.Msg, publishesMaxAckPending)
|
|
||||||
cc, err := c.Consume(func(m jetstream.Msg) { ch <- m }, jetstream.PullMaxMessages(publishesMaxAckPending))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("the consumer %s is not pulled: %w", publishesConsumer(holder, class), err)
|
|
||||||
}
|
|
||||||
go func() { <-ctx.Done(); cc.Stop() }()
|
|
||||||
chans[class] = ch
|
|
||||||
if class == versions.PublishClassLive {
|
|
||||||
live = c
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
liveWaits := func() bool {
|
c, err := pq.js.CreateOrUpdateConsumer(ctx, b.Stream, jetstream.ConsumerConfig{Durable: publishesConsumer(holder),
|
||||||
info, err := live.Info(ctx)
|
FilterSubject: b.Subject + ".publish." + versions.EscapeToken(holder) + ".>", AckPolicy: jetstream.AckExplicitPolicy,
|
||||||
return err == nil && info.NumPending > 0
|
AckWait: pq.ackWait, MaxAckPending: publishesMaxAckPending, MaxDeliver: publishesMaxDeliver})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("the consumer %s: %w", publishesConsumer(holder), err)
|
||||||
}
|
}
|
||||||
pq.logf("pulling the publishes of %s, the live first", holder)
|
pq.logf("pulling the publishes of %s", holder)
|
||||||
go pq.dispatch(ctx, chans[versions.PublishClassLive], chans[versions.PublishClassStart], liveWaits)
|
go pq.dispatch(ctx, holder, c)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// dispatch runs the items of one holder, at most four at once, every live item before an again one: an again item pulled while
|
// dispatch runs the items of one holder in the order its one consumer gives them, at most four at once (design 47 H2 §793,
|
||||||
// a live one waits on the queue (liveWaits) runs after it.
|
// H-A-483): each free slot takes the next item through a pull that waits, so an item put or handed back after its pause is
|
||||||
func (pq *publishQueue) dispatch(ctx context.Context, live, again <-chan jetstream.Msg, liveWaits func() bool) {
|
// received the moment the bus gives it; an item handed back reappears only after its pause, so an item put meanwhile goes
|
||||||
|
// before it. A pull the bus refuses ends the dispatch, said; the holder is pulled again when an item of it is put.
|
||||||
|
func (pq *publishQueue) dispatch(ctx context.Context, holder string, c jetstream.Consumer) {
|
||||||
sem := make(chan struct{}, versions.PublishSendsAtOnce)
|
sem := make(chan struct{}, versions.PublishSendsAtOnce)
|
||||||
run := func(m jetstream.Msg) {
|
|
||||||
go func() {
|
|
||||||
defer func() { <-sem }()
|
|
||||||
pq.take(ctx, m)
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
var spare jetstream.Msg // an again item pulled while a live one waited
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case sem <- struct{}{}:
|
case sem <- struct{}{}:
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
select {
|
var got jetstream.Msg
|
||||||
case m := <-live:
|
b, err := c.Fetch(1)
|
||||||
run(m)
|
if err == nil {
|
||||||
continue
|
for m := range b.Messages() {
|
||||||
default:
|
got = m
|
||||||
}
|
|
||||||
m := spare
|
|
||||||
spare = nil
|
|
||||||
if m == nil {
|
|
||||||
select {
|
|
||||||
case lm := <-live:
|
|
||||||
run(lm)
|
|
||||||
continue
|
|
||||||
case m = <-again:
|
|
||||||
case <-ctx.Done():
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
err = b.Error()
|
||||||
}
|
}
|
||||||
if liveWaits() {
|
if err != nil && !errors.Is(err, jetstream.ErrNoMessages) && !errors.Is(err, nats.ErrTimeout) && ctx.Err() == nil {
|
||||||
spare = m
|
<-sem
|
||||||
select {
|
pq.logf("the publishes of %s are not pulled: %v; they are pulled when an item of it is put", holder, err)
|
||||||
case lm := <-live:
|
pq.mu.Lock()
|
||||||
run(lm)
|
delete(pq.pulling, holder)
|
||||||
case <-ctx.Done():
|
pq.mu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if got == nil {
|
||||||
|
<-sem
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
select {
|
go func(m jetstream.Msg) {
|
||||||
case lm := <-live: // came while the queue was asked
|
defer func() { <-sem }()
|
||||||
spare = m
|
pq.take(ctx, m)
|
||||||
run(lm)
|
}(got)
|
||||||
default:
|
|
||||||
run(m)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,45 +810,6 @@ func (pq *publishQueue) drop(ctx context.Context, items *publishItems, module, v
|
|||||||
return fmt.Sprintf("the publish of %s %s is dropped: %d items terminated, and none is sent or put again", module, version, len(qs)), nil
|
return fmt.Sprintf("the publish of %s %s is dropped: %d items terminated, and none is sent or put again", module, version, len(qs)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// first is builder_publish_first (§793): each again item of the version is put again as live, under the message id
|
|
||||||
// `<holder>.live.<module>.<version>`, and the old terminated; a live id the queue holds within its window takes nothing, and the
|
|
||||||
// old stays, said.
|
|
||||||
func (pq *publishQueue) first(ctx context.Context, items *publishItems, module, version string) (string, error) {
|
|
||||||
qs, st, err := pq.itemsOf(ctx, module, version, versions.PublishClassStart)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("the work queue %s cannot be read: %w", versions.PublishesLocal, err)
|
|
||||||
}
|
|
||||||
if len(qs) == 0 {
|
|
||||||
return "", fmt.Errorf("the work queue %s holds no again item of %s %s", versions.PublishesLocal, module, version)
|
|
||||||
}
|
|
||||||
var moved, kept []string
|
|
||||||
for subj, q := range qs {
|
|
||||||
q.Class = versions.PublishClassLive
|
|
||||||
dup, err := pq.put(ctx, q)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("%s %s is not put again as live at %s: %w", module, version, q.Holder, err)
|
|
||||||
}
|
|
||||||
if dup {
|
|
||||||
kept = append(kept, q.Holder)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err := st.Purge(ctx, jetstream.WithPurgeSubject(subj)); err != nil {
|
|
||||||
return "", fmt.Errorf("the again item of %s %s at %s is not terminated: %w", module, version, q.Holder, err)
|
|
||||||
}
|
|
||||||
moved = append(moved, q.Holder)
|
|
||||||
}
|
|
||||||
for _, h := range items.settle(module, version, func(h heldItem) bool { return h.q.Class == versions.PublishClassStart }) {
|
|
||||||
_ = h.m.Term()
|
|
||||||
}
|
|
||||||
sort.Strings(moved)
|
|
||||||
answer := fmt.Sprintf("%s %s is put first as live at %s, its again item terminated", module, version, strings.Join(moved, ", "))
|
|
||||||
if len(kept) > 0 {
|
|
||||||
sort.Strings(kept)
|
|
||||||
answer += fmt.Sprintf("; at %s the work queue holds its live id within the duplicates window, so its again item stays", strings.Join(kept, ", "))
|
|
||||||
}
|
|
||||||
return answer, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// endItem writes the version's publish item ended with answer, made when none stands: Try and take then leave it, and a start
|
// endItem writes the version's publish item ended with answer, made when none stands: Try and take then leave it, and a start
|
||||||
// asks it no more.
|
// asks it no more.
|
||||||
func (p *publishItems) endItem(ctx context.Context, module, version, answer string) error {
|
func (p *publishItems) endItem(ctx context.Context, module, version, answer string) error {
|
||||||
|
|||||||
@@ -440,3 +440,17 @@ func TestAPublishIsNotAskedAgainWhileItsPublishedMayBeUnheard(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Design 47 H2 H-A-483 (third addendum): a holder is a module name, so one ending in -live or -again, the class durables of an
|
||||||
|
// earlier release, is refused at the learn, said, and nothing of it is pulled.
|
||||||
|
func TestAHolderNamedLikeAClassDurableIsRefused(t *testing.T) {
|
||||||
|
for _, holder := range []string{"oci-live", "oci-again"} {
|
||||||
|
var said []string
|
||||||
|
pq := &publishQueue{logf: func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) },
|
||||||
|
binding: func() (publishesStream, error) { return publishesStream{}, errors.New("no bus in a unit test") }}
|
||||||
|
pq.learn(context.Background(), holder)
|
||||||
|
if len(said) != 1 || !strings.Contains(said[0], "the publishes of "+holder+" are refused") || pq.pulling[holder] {
|
||||||
|
t.Errorf("%s: said %q, pulling %v, want it refused at the learn, said once, nothing pulled", holder, said, pq.pulling[holder])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, items *publi
|
|||||||
released(ctx, b, kv, e, r, logf)
|
released(ctx, b, kv, e, r, logf)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModePublishFirst || r.Mode == build.ModeFloorAgain || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone {
|
if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeFloorAgain || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone {
|
||||||
// A version's hand act (design 51 *Tools of the builder*) may build again, so it is answered beside the watch.
|
// A version's hand act (design 51 *Tools of the builder*) may build again, so it is answered beside the watch.
|
||||||
go versionActed(ctx, acts, kv, e, r, logf)
|
go versionActed(ctx, acts, kv, e, r, logf)
|
||||||
return
|
return
|
||||||
@@ -208,11 +208,8 @@ func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue
|
|||||||
r.Answer = "queued " + fmt.Sprint(len(r.Queued)) + " versions to publish again: " + strings.Join(r.Queued, ", ") + "; builder_publish_queue shows them"
|
r.Answer = "queued " + fmt.Sprint(len(r.Queued)) + " versions to publish again: " + strings.Join(r.Queued, ", ") + "; builder_publish_queue shows them"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if r.Mode == build.ModePublishDrop || r.Mode == build.ModePublishFirst {
|
} else if r.Mode == build.ModePublishDrop {
|
||||||
act := acts.PublishDrop
|
act := acts.PublishDrop
|
||||||
if r.Mode == build.ModePublishFirst {
|
|
||||||
act = acts.PublishFirst
|
|
||||||
}
|
|
||||||
if act == nil {
|
if act == nil {
|
||||||
err = errors.New("this builder keeps no work queue of publishes")
|
err = errors.New("this builder keeps no work queue of publishes")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
"github.com/nats-io/nats.go/jetstream"
|
"github.com/nats-io/nats.go/jetstream"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git"
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
"git.novox.be/novox/mesh-sdk/go/process"
|
"git.novox.be/novox/mesh-sdk/go/process"
|
||||||
|
|
||||||
@@ -57,8 +56,9 @@ type reservations struct {
|
|||||||
logf func(string, ...any)
|
logf func(string, ...any)
|
||||||
// withdraw ends the running build of a module's fingerprint, superseded, with why (H-A-225); nil ends none.
|
// withdraw ends the running build of a module's fingerprint, superseded, with why (H-A-225); nil ends none.
|
||||||
withdraw func(module, fingerprint, why string)
|
withdraw func(module, fingerprint, why string)
|
||||||
// call asks a seat's verb: the git seat's tag (design 47 G §370).
|
// recordAgain records the digests of a done build of module at fp its end did not record, saying so (design 47 H2 H-A-492);
|
||||||
call toolCaller
|
// nil records none.
|
||||||
|
recordAgain func(ctx context.Context, module, fp, when string) (string, error)
|
||||||
// rebuild builds a done key of module at fp again (the build-again path, A-490; H-A-279); nil builds none.
|
// rebuild builds a done key of module at fp again (the build-again path, A-490; H-A-279); nil builds none.
|
||||||
rebuild func(ctx context.Context, module, fp, why string) error
|
rebuild func(ctx context.Context, module, fp, why string) error
|
||||||
// say says package-published on the seat mesh-builds; nil says none.
|
// say says package-published on the seat mesh-builds; nil says none.
|
||||||
@@ -117,7 +117,7 @@ func sayReservedOn(js jetstream.JetStream, cred process.Account) func(context.Co
|
|||||||
// newReservations makes the reserving over store; the released versions of a module are asked of the seat mesh-catalog's
|
// newReservations makes the reserving over store; the released versions of a module are asked of the seat mesh-catalog's
|
||||||
// verb versions through call (design 47 G §348), the only source numbering reads them from.
|
// verb versions through call (design 47 G §348), the only source numbering reads them from.
|
||||||
func newReservations(store versions.ReserveStore, call toolCaller, bounds func() jetstream.KeyValue, found *findings, wake func(context.Context), logf func(string, ...any)) *reservations {
|
func newReservations(store versions.ReserveStore, call toolCaller, bounds func() jetstream.KeyValue, found *findings, wake func(context.Context), logf func(string, ...any)) *reservations {
|
||||||
rv := &reservations{call: call, bounds: bounds, found: found, bound: versions.UnreleasedBound, wake: wake, logf: logf}
|
rv := &reservations{bounds: bounds, found: found, bound: versions.UnreleasedBound, wake: wake, logf: logf}
|
||||||
rv.r = &versions.Reserver{Store: store, Filled: rv.filled.Load, ReleasedOf: func(_ context.Context, module string) ([]string, error) {
|
rv.r = &versions.Reserver{Store: store, Filled: rv.filled.Load, ReleasedOf: func(_ context.Context, module string) ([]string, error) {
|
||||||
raw, err := call("seat:"+meshcatalog.Seat+".versions", meshcatalog.VersionsInput{Module: module})
|
raw, err := call("seat:"+meshcatalog.Seat+".versions", meshcatalog.VersionsInput{Module: module})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -134,8 +134,6 @@ func newReservations(store versions.ReserveStore, call toolCaller, bounds func()
|
|||||||
return out, nil
|
return out, nil
|
||||||
}}
|
}}
|
||||||
rv.r.Took, rv.r.Logf, rv.r.Reserved = rv.took, logf, rv.reservedSaid
|
rv.r.Took, rv.r.Logf, rv.r.Reserved = rv.took, logf, rv.reservedSaid
|
||||||
// A module's tags are read before it reserves, and a number tagged at another commit skipped (design 47 H2 §796).
|
|
||||||
rv.r.Tags, rv.r.TaggedElsewhere = tagsVia(call), rv.taggedElsewhere
|
|
||||||
return rv
|
return rv
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,7 +308,7 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
|
|||||||
rv.logf("%s holds what is no version-released, left: %v", m.Subject(), err)
|
rv.logf("%s holds what is no version-released, left: %v", m.Subject(), err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err := rv.tagged(ctx, ev); err != nil {
|
if err := rv.release(ctx, ev); err != nil {
|
||||||
rv.logf("%v; heard again", err)
|
rv.logf("%v; heard again", err)
|
||||||
if nakErr := m.Nak(); nakErr != nil {
|
if nakErr := m.Nak(); nakErr != nil {
|
||||||
rv.logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr)
|
rv.logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr)
|
||||||
@@ -318,24 +316,6 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
|
|||||||
givenUp(m, "the version-released of "+ev.Module+" "+ev.Version, err, rv.logf)
|
givenUp(m, "the version-released of "+ev.Module+" "+ev.Version, err, rv.logf)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
gone, err := rv.r.Released(ctx, ev.Module, ev.Version)
|
|
||||||
if err != nil {
|
|
||||||
rv.logf("%v; heard again", err)
|
|
||||||
if nakErr := m.Nak(); nakErr != nil {
|
|
||||||
rv.logf("leaving %s for the bus to give again: %v", m.Subject(), nakErr)
|
|
||||||
}
|
|
||||||
givenUp(m, "the version-released of "+ev.Module+" "+ev.Version, err, rv.logf)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
for _, k := range gone {
|
|
||||||
rv.dropBound(ctx, k)
|
|
||||||
}
|
|
||||||
if rv.released != nil {
|
|
||||||
rv.released(ctx, ev.Module, ev.Version)
|
|
||||||
}
|
|
||||||
rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, ev.Module)
|
|
||||||
rv.found.clear(ctx, versions.VersionHeldElsewhere, meshconditionsclient.ScopeModule, ev.Module)
|
|
||||||
rv.found.clear(ctx, versions.VersionTaggedElsewhere, meshconditionsclient.ScopeModule, ev.Module)
|
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -345,6 +325,87 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// release takes a released version in as the catalog's version-released says it (design 47 G §369): its reservation released,
|
||||||
|
// its bound and publish item ended and its findings cleared. No git tag is written (design 47 H2 H-A-494).
|
||||||
|
func (rv *reservations) release(ctx context.Context, ev meshcatalog.VersionReleasedEvent) error {
|
||||||
|
gone, err := rv.r.Released(ctx, ev.Module, ev.Version)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, k := range gone {
|
||||||
|
rv.dropBound(ctx, k)
|
||||||
|
}
|
||||||
|
if rv.released != nil {
|
||||||
|
rv.released(ctx, ev.Module, ev.Version)
|
||||||
|
}
|
||||||
|
rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, ev.Module)
|
||||||
|
rv.found.clear(ctx, versions.VersionHeldElsewhere, meshconditionsclient.ScopeModule, ev.Module)
|
||||||
|
rv.found.clear(ctx, versions.VersionTaggedElsewhere, meshconditionsclient.ScopeModule, ev.Module) // one raised before H-A-494
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// releasedAtStart takes in, at the builder's start, every built, unreleased reservation whose version the catalog's verb versions
|
||||||
|
// holds released, as its version-released would (design 47 H2 H-A-484 addendum): a version-released the bus gave up on, or one
|
||||||
|
// said while the builder was away, is taken all the same, its reservation released and its publish item ended; no tag is written
|
||||||
|
// (design 47 H2 H-A-494).
|
||||||
|
// A module whose versions cannot be read, and a release that is not taken, are said and left to its next version-released.
|
||||||
|
// Before that, a standing reservation with no digests recorded whose build key is done has them recorded from the done key
|
||||||
|
// (design 47 H2 H-A-492), so it is held against the released versions too.
|
||||||
|
func (rv *reservations) releasedAtStart(ctx context.Context) {
|
||||||
|
all, err := rv.r.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
rv.logf("the reservations are not held against the catalog's released versions at the start: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if rv.recordedAtStart(ctx, all) {
|
||||||
|
if all, err = rv.r.All(ctx); err != nil {
|
||||||
|
rv.logf("the reservations are not held against the catalog's released versions at the start: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read := map[string][]string{}
|
||||||
|
for _, v := range builtOf(all) {
|
||||||
|
if versions.NotStanding(v, true) != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
released, ok := read[v.Module]
|
||||||
|
if !ok {
|
||||||
|
if released, err = rv.r.ReleasedOf(ctx, v.Module); err != nil {
|
||||||
|
rv.logf("%s: the catalog's released versions cannot be read at the start, so its built reservations wait for its next version-released: %v", v.Module, err)
|
||||||
|
}
|
||||||
|
read[v.Module] = released
|
||||||
|
}
|
||||||
|
if !slices.Contains(released, v.Version) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := rv.release(ctx, meshcatalog.VersionReleasedEvent{Module: v.Module, Version: v.Version}); err != nil {
|
||||||
|
rv.logf("%s %s is released in the catalog and not taken in at the start: %v", v.Module, v.Version, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
rv.logf("%s %s is released in the catalog: taken in at the start, as its version-released", v.Module, v.Version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// recordedAtStart records the digests of every standing reservation that has none recorded and whose build key is done (design 47
|
||||||
|
// H2 H-A-492): a record its build's end lost. It answers whether one was recorded; one that cannot be is said.
|
||||||
|
func (rv *reservations) recordedAtStart(ctx context.Context, all []versions.ReservedVersion) bool {
|
||||||
|
if rv.recordAgain == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
recorded := false
|
||||||
|
for _, v := range all {
|
||||||
|
if !v.BuiltAt.IsZero() || v.Fingerprint == "" || versions.NotStanding(v, true) != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
version, err := rv.recordAgain(ctx, v.Module, v.Fingerprint, "at the builder's start")
|
||||||
|
if err != nil {
|
||||||
|
rv.logf("%v", err)
|
||||||
|
}
|
||||||
|
recorded = recorded || version != ""
|
||||||
|
}
|
||||||
|
return recorded
|
||||||
|
}
|
||||||
|
|
||||||
// published marks the artifacts of the reservation a registry seat's published names (its version and digest). inProgress is told
|
// published marks the artifacts of the reservation a registry seat's published names (its version and digest). inProgress is told
|
||||||
// before a pass that may read many reservations, so the handler says in progress to the bus (design 47 H H-A-280); nil is told
|
// before a pass that may read many reservations, so the handler says in progress to the bus (design 47 H H-A-280); nil is told
|
||||||
// nothing.
|
// nothing.
|
||||||
@@ -404,33 +465,6 @@ func (rv *reservations) dropped(ctx context.Context, module, series, by, why str
|
|||||||
return fmt.Sprintf("the reservation of %s %s is dropped (%s, %s)", module, series, by, why), nil
|
return fmt.Sprintf("the reservation of %s %s is dropped (%s, %s)", module, series, by, why), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// tagged writes the git tag of a released version (design 47 G §370): on the catalog's version-released, through the seat
|
|
||||||
// git's verb tag, at the commit the reservation of that version was made from. A version with no reservation (a superseded
|
|
||||||
// build's version is never released, and the key of a version released by another builder is gone) or one that names no
|
|
||||||
// tag (a module with no Go package) is tagged nowhere. A tag the forge could not write is an error, the message heard again.
|
|
||||||
func (rv *reservations) tagged(ctx context.Context, ev meshcatalog.VersionReleasedEvent) error {
|
|
||||||
res, found, err := rv.r.Of(ctx, ev.Module, ev.Version)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("the reservation of %s %s cannot be read to tag it: %w", ev.Module, ev.Version, err)
|
|
||||||
}
|
|
||||||
if !found || res.Tag == "" || res.Commit == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
raw, err := rv.call("seat:"+git.Seat+".tag", git.TagInput{Repository: res.Repository, Commit: res.Commit, Tag: res.Tag})
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("the tag %s of %s is not written: %w", res.Tag, ev.Module, err)
|
|
||||||
}
|
|
||||||
var a git.TagAnswer
|
|
||||||
if err := json.Unmarshal(raw, &a); err != nil {
|
|
||||||
return fmt.Errorf("the git seat answered what is no tag answer for %s: %w", res.Tag, err)
|
|
||||||
}
|
|
||||||
if a.Error != "" || !a.Performed {
|
|
||||||
return fmt.Errorf("the tag %s of %s is not written: %s (%s)", res.Tag, ev.Module, a.Error, a.ErrorKind)
|
|
||||||
}
|
|
||||||
rv.logf("%s is tagged %s at %s", ev.Module, res.Tag, res.Commit)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// noMark says why a published marked nothing, from the reservations the published read (design 47 H H-A-280: no second read):
|
// noMark says why a published marked nothing, from the reservations the published read (design 47 H H-A-280: no second read):
|
||||||
// what each holds of digests, and how many stand at that version by the index by version (its one key, no reservation read).
|
// what each holds of digests, and how many stand at that version by the index by version (its one key, no reservation read).
|
||||||
func (rv *reservations) noMark(ctx context.Context, o versions.Outcome, read []versions.ReadReservation) string {
|
func (rv *reservations) noMark(ctx context.Context, o versions.Outcome, read []versions.ReadReservation) string {
|
||||||
@@ -502,19 +536,6 @@ func (rv *reservations) heldElsewhere(ctx context.Context, module, why string) {
|
|||||||
needs: "builder_reserved shows the reservation and its withdrawn numbers; the registry seat's versions shows what it holds."})
|
needs: "builder_reserved shows the reservation and its withdrawn numbers; the registry seat's versions shows what it holds."})
|
||||||
}
|
}
|
||||||
|
|
||||||
// taggedElsewhere raises version-tagged-elsewhere about module (design 47 H2 §796): numbers whose git tag stands at another
|
|
||||||
// commit were skipped at reserving; a tag is never moved. Cleared at the module's next version-released.
|
|
||||||
func (rv *reservations) taggedElsewhere(ctx context.Context, module string, skipped []string) {
|
|
||||||
why := "the tags of " + strings.Join(skipped, ", ") + " stand at another commit, so the reserve skipped them"
|
|
||||||
rv.logf("%s: %s", module, why)
|
|
||||||
rv.found.raise(ctx, finding{kind: versions.VersionTaggedElsewhere, scope: meshconditionsclient.ScopeModule, id: module,
|
|
||||||
summary: module + ": " + why,
|
|
||||||
headline: "A number whose tag stands at another commit is not used",
|
|
||||||
explanation: "The repository holds a tag of " + module + " at a commit other than the build's: " + why + ". A tag is never moved.",
|
|
||||||
resolved: "The catalog says version-released for " + module + ".",
|
|
||||||
needs: "builder_reserved shows the reservation; the seat git's tags shows each tag with its commit."})
|
|
||||||
}
|
|
||||||
|
|
||||||
// movedElsewhere takes a done build whose number a registry holds at another digest off that number (design 47 H H-A-275,
|
// movedElsewhere takes a done build whose number a registry holds at another digest off that number (design 47 H H-A-275,
|
||||||
// H-A-279): every artifact carries its version from its build, so no digest survives a move. The number is withdrawn as a gap
|
// H-A-279): every artifact carries its version from its build, so no digest survives a move. The number is withdrawn as a gap
|
||||||
// (H-A-226), the finding raised naming both digests, and the build of the same fingerprint asked again (the build-again path of a
|
// (H-A-226), the finding raised naming both digests, and the build of the same fingerprint asked again (the build-again path of a
|
||||||
|
|||||||
@@ -156,89 +156,117 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestAReleasedVersionIsTaggedAtTheCommitItWasBuiltFrom: design 47 G §370 — the git tag go/vMAJOR.MINOR.PATCH is written through
|
// TestAReleasedVersionWritesNoTag: design 47 H2 H-A-494 — the builder writes no git tag at a release, and numbers a series from the
|
||||||
// the seat git's tag on the catalog's version-released, at the commit the version's reservation was made from; a module with no
|
// catalog's versions and the registries' alone: the catalog's version-released releases the reservation with no call of the seat
|
||||||
// Go package, and a version never released (a superseded build's), are tagged nowhere; a tag the forge did not write leaves
|
// git, a reservation written before (one naming a tag) included; the start's take-in of a version the catalog holds released
|
||||||
// version-released to be heard again with the reservation standing.
|
// (H-A-484 c) the same; and a reserve reads no git tag, a tag standing at another commit no reason to skip a number.
|
||||||
func TestAReleasedVersionIsTaggedAtTheCommitItWasBuiltFrom(t *testing.T) {
|
func TestAReleasedVersionWritesNoTag(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
var tags []git.TagInput
|
var gitCalls []string // every call of the seat git: none is made
|
||||||
refuse := ""
|
var catalog []meshcatalog.VersionEntry // the released versions the catalog's verb versions answers
|
||||||
var standing []git.Tag // the tags the seat git's tags answers (design 47 H2 §796)
|
|
||||||
call := func(addr string, body any) (json.RawMessage, error) {
|
call := func(addr string, body any) (json.RawMessage, error) {
|
||||||
switch addr {
|
if strings.HasPrefix(addr, "seat:git.") {
|
||||||
case "seat:git.tags":
|
gitCalls = append(gitCalls, addr)
|
||||||
return json.Marshal(map[string]any{"form": 2, "tags": standing, "a-field-of-a-later-form": true})
|
if addr == "seat:git.tags" { // a tag standing at another commit, as the forge may still hold one
|
||||||
case "seat:git.tag":
|
return json.Marshal(map[string]any{"form": 2, "tags": []git.Tag{{Tag: "go/v0.2.0", Commit: "elsewhere"}}})
|
||||||
default:
|
}
|
||||||
return json.Marshal(meshcatalog.VersionsAnswer{})
|
return json.Marshal(git.TagAnswer{Performed: true})
|
||||||
}
|
}
|
||||||
tags = append(tags, body.(git.TagInput))
|
return json.Marshal(meshcatalog.VersionsAnswer{Versions: catalog})
|
||||||
return json.Marshal(git.TagAnswer{Performed: refuse == "", Error: refuse})
|
|
||||||
}
|
}
|
||||||
fw := &memFindings{vals: map[string][]byte{}}
|
fw := &memFindings{vals: map[string][]byte{}}
|
||||||
found := &findings{module: builds.BuilderModule, w: fw, logf: t.Logf, now: func() time.Time { return time.Unix(0, 0) }}
|
found := &findings{module: builds.BuilderModule, w: fw, logf: t.Logf, now: func() time.Time { return time.Unix(0, 0) }}
|
||||||
rv := newReservations(&memReserve{vals: map[string][]byte{}, revs: map[string]uint64{}}, call, func() jetstream.KeyValue { return &boundsKV{keys: map[string]bool{}} }, found, nil, t.Logf)
|
store := &memReserve{vals: map[string][]byte{}, revs: map[string]uint64{}}
|
||||||
|
rv := newReservations(store, call, func() jetstream.KeyValue { return &boundsKV{keys: map[string]bool{}} }, found, nil, t.Logf)
|
||||||
rv.filled.Store(true)
|
rv.filled.Store(true)
|
||||||
// Design 47 H2 §796: the tag names the Go module's directory, read from its module path: mesh-sdk's `go` here.
|
rv.names = func(_ context.Context, _, artifact string) (string, bool, error) {
|
||||||
rv.r.Names = func(_ context.Context, module, artifact string) (string, bool, error) {
|
return "git.example/o/r/go", artifact == "lib", nil
|
||||||
return "git.example/o/r/go", artifact == "lib" || artifact == "pkg", nil
|
|
||||||
}
|
}
|
||||||
goPkg := versions.Source{Repository: "o/r", Commit: "c0ffee", GoPackage: true, GoArtifact: "lib"}
|
goPkg := versions.Source{Repository: "o/r", Commit: "c0ffee", Fingerprint: "fpA"}
|
||||||
if _, err := rv.Reserve(ctx, "pkg", "0.1", []string{"pkg:lib"}, goPkg); err != nil {
|
// oldRecord rewrites a reservation as one written before H-A-494, naming the tag its release was to be written as.
|
||||||
t.Fatal(err)
|
oldRecord := func(module, series, tag string) {
|
||||||
}
|
key := versions.ReservedKey(module, series)
|
||||||
if _, err := rv.Reserve(ctx, "prog", "2.0", []string{"prog:bin"}, versions.Source{Repository: "o/p", Commit: "beef"}); err != nil {
|
var v versions.ReservedVersion
|
||||||
t.Fatal(err)
|
if err := json.Unmarshal(store.vals[key], &v); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
v.Tag = tag
|
||||||
|
store.vals[key], _ = json.Marshal(v)
|
||||||
}
|
}
|
||||||
release := func(module, version string) *wakeMsg {
|
release := func(module, version string) *wakeMsg {
|
||||||
m := &wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"v":1,"module":"` + module + `","version":"` + version + `","source":1,"artifacts":[]}`)}
|
m := &wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"v":1,"module":"` + module + `","version":"` + version + `","source":1,"artifacts":[]}`)}
|
||||||
rv.heard(ctx, m)
|
rv.heard(ctx, m)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
if m := release("prog", "2.0.0"); !m.acked || len(tags) != 0 {
|
// The release path: a Go package's version-released releases it, acknowledged, with no tag written.
|
||||||
t.Fatalf("a module with no Go package: acked %v, tags %v; want none written", m.acked, tags)
|
if v, err := rv.Reserve(ctx, "pkg", "0.1", []string{"pkg:lib"}, goPkg); err != nil || v.Tag != "" {
|
||||||
|
t.Fatalf("reserved %+v (%v), want a reservation naming no tag", v, err)
|
||||||
}
|
}
|
||||||
refuse = "forge down"
|
oldRecord("pkg", "0.1", "go/v0.1.0")
|
||||||
if m := release("pkg", "0.1.0"); !m.naked || m.acked {
|
if m := release("pkg", "0.1.0"); !m.acked || m.naked {
|
||||||
t.Fatalf("a tag the forge did not write: naked %v acked %v; want the release heard again", m.naked, m.acked)
|
t.Fatalf("the release: acked %v naked %v; want it acknowledged", m.acked, m.naked)
|
||||||
}
|
}
|
||||||
if all, _ := rv.r.All(ctx); len(all) != 1 {
|
if len(gitCalls) != 0 {
|
||||||
t.Fatalf("the reservation went with an unwritten tag: %v", all)
|
t.Errorf("the release called the seat git: %v; want no tag written", gitCalls)
|
||||||
|
gitCalls = nil
|
||||||
}
|
}
|
||||||
refuse = ""
|
if all, _ := rv.r.All(ctx); len(all) != 0 {
|
||||||
tags = nil
|
t.Fatalf("the released version still stands: %v", all)
|
||||||
if m := release("pkg", "0.1.0"); !m.acked || len(tags) != 1 || tags[0] != (git.TagInput{Repository: "o/r", Commit: "c0ffee", Tag: "go/v0.1.0"}) {
|
|
||||||
t.Fatalf("the release: acked %v, tags %+v; want go/v0.1.0 at c0ffee of o/r", m.acked, tags)
|
|
||||||
}
|
}
|
||||||
tags = nil
|
// The start check (H-A-484 c): a built reservation the catalog holds released is released at the start, no tag written; one
|
||||||
if _, err := rv.Reserve(ctx, "pkg", "0.1", []string{"pkg:lib"}, goPkg); err != nil { // build A: 0.1.0 (the stub catalog holds none released)
|
// not built, or not released, stands.
|
||||||
|
// Design 47 H2 H-A-492: at the start, a standing reservation with no digests recorded whose build key is done has them
|
||||||
|
// recorded (the builder's RecordAgain), and is then held against the released versions as a built one is.
|
||||||
|
if _, err := rv.Reserve(ctx, "rec", "0.1", []string{"rec:bin"}, versions.Source{Repository: "o/q", Commit: "abc", Fingerprint: "fpR"}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if v, err := rv.Reserve(ctx, "pkg", "0.1", []string{"pkg:lib"}, versions.Source{Repository: "o/r", Commit: "b0b", GoPackage: true, GoArtifact: "lib"}); err != nil || v.Version != "0.1.1" { // build B supersedes A
|
var recordedAt []string
|
||||||
t.Fatalf("second build reserved %q (%v)", v.Version, err)
|
rv.recordAgain = func(ctx context.Context, module, fp, when string) (string, error) {
|
||||||
|
recordedAt = append(recordedAt, module+" "+fp+" "+when)
|
||||||
|
_, err := rv.r.Built(ctx, module, "0.1.0", "rec:bin", "sha256:bb", nil) // its done key's digest
|
||||||
|
return "0.1.0", err
|
||||||
}
|
}
|
||||||
release("pkg", "0.1.0") // A's version is never released in fact; were it said, it is no reservation of the key
|
catalog = []meshcatalog.VersionEntry{{Module: "rec", Version: "0.1.0"}}
|
||||||
if len(tags) != 0 {
|
rv.releasedAtStart(ctx)
|
||||||
t.Fatalf("a superseded build's version was tagged: %+v", tags)
|
if _, standing, _ := rv.r.Of(ctx, "rec", "0.1.0"); standing || !slices.Equal(recordedAt, []string{"rec fpR at the builder's start"}) {
|
||||||
|
t.Fatalf("at the start, rec 0.1.0 unrecorded and released: standing %v, recorded %q; want it recorded once at the start and released", standing, recordedAt)
|
||||||
}
|
}
|
||||||
if release("pkg", "0.1.1"); len(tags) != 1 || tags[0].Commit != "b0b" {
|
catalog, rv.recordAgain = nil, nil
|
||||||
t.Fatalf("the newer build's version: tags %+v; want go/v0.1.1 at b0b", tags)
|
var ended []string
|
||||||
|
rv.released = func(_ context.Context, module, version string) { ended = append(ended, module+" "+version) }
|
||||||
|
if _, err := rv.Reserve(ctx, "pkg", "0.1", []string{"pkg:lib"}, versions.Source{Repository: "o/r", Commit: "b0b", Fingerprint: "fpB"}); err != nil {
|
||||||
|
t.Fatal(err) // 0.1.0 again: the stub catalog holds none released
|
||||||
}
|
}
|
||||||
// Design 47 H2 §796: a tag standing at another commit makes the next number and the finding version-tagged-elsewhere, which
|
oldRecord("pkg", "0.1", "go/v0.1.0")
|
||||||
// clears at the module's next version-released.
|
rv.releasedAtStart(ctx) // built nothing yet: nothing taken
|
||||||
standing = []git.Tag{{Tag: "go/v0.2.0", Commit: "elsewhere"}, {Tag: "go/v0.2.1", Commit: "elsewhere"}}
|
if all, _ := rv.r.All(ctx); len(all) != 1 {
|
||||||
if v, err := rv.Reserve(ctx, "pkg", "0.2", []string{"pkg:lib"}, goPkg); err != nil || v.Version != "0.2.2" || v.Tag != "go/v0.2.2" {
|
t.Fatalf("at the start with no build done: reservations %v; want the reservation standing", all)
|
||||||
t.Fatalf("reserved %+v (%v) with 0.2.0 and 0.2.1 tagged elsewhere, want 0.2.2 tagged go/v0.2.2", v, err)
|
}
|
||||||
|
if _, err := rv.r.Built(ctx, "pkg", "0.1.0", "pkg:lib", "sha256:aa", nil); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
rv.releasedAtStart(ctx) // the catalog holds none released: it stands
|
||||||
|
if all, _ := rv.r.All(ctx); len(all) != 1 {
|
||||||
|
t.Fatalf("at the start with nothing released: reservations %v; want the reservation standing", all)
|
||||||
|
}
|
||||||
|
catalog = []meshcatalog.VersionEntry{{Module: "pkg", Version: "0.1.0"}}
|
||||||
|
rv.releasedAtStart(ctx)
|
||||||
|
if all, _ := rv.r.All(ctx); len(all) != 0 || !slices.Equal(ended, []string{"pkg 0.1.0"}) {
|
||||||
|
t.Fatalf("at the start with 0.1.0 released: reservations %v, items ended %v; want it released and its item ended", all, ended)
|
||||||
|
}
|
||||||
|
if len(gitCalls) != 0 {
|
||||||
|
t.Errorf("the start check called the seat git: %v; want no tag written", gitCalls)
|
||||||
|
gitCalls = nil
|
||||||
|
}
|
||||||
|
catalog, rv.released = nil, nil
|
||||||
|
// Numbering reads no tag: the seat git would answer go/v0.2.0 at another commit, and 0.2.0 is reserved all the same.
|
||||||
|
if v, err := rv.Reserve(ctx, "pkg", "0.2", []string{"pkg:lib"}, goPkg); err != nil || v.Version != "0.2.0" || v.Tag != "" || len(gitCalls) != 0 {
|
||||||
|
t.Errorf("reserved %+v (%v), git calls %v; want 0.2.0 naming no tag, no git tag read", v, err, gitCalls)
|
||||||
}
|
}
|
||||||
key := meshconditionsclient.Key(meshconditionsclient.ScopeModule, "pkg", versions.VersionTaggedElsewhere)
|
key := meshconditionsclient.Key(meshconditionsclient.ScopeModule, "pkg", versions.VersionTaggedElsewhere)
|
||||||
if got, err := decodeFinding(fw.vals[key]); err != nil || !strings.Contains(got.Summary, "0.2.0") || !strings.Contains(got.Summary, "0.2.1") {
|
if fw.vals[key] != nil {
|
||||||
t.Fatalf("the finding %s = %+v (%v), want it naming 0.2.0 and 0.2.1", key, got, err)
|
t.Errorf("a reserve raised %s", key)
|
||||||
}
|
}
|
||||||
if release("pkg", "0.2.2"); fw.vals[key] != nil {
|
|
||||||
t.Errorf("version-released of pkg left %s standing", key)
|
|
||||||
}
|
|
||||||
standing = nil
|
|
||||||
// Design 47 H2 §805, H-A-420 (2): a package's number newly reserved is said as version-reserved, its path the package's name
|
// Design 47 H2 §805, H-A-420 (2): a package's number newly reserved is said as version-reserved, its path the package's name
|
||||||
// and its revision the indexer's `<branch>.<n>`; a reservation kept as it stood, an artifact that is no package and a
|
// and its revision the indexer's `<branch>.<n>`; a reservation kept as it stood, an artifact that is no package and a
|
||||||
// reservation naming no catalog revision say none.
|
// reservation naming no catalog revision say none.
|
||||||
@@ -247,7 +275,7 @@ func TestAReleasedVersionIsTaggedAtTheCommitItWasBuiltFrom(t *testing.T) {
|
|||||||
return "git.example/o/r/" + artifact, module == "lib2" && artifact == "pkg", nil
|
return "git.example/o/r/" + artifact, module == "lib2" && artifact == "pkg", nil
|
||||||
}
|
}
|
||||||
rv.sayReserved = func(_ context.Context, ev meshbuilds.VersionReservedEvent) error { said = append(said, ev); return nil }
|
rv.sayReserved = func(_ context.Context, ev meshbuilds.VersionReservedEvent) error { said = append(said, ev); return nil }
|
||||||
at := versions.Source{Repository: "o/r", Commit: "c1", Fingerprint: "src2:l2", GoPackage: true, GoArtifact: "pkg", Branch: "main", CatalogRevision: 158}
|
at := versions.Source{Repository: "o/r", Commit: "c1", Fingerprint: "src2:l2", Branch: "main", CatalogRevision: 158}
|
||||||
for range 2 {
|
for range 2 {
|
||||||
if _, err := rv.Reserve(ctx, "lib2", "0.3", []string{"lib2:pkg", "lib2:bin"}, at); err != nil {
|
if _, err := rv.Reserve(ctx, "lib2", "0.3", []string{"lib2:pkg", "lib2:bin"}, at); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import (
|
|||||||
// `module` alone the module's keys newest first, at most MostBuilds, each with its fingerprint whole, its state, revision and
|
// `module` alone the module's keys newest first, at most MostBuilds, each with its fingerprint whole, its state, revision and
|
||||||
// since when, its step and node, its error whole, event-builds and the open ask (§568), and `newest` naming each watched branch
|
// since when, its step and node, its error whole, event-builds and the open ask (§568), and `newest` naming each watched branch
|
||||||
// whose newest catalog graph entry of the module names that fingerprint, read from the catalog half by the tools bundle.
|
// whose newest catalog graph entry of the module names that fingerprint, read from the catalog half by the tools bundle.
|
||||||
|
// **Each key's time is its entry's own write time** (design 47 H2 H-A-487): the history of a key is read only for the one key a
|
||||||
|
// fingerprint names, when its entry does not say when it was written, and a listing cut at MostBuilds says so in its note.
|
||||||
|
|
||||||
// BuildTool is the builder's read tool of a module's build keys.
|
// BuildTool is the builder's read tool of a module's build keys.
|
||||||
const BuildTool = "builder_build"
|
const BuildTool = "builder_build"
|
||||||
@@ -56,14 +58,16 @@ type BuildAnswer struct {
|
|||||||
Builds []BuildRow `json:"builds"`
|
Builds []BuildRow `json:"builds"`
|
||||||
// Newest is the fingerprint of the module's newest catalog graph entry on each watched branch.
|
// Newest is the fingerprint of the module's newest catalog graph entry on each watched branch.
|
||||||
Newest map[string]string `json:"newest-entries,omitempty"`
|
Newest map[string]string `json:"newest-entries,omitempty"`
|
||||||
// Note says what no key shows: that none of the keys is the newest entry's, naming its fingerprint.
|
// Note says what no key shows: that none of the keys is the newest entry's, naming its fingerprint, and that the listing
|
||||||
|
// was cut at MostBuilds (H-A-487).
|
||||||
Note string `json:"note,omitempty"`
|
Note string `json:"note,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildReader reads what builder_build answers.
|
// BuildReader reads what builder_build answers.
|
||||||
type BuildReader struct {
|
type BuildReader struct {
|
||||||
Builds StateRead
|
Builds StateRead
|
||||||
// Entry is a key's value with its revision and when it was written; nil leaves both out.
|
// Entry is a key's value with its revision and when it was written, the entry's own write time (H-A-487); nil leaves both
|
||||||
|
// out. Builds.Written, the key's history, is read only for the key a fingerprint names when Entry says no time.
|
||||||
Entry func(key string) (json.RawMessage, uint64, time.Time, error)
|
Entry func(key string) (json.RawMessage, uint64, time.Time, error)
|
||||||
// Asked is the builder's state asked, which holds the asks the operator was asked.
|
// Asked is the builder's state asked, which holds the asks the operator was asked.
|
||||||
Asked StateRead
|
Asked StateRead
|
||||||
@@ -96,6 +100,9 @@ func (r *BuildReader) Build(module, fingerprint string) (BuildAnswer, error) {
|
|||||||
if raw == nil {
|
if raw == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if at.IsZero() && fingerprint != "" && r.Builds.Written != nil {
|
||||||
|
at = r.Builds.Written(key) // one key's history, never every key's (H-A-487)
|
||||||
|
}
|
||||||
v, err := builds.DecodeBuilderBuild(raw)
|
v, err := builds.DecodeBuilderBuild(raw)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return out, fmt.Errorf("%s holds what is not a build: %w", key, err)
|
return out, fmt.Errorf("%s holds what is not a build: %w", key, err)
|
||||||
@@ -118,7 +125,9 @@ func (r *BuildReader) Build(module, fingerprint string) (BuildAnswer, error) {
|
|||||||
}
|
}
|
||||||
return rows[i].Key > rows[j].Key
|
return rows[i].Key > rows[j].Key
|
||||||
})
|
})
|
||||||
|
var cut string
|
||||||
if len(rows) > MostBuilds {
|
if len(rows) > MostBuilds {
|
||||||
|
cut = fmt.Sprintf("%d of %s's %d build keys are answered, the newest by write time; name a fingerprint for another", MostBuilds, module, len(rows))
|
||||||
rows = rows[:MostBuilds]
|
rows = rows[:MostBuilds]
|
||||||
}
|
}
|
||||||
asks := r.openAsks()
|
asks := r.openAsks()
|
||||||
@@ -149,6 +158,9 @@ func (r *BuildReader) Build(module, fingerprint string) (BuildAnswer, error) {
|
|||||||
out.Note = "no build key of " + module + " is the newest entry's: " + strings.Join(says, "; ")
|
out.Note = "no build key of " + module + " is the newest entry's: " + strings.Join(says, "; ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if cut != "" {
|
||||||
|
out.Note = strings.TrimPrefix(out.Note+"; "+cut, "; ")
|
||||||
|
}
|
||||||
out.Builds = append(out.Builds, rows...)
|
out.Builds = append(out.Builds, rows...)
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package build
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -66,6 +67,31 @@ func TestBuilderBuildAnswersAModulesKeysWhole(t *testing.T) {
|
|||||||
if n, err := r.Build("m", ""); err != nil || !strings.Contains(n.Note, "no build key of m is the newest entry's") || !strings.Contains(n.Note, "main names src2:"+strings.Repeat("c", 64)) {
|
if n, err := r.Build("m", ""); err != nil || !strings.Contains(n.Note, "no build key of m is the newest entry's") || !strings.Contains(n.Note, "main names src2:"+strings.Repeat("c", 64)) {
|
||||||
t.Errorf("a module none of whose keys the newest entry names: %+v, %v", n, err)
|
t.Errorf("a module none of whose keys the newest entry names: %+v, %v", n, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// H-A-487: a module of 100 keys is read by each entry's own write time, no key's history read, and the listing is cut at the
|
||||||
|
// 20 newest, saying so; a fingerprint's key with no time in its entry has its one history read.
|
||||||
|
many, at := map[string][]byte{}, map[string]time.Time{}
|
||||||
|
base := time.Date(2026, 11, 22, 20, 0, 0, 0, time.UTC)
|
||||||
|
for i := range 100 {
|
||||||
|
k, _ := builds.BuilderBuildKey("big", fmt.Sprintf("src2:%064x", i))
|
||||||
|
many[k], at[k] = done, base.Add(time.Duration(i)*time.Minute)
|
||||||
|
}
|
||||||
|
histories := 0
|
||||||
|
st := stateOf(many)
|
||||||
|
st.Written = func(string) time.Time { histories++; return base }
|
||||||
|
big := &BuildReader{Builds: st, Entry: func(k string) (json.RawMessage, uint64, time.Time, error) { return many[k], 1, at[k], nil }}
|
||||||
|
a, err = big.Build("big", "")
|
||||||
|
if err != nil || len(a.Builds) != MostBuilds || !a.Builds[0].Since.Equal(base.Add(99*time.Minute)) || histories != 0 ||
|
||||||
|
!strings.Contains(a.Note, "20 of big's 100 build keys are answered") {
|
||||||
|
t.Fatalf("100 keys: %d rows, newest %v, %d histories read, note %q; want the 20 newest, no history, the cut said", len(a.Builds), a.Builds[0].Since, histories, a.Note)
|
||||||
|
}
|
||||||
|
big.Entry = func(k string) (json.RawMessage, uint64, time.Time, error) { return many[k], 1, time.Time{}, nil }
|
||||||
|
if a, err := big.Build("big", ""); err != nil || len(a.Builds) != MostBuilds || histories != 0 {
|
||||||
|
t.Fatalf("100 keys with no time in their entries: %d rows (%v), %d histories read; want no history read for a listing", len(a.Builds), err, histories)
|
||||||
|
}
|
||||||
|
if one, err := big.Build("big", fmt.Sprintf("src2:%064x", 7)); err != nil || len(one.Builds) != 1 || !one.Builds[0].Since.Equal(base) || histories != 1 {
|
||||||
|
t.Errorf("one fingerprint with no time in its entry: %+v (%v), %d histories; want its one history read", one, err, histories)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Design 47 G §589: builder_stuck answers each key's fingerprint whole, as the build-input fingerprint the catalog graph entry carries it.
|
// Design 47 G §589: builder_stuck answers each key's fingerprint whole, as the build-input fingerprint the catalog graph entry carries it.
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ func Unreferenced(b builds.BuilderBuild) bool {
|
|||||||
// clause 2, ADR 0498 clauses 4 and 5) or for digests that differ (buildrun.DigestsDifferPrefix, clause 4),
|
// clause 2, ADR 0498 clauses 4 and 5) or for digests that differ (buildrun.DigestsDifferPrefix, clause 4),
|
||||||
// which wait for another fingerprint, and one failed for want of an image builder (NoImageBuilderPrefix), which waits for
|
// which wait for another fingerprint, and one failed for want of an image builder (NoImageBuilderPrefix), which waits for
|
||||||
// another fingerprint or a node that runs the image build module (ClaimOptions.ImageBuilder);
|
// another fingerprint or a node that runs the image build module (ClaimOptions.ImageBuilder);
|
||||||
|
// - a failed key withdrawn (withdrawnPrefix) is final for its fingerprint, taken again only by a person's build again (H-A-489);
|
||||||
// - a key queued waiting for a package version (Waits) is claimed building as a new revision once that version is
|
// - a key queued waiting for a package version (Waits) is claimed building as a new revision once that version is
|
||||||
// published (ClaimOptions.Published, ADR 0500 clause 6), and not before;
|
// published (ClaimOptions.Published, ADR 0500 clause 6), and not before;
|
||||||
// - a key left queued or building by this builder is taken as it stands (ADR 0478 clause 5: a stopped builder takes its
|
// - a key left queued or building by this builder is taken as it stands (ADR 0478 clause 5: a stopped builder takes its
|
||||||
@@ -229,6 +230,8 @@ func (c Claimer) Claim(ctx context.Context, module, fingerprint, manifest string
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
case cur.State == builds.BuildFailed && (builds.FailedUntilChanged(cur.Error) || strings.HasPrefix(cur.Error, buildrun.DigestsDifferPrefix)):
|
case cur.State == builds.BuildFailed && (builds.FailedUntilChanged(cur.Error) || strings.HasPrefix(cur.Error, buildrun.DigestsDifferPrefix)):
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
case cur.State == builds.BuildFailed && strings.HasPrefix(cur.Error, withdrawnPrefix) && !opt.ByHand:
|
||||||
|
return nil, nil // withdrawn is final for its fingerprint: no look builds it again (H-A-489)
|
||||||
case cur.State == builds.BuildFailed && builds.FailedOnTransportFault(cur.Error) && !opt.ByHand && !opt.TakeOver && !opt.ByEvent:
|
case cur.State == builds.BuildFailed && builds.FailedOnTransportFault(cur.Error) && !opt.ByHand && !opt.TakeOver && !opt.ByEvent:
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case cur.State == builds.BuildFailed && strings.HasPrefix(cur.Error, NoImageBuilderPrefix) && (opt.ImageBuilder == nil || !opt.ImageBuilder()):
|
case cur.State == builds.BuildFailed && strings.HasPrefix(cur.Error, NoImageBuilderPrefix) && (opt.ImageBuilder == nil || !opt.ImageBuilder()):
|
||||||
|
|||||||
@@ -106,11 +106,19 @@ func (b *Builder) doneDigests(ctx context.Context, module, fp string) map[string
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
raw, _, found, err := b.Claimer.Store.Get(ctx, key)
|
raw, _, found, err := b.Claimer.Store.Get(ctx, key)
|
||||||
if err != nil || !found {
|
if err != nil {
|
||||||
|
b.logf("%s: the build key cannot be read, so it is taken as not done: %v", key, err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
cur, err := builds.DecodeBuilderBuild(raw)
|
cur, err := builds.DecodeBuilderBuild(raw)
|
||||||
if err != nil || cur.State != builds.BuildDone {
|
if err != nil {
|
||||||
|
b.logf("%s: the build key holds what is no build, so it is taken as not done: %v", key, err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if cur.State != builds.BuildDone {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
out := map[string]string{}
|
out := map[string]string{}
|
||||||
@@ -122,6 +130,57 @@ func (b *Builder) doneDigests(ctx context.Context, module, fp string) map[string
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultRecordBound is the bound of the record of a reservation's digests, its setting record-bound-seconds' default (design 47
|
||||||
|
// H2 H-A-492).
|
||||||
|
const DefaultRecordBound = time.Minute
|
||||||
|
|
||||||
|
// recordContext is the context a reservation's digests are recorded under: ctx's values with no cancel of its own, bounded by
|
||||||
|
// RecordBound (design 47 H2 H-A-492), so a takeover or an end cancelling the build cannot cancel the record.
|
||||||
|
func (b *Builder) recordContext(ctx context.Context) (context.Context, context.CancelFunc) {
|
||||||
|
bound := b.RecordBound
|
||||||
|
if bound <= 0 {
|
||||||
|
bound = DefaultRecordBound
|
||||||
|
}
|
||||||
|
return context.WithTimeout(context.WithoutCancel(ctx), bound)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RecordAgain records the digests of fp's done build under its standing reservation when its end did not record them (design 47
|
||||||
|
// H2 H-A-492): at the builder's look of the key and at its start (when says which), said each time. It answers the version
|
||||||
|
// recorded, "" when nothing was to be recorded: the key is not done, no reservation stands for fp, or it is recorded already.
|
||||||
|
func (b *Builder) RecordAgain(ctx context.Context, module, fp, when string) (string, error) {
|
||||||
|
b.init()
|
||||||
|
if b.Reserved == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
digests := b.doneDigests(ctx, module, fp)
|
||||||
|
if digests == nil {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
res, ok, err := b.Reserved.ReservedFor(ctx, module, fp)
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("%s at %s: whether its done build's digests are recorded cannot be read %s: %w", module, fp, when, err)
|
||||||
|
}
|
||||||
|
if !ok || !res.BuiltAt.IsZero() || len(res.Artifacts) == 0 || versions.NotStanding(res, true) != "" {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
refs := map[string]string{}
|
||||||
|
for ref := range res.Artifacts {
|
||||||
|
_, artifact, _ := strings.Cut(ref, ":")
|
||||||
|
d, have := digests[artifact]
|
||||||
|
if !have {
|
||||||
|
return "", fmt.Errorf("%s at %s: the digests of %s are not recorded, and the done key holds no digest of %s to record %s", module, fp, res.Version, ref, when)
|
||||||
|
}
|
||||||
|
refs[ref] = d
|
||||||
|
}
|
||||||
|
rec, stop := b.recordContext(ctx)
|
||||||
|
defer stop()
|
||||||
|
if err := b.Reserved.Built(rec, module, res.Version, refs, nil); err != nil {
|
||||||
|
return "", fmt.Errorf("%s at %s: the digests of %s are not recorded %s either: %w", module, fp, res.Version, when, err)
|
||||||
|
}
|
||||||
|
b.logf("%s at %s: the digests of %s were not recorded at its build's end: recorded %s from the done key", module, fp, res.Version, when)
|
||||||
|
return res.Version, nil
|
||||||
|
}
|
||||||
|
|
||||||
// PackageNamed looks at a module again when the indexer's packages state names a name for one of its packages
|
// PackageNamed looks at a module again when the indexer's packages state names a name for one of its packages
|
||||||
// (versions.NamedModule): a done trunk build that left the package unnumbered, its name not known at its claim, is
|
// (versions.NamedModule): a done trunk build that left the package unnumbered, its name not known at its claim, is
|
||||||
// numbered then with the done build's digests, and version.numbered says them for its build module's late publish.
|
// numbered then with the done build's digests, and version.numbered says them for its build module's late publish.
|
||||||
@@ -199,8 +258,8 @@ func (b *Builder) reserve(ctx context.Context, module string, m meshcatalog.Modu
|
|||||||
}
|
}
|
||||||
src := versions.Source{Repository: m.Repository, Commit: m.Commit, Fingerprint: m.Fp2, Branch: o.Branch, Revision: o.Source, CatalogRevision: o.Revision, Rebuild: rebuild}
|
src := versions.Source{Repository: m.Repository, Commit: m.Commit, Fingerprint: m.Fp2, Branch: o.Branch, Revision: o.Source, CatalogRevision: o.Revision, Rebuild: rebuild}
|
||||||
for _, t := range plan.Tasks {
|
for _, t := range plan.Tasks {
|
||||||
if t.Kind == catalogue.ArtifactPackage && t.Language == "go" && !src.GoPackage {
|
if t.Kind == catalogue.ArtifactUpstream {
|
||||||
src.GoPackage, src.GoArtifact = true, t.Artifact // its module path names its tag's directory (design 47 H2 §796)
|
src.Upstream = append(src.Upstream, module+":"+t.Artifact) // copied by its pin, never awaited (H-A-486)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res, err := b.Reserved.Reserve(ctx, module, plan.Series, refs, src)
|
res, err := b.Reserved.Reserve(ctx, module, plan.Series, refs, src)
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ type fakeReservations struct {
|
|||||||
next string // the version Reserve answers when set, else the series' .5
|
next string // the version Reserve answers when set, else the series' .5
|
||||||
fail error // the reservation cannot be made (the catalog's versions cannot be read)
|
fail error // the reservation cannot be made (the catalog's versions cannot be read)
|
||||||
tookBy map[string]versions.ReservedVersion // by fingerprint, the reservation that took its series over (H-A-244)
|
tookBy map[string]versions.ReservedVersion // by fingerprint, the reservation that took its series over (H-A-244)
|
||||||
|
held map[string]versions.ReservedVersion // by fingerprint, the reservation ReservedFor answers as it stands (H-A-492)
|
||||||
|
lost error // the record of the digests fails, as a store refusing it would
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeReservations) TakenOver(_ context.Context, _, fp string) (versions.ReservedVersion, bool, error) {
|
func (f *fakeReservations) TakenOver(_ context.Context, _, fp string) (versions.ReservedVersion, bool, error) {
|
||||||
@@ -46,6 +48,9 @@ func (f *fakeReservations) ReleasedFor(_ context.Context, _, fp string) (bool, e
|
|||||||
func (f *fakeReservations) Filled() bool { return f.filled }
|
func (f *fakeReservations) Filled() bool { return f.filled }
|
||||||
|
|
||||||
func (f *fakeReservations) ReservedFor(_ context.Context, _, fp string) (versions.ReservedVersion, bool, error) {
|
func (f *fakeReservations) ReservedFor(_ context.Context, _, fp string) (versions.ReservedVersion, bool, error) {
|
||||||
|
if v, ok := f.held[fp]; ok {
|
||||||
|
return v, true, nil
|
||||||
|
}
|
||||||
for _, s := range f.sources {
|
for _, s := range f.sources {
|
||||||
if s.Fingerprint == fp {
|
if s.Fingerprint == fp {
|
||||||
return versions.ReservedVersion{Version: "held"}, true, nil
|
return versions.ReservedVersion{Version: "held"}, true, nil
|
||||||
@@ -65,7 +70,13 @@ func (f *fakeReservations) Reserve(_ context.Context, module, series string, art
|
|||||||
return versions.ReservedVersion{Module: module, Series: series, Version: series + ".5"}, nil
|
return versions.ReservedVersion{Module: module, Series: series, Version: series + ".5"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeReservations) Built(_ context.Context, _, version string, digests map[string]string, deps map[string][]meshbuilds.Dependency) error {
|
func (f *fakeReservations) Built(ctx context.Context, _, version string, digests map[string]string, deps map[string][]meshbuilds.Dependency) error {
|
||||||
|
if err := ctx.Err(); err != nil {
|
||||||
|
return err // the state's write runs under ctx: a cancelled one records nothing
|
||||||
|
}
|
||||||
|
if f.lost != nil {
|
||||||
|
return f.lost
|
||||||
|
}
|
||||||
f.deps = deps
|
f.deps = deps
|
||||||
f.built = map[string]string{version: ""}
|
f.built = map[string]string{version: ""}
|
||||||
for ref, d := range digests {
|
for ref, d := range digests {
|
||||||
@@ -118,6 +129,13 @@ func TestABuildReservesItsVersionAtItsStartOnceTheCatalogFilled(t *testing.T) {
|
|||||||
if res.built["m:tool"] != digest || len(res.built) != 2 {
|
if res.built["m:tool"] != digest || len(res.built) != 2 {
|
||||||
t.Errorf("recorded %v, want the digest of m:tool under the reserved version", res.built)
|
t.Errorf("recorded %v, want the digest of m:tool under the reserved version", res.built)
|
||||||
}
|
}
|
||||||
|
// H-A-486: an upstream artifact is reserved for the record and named as upstream, so its publish is never awaited.
|
||||||
|
up := &fakeReservations{filled: true}
|
||||||
|
plan := Plan{Series: "0.1", Tasks: []Task{{Artifact: "server", Kind: catalogue.ArtifactUpstream}, {Artifact: "tools", Kind: catalogue.ArtifactBundle}}}
|
||||||
|
if _, ok := (&Builder{Reserved: up}).reserve(context.Background(), "nats", meshcatalog.ModulesByModuleValue{Fp2: "f"}, plan, Origin{}, false); !ok ||
|
||||||
|
!slices.Equal(up.reserved[0], []string{"nats:server", "nats:tools"}) || !slices.Equal(up.sources[0].Upstream, []string{"nats:server"}) {
|
||||||
|
t.Errorf("an upstream artifact reserved %v from %+v, want both refs reserved and nats:server named upstream", up.reserved, up.sources)
|
||||||
|
}
|
||||||
r.consider(t, "modules/m")
|
r.consider(t, "modules/m")
|
||||||
if len(res.reserved) != 1 {
|
if len(res.reserved) != 1 {
|
||||||
t.Errorf("a done key reserved again: %v", res.reserved)
|
t.Errorf("a done key reserved again: %v", res.reserved)
|
||||||
@@ -146,6 +164,97 @@ func TestABuildReservesItsVersionAtItsStartOnceTheCatalogFilled(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestAVersionsDigestsAreRecordedUnderTheBuildersOwnBound: design 47 H2 H-A-492 — the record of a reservation's digests after a
|
||||||
|
// build ends runs under the builder's own bound, so a build context cancelled at its end still records; a done build whose
|
||||||
|
// digests are not recorded is recorded at the builder's next look, said.
|
||||||
|
func TestAVersionsDigestsAreRecordedUnderTheBuildersOwnBound(t *testing.T) {
|
||||||
|
manifest := catalogue.Manifest{Module: "m", Version: "0.1", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{goBundle}}}
|
||||||
|
t.Run("a build's context cancelled at its end still records", func(t *testing.T) {
|
||||||
|
r := newRig(t, goBundle)
|
||||||
|
r.mf.byDigest[mdigest('a')] = manifest
|
||||||
|
res := &fakeReservations{filled: true}
|
||||||
|
r.b.Reserved = res
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
r.b.Ended = func(context.Context, string) { cancel() } // a takeover or the builder's end, once the key is written
|
||||||
|
r.b.Module(ctx, "m", moduleValue(t, "modules/m"))
|
||||||
|
r.b.Wait()
|
||||||
|
if v := valueOf(t, r.st, r.key); v.State != builds.BuildDone {
|
||||||
|
t.Fatalf("build = %+v, want done", v)
|
||||||
|
}
|
||||||
|
if res.built["m:tool"] != digest {
|
||||||
|
t.Errorf("recorded %v, want the digest of m:tool under 0.1.5 though the build's context ended", res.built)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("the record's bound is the setting record-bound-seconds, never the build's", func(t *testing.T) {
|
||||||
|
build, cancel := context.WithCancel(context.Background())
|
||||||
|
cancel()
|
||||||
|
for _, c := range []struct {
|
||||||
|
bound, want time.Duration
|
||||||
|
}{{0, DefaultRecordBound}, {5 * time.Second, 5 * time.Second}} {
|
||||||
|
rec, stop := (&Builder{RecordBound: c.bound}).recordContext(build)
|
||||||
|
deadline, has := rec.Deadline()
|
||||||
|
stop()
|
||||||
|
if left := time.Until(deadline); !has || left > c.want || left < c.want-time.Second {
|
||||||
|
t.Errorf("RecordBound %v: the record's context has deadline %v (%v left, %v), want %v left of its own", c.bound, deadline, left, has, c.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rec, stop := (&Builder{}).recordContext(build)
|
||||||
|
defer stop()
|
||||||
|
if rec.Err() != nil {
|
||||||
|
t.Errorf("the record's context ended with the build's: %v", rec.Err())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("a build key that cannot be read is said, not taken silently", func(t *testing.T) {
|
||||||
|
var journal []string
|
||||||
|
b := &Builder{Claimer: Claimer{Store: unreadable{newMem()}}, Logf: func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) }}
|
||||||
|
if d := b.doneDigests(context.Background(), "m", fp1); d != nil {
|
||||||
|
t.Errorf("an unreadable key answered digests %v", d)
|
||||||
|
}
|
||||||
|
if !slices.ContainsFunc(journal, func(l string) bool {
|
||||||
|
return strings.Contains(l, "cannot be read") && strings.Contains(l, "bus timeout")
|
||||||
|
}) {
|
||||||
|
t.Errorf("journal %q, want a line saying the build key cannot be read, with why", journal)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
t.Run("a done key whose digests are not recorded is recorded at the next look", func(t *testing.T) {
|
||||||
|
r := newRig(t, goBundle)
|
||||||
|
r.mf.byDigest[mdigest('a')] = manifest
|
||||||
|
res := &fakeReservations{filled: true, lost: errors.New("context canceled")}
|
||||||
|
r.b.Reserved = res
|
||||||
|
var journal []string
|
||||||
|
r.b.Logf = func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) }
|
||||||
|
if v := r.consider(t, "modules/m"); v.State != builds.BuildDone || res.built != nil {
|
||||||
|
t.Fatalf("build %s recorded %v, want done and nothing recorded", v.State, res.built)
|
||||||
|
}
|
||||||
|
res.lost = nil
|
||||||
|
res.held = map[string]versions.ReservedVersion{fp1: {Module: "m", Series: "0.1", Version: "0.1.5", Fingerprint: fp1, Artifacts: map[string]string{"m:tool": ""}}}
|
||||||
|
r.consider(t, "modules/m")
|
||||||
|
if res.built["m:tool"] != digest || len(res.built) != 2 {
|
||||||
|
t.Errorf("recorded %v at the next look, want the done key's digest of m:tool under 0.1.5", res.built)
|
||||||
|
}
|
||||||
|
if !slices.ContainsFunc(journal, func(l string) bool {
|
||||||
|
return strings.Contains(l, "0.1.5 were not recorded") && strings.Contains(l, "recorded at a look")
|
||||||
|
}) {
|
||||||
|
t.Errorf("journal %q, want a line saying 0.1.5's digests were recorded at a look", journal)
|
||||||
|
}
|
||||||
|
// Recorded once: a reservation whose build ended recorded is left.
|
||||||
|
res.built = nil
|
||||||
|
res.held[fp1] = versions.ReservedVersion{Module: "m", Series: "0.1", Version: "0.1.5", Fingerprint: fp1, Artifacts: map[string]string{"m:tool": digest}, BuiltAt: time.Unix(1, 0)}
|
||||||
|
r.consider(t, "modules/m")
|
||||||
|
if res.built != nil {
|
||||||
|
t.Errorf("a recorded reservation was recorded again: %v", res.built)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// unreadable is a builds bucket whose reads fail, as one on a bus that does not answer.
|
||||||
|
type unreadable struct{ *memStore }
|
||||||
|
|
||||||
|
func (unreadable) Get(context.Context, string) ([]byte, uint64, bool, error) {
|
||||||
|
return nil, 0, false, errors.New("bus timeout")
|
||||||
|
}
|
||||||
|
|
||||||
// TestADropOfAReservationIsAReasksValueOfItsOwnKey: design 47 G §369 — builder_reserved_drop asks the builder through
|
// TestADropOfAReservationIsAReasksValueOfItsOwnKey: design 47 G §369 — builder_reserved_drop asks the builder through
|
||||||
// reasks, under a key of the reservation (never a build key), refusing a module with no MAJOR.MINOR or no why.
|
// reasks, under a key of the reservation (never a build key), refusing a module with no MAJOR.MINOR or no why.
|
||||||
func TestADropOfAReservationIsAReasksValueOfItsOwnKey(t *testing.T) {
|
func TestADropOfAReservationIsAReasksValueOfItsOwnKey(t *testing.T) {
|
||||||
@@ -236,7 +345,7 @@ func TestAReservedBuildKeepsWhatItsStepResolvedAndWasBuiltWith(t *testing.T) {
|
|||||||
|
|
||||||
// TestAModuleWhoseOnlyArtifactIsAGoPackageIsBuiltUnderItsReservedVersion: design 47 G §370 — a module whose one artifact is
|
// TestAModuleWhoseOnlyArtifactIsAGoPackageIsBuiltUnderItsReservedVersion: design 47 G §370 — a module whose one artifact is
|
||||||
// a Go package (mesh-wireguard's go-overlay) is planned on the Go build seat, its ask carries the reserved version and names
|
// a Go package (mesh-wireguard's go-overlay) is planned on the Go build seat, its ask carries the reserved version and names
|
||||||
// the seat go-package-registry the package is published and tagged through, and the build is done; a build reserving none
|
// the seat go-package-registry the package is published through, and the build is done; a build reserving none
|
||||||
// names no seat.
|
// names no seat.
|
||||||
func TestAModuleWhoseOnlyArtifactIsAGoPackageIsBuiltUnderItsReservedVersion(t *testing.T) {
|
func TestAModuleWhoseOnlyArtifactIsAGoPackageIsBuiltUnderItsReservedVersion(t *testing.T) {
|
||||||
goPackage := catalogue.Artifact{Name: "go-overlay", Kind: catalogue.ArtifactPackage, Language: "go", Paths: []string{"go"}}
|
goPackage := catalogue.Artifact{Name: "go-overlay", Kind: catalogue.ArtifactPackage, Language: "go", Paths: []string{"go"}}
|
||||||
@@ -265,10 +374,6 @@ func TestAModuleWhoseOnlyArtifactIsAGoPackageIsBuiltUnderItsReservedVersion(t *t
|
|||||||
len(asked[0].Build.Artifacts) != 1 || asked[0].Build.Artifacts[0] != (buildstep.AskArtifact{Artifact: "go-overlay", Seat: c.seat}) {
|
len(asked[0].Build.Artifacts) != 1 || asked[0].Build.Artifacts[0] != (buildstep.AskArtifact{Artifact: "go-overlay", Seat: c.seat}) {
|
||||||
t.Fatalf("asks %+v, want one Go ask with version %q naming go-overlay on seat %q", asked, c.version, c.seat)
|
t.Fatalf("asks %+v, want one Go ask with version %q naming go-overlay on seat %q", asked, c.version, c.seat)
|
||||||
}
|
}
|
||||||
// Design 47 H2 §796: the reservation names the Go package's artifact, whose module path names its tag's directory.
|
|
||||||
if c.version != "" && (len(res.sources) != 1 || !res.sources[0].GoPackage || res.sources[0].GoArtifact != "go-overlay") {
|
|
||||||
t.Errorf("reserved from %+v, want one source naming the Go package go-overlay", res.sources)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ func (b *Builder) holdsRevision(branch string, source int64, entries []meshbuild
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keptRevisionHolds answers no outcome when the catalog keeps the ask's revision (its catalog revision by number) and that
|
// keptRevisionHolds answers no outcome when the catalog keeps the ask's revision (its catalog revision by number) and that
|
||||||
// revision names every entry of the ask (H-A-205, H-A-222); else failed or could not run, with its words.
|
// revision names every entry of the ask (H-A-205, H-A-222); superseded when it names a newer fingerprint of an entry (H-A-508
|
||||||
|
// second addendum); else failed or could not run, with its words.
|
||||||
func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun, held int64) (outcome, said string) {
|
func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun, held int64) (outcome, said string) {
|
||||||
below := fmt.Sprintf("revision %d of %s is not named by the builder's picture, which holds source revision %d", run.Source, run.Branch, held)
|
below := fmt.Sprintf("revision %d of %s is not named by the builder's picture, which holds source revision %d", run.Source, run.Branch, held)
|
||||||
if run.Source < held {
|
if run.Source < held {
|
||||||
@@ -100,14 +101,30 @@ func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun,
|
|||||||
b.logf("%s: %s, and the catalog's revision %d is of source revision %d, the ask names %d: the step fails, nothing is built", run.Pipeline, below, run.Revision, source, run.Source)
|
b.logf("%s: %s, and the catalog's revision %d is of source revision %d, the ask names %d: the step fails, nothing is built", run.Pipeline, below, run.Revision, source, run.Source)
|
||||||
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d is of source revision %d, the ask names %d", below, run.Revision, source, run.Source)
|
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d is of source revision %d, the ask names %d", below, run.Revision, source, run.Source)
|
||||||
}
|
}
|
||||||
|
// A step whose fingerprint the catalog's revision no longer names but names a newer one of its module, found below the
|
||||||
|
// picture or by the revision's number, ends superseded with the superseding fingerprint in its why, never failed (design
|
||||||
|
// 47 H2 H-A-508 second addendum: one outcome for one fact, found by either check). Failed stays for any other mismatch.
|
||||||
|
var superseded []string
|
||||||
for _, e := range run.Entries {
|
for _, e := range run.Entries {
|
||||||
if fps[e.Module] != e.Fingerprint {
|
if fps[e.Module] == e.Fingerprint {
|
||||||
b.logf("%s: %s, and the catalog's revision %d names %s at %q, not %s: the step fails, nothing is built", run.Pipeline, below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
|
continue
|
||||||
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d names %s at %q, not %s", below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
|
|
||||||
}
|
}
|
||||||
|
if fps[e.Module] != "" {
|
||||||
|
superseded = append(superseded, stepSuperseded(e.Module, e.Fingerprint, fps[e.Module]))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
b.logf("%s: %s, and the catalog's revision %d names %s at %q, not %s: the step fails, nothing is built", run.Pipeline, below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
|
||||||
|
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d names %s at %q, not %s", below, run.Revision, e.Module, fps[e.Module], e.Fingerprint)
|
||||||
|
}
|
||||||
|
if len(superseded) > 0 {
|
||||||
|
said := strings.Join(superseded, "; ")
|
||||||
|
b.logf("%s: %s, and the catalog's revision %d names newer fingerprints: %s; nothing is built", run.Pipeline, below, run.Revision, said)
|
||||||
|
return meshbuilds.StepEndedOutcomeSuperseded, said
|
||||||
}
|
}
|
||||||
// Each asked fingerprint is recorded as the branch's, so its build reserves its version (H-A-155) as one the picture
|
// Each asked fingerprint is recorded as the branch's, so its build reserves its version (H-A-155) as one the picture
|
||||||
// took in does; what the picture heard stays as it is, so the newer fingerprint's build is not superseded.
|
// took in does; what the picture heard stays as it is, so the newer fingerprint's build is not superseded. Once the picture
|
||||||
|
// heard a newer entry of the module on the first branch, H-A-489 overrides H-A-205: the older fingerprint is refused
|
||||||
|
// superseded (buildEntry), never built or reserved.
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
for _, e := range run.Entries {
|
for _, e := range run.Entries {
|
||||||
key, err := builds.BuilderBuildKey(e.Module, e.Fingerprint)
|
key, err := builds.BuilderBuildKey(e.Module, e.Fingerprint)
|
||||||
@@ -134,9 +151,10 @@ func (b *Builder) awaitRevision(ctx context.Context, run meshbuilds.StepRun) (ou
|
|||||||
if (run.Revision > 0 && b.KeptRevision != nil) || below {
|
if (run.Revision > 0 && b.KeptRevision != nil) || below {
|
||||||
// By its number (H-A-222), whatever the source the picture holds; for an ask naming none, only below the
|
// By its number (H-A-222), whatever the source the picture holds; for an ask naming none, only below the
|
||||||
// picture (H-A-205). A kept revision of another source or naming other fingerprints is a mismatch the wait
|
// picture (H-A-205). A kept revision of another source or naming other fingerprints is a mismatch the wait
|
||||||
// cannot mend: it fails at once; only a revision the catalog does not answer is waited for.
|
// cannot mend: it fails at once, or ends superseded at once when it names a newer fingerprint of the module (H-A-508
|
||||||
|
// second addendum); only a revision the catalog does not answer is waited for.
|
||||||
outcome, said := b.keptRevisionHolds(ctx, run, held)
|
outcome, said := b.keptRevisionHolds(ctx, run, held)
|
||||||
if outcome == "" || below || outcome == meshbuilds.StepEndedOutcomeFailed {
|
if outcome == "" || below || outcome == meshbuilds.StepEndedOutcomeFailed || outcome == meshbuilds.StepEndedOutcomeSuperseded {
|
||||||
return outcome, said
|
return outcome, said
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,9 @@ type Builder struct {
|
|||||||
// package-wait-minutes (H-A-165); DefaultPackageWait when 0. Only a registry seat's published heard (PackagePublished)
|
// package-wait-minutes (H-A-165); DefaultPackageWait when 0. Only a registry seat's published heard (PackagePublished)
|
||||||
// gives a pin (H-A-192).
|
// gives a pin (H-A-192).
|
||||||
PackageWait time.Duration
|
PackageWait time.Duration
|
||||||
|
// RecordBound bounds the record of a reservation's digests after a build ends, its setting record-bound-seconds (design 47
|
||||||
|
// H2 H-A-492): the builder's own bound, never the build's context; DefaultRecordBound when 0.
|
||||||
|
RecordBound time.Duration
|
||||||
// PublishedVersions asks the Go package registry seat's verb versions for one package path, its versions newest first
|
// PublishedVersions asks the Go package registry seat's verb versions for one package path, its versions newest first
|
||||||
// (H-A-194): read once before a build waits for that package. Nil reads none.
|
// (H-A-194): read once before a build waits for that package. Nil reads none.
|
||||||
PublishedVersions func(ctx context.Context, path string) ([]string, error)
|
PublishedVersions func(ctx context.Context, path string) ([]string, error)
|
||||||
@@ -177,6 +180,8 @@ type Builder struct {
|
|||||||
// publishedPins are the newest version a registry seat said published, by package path and series (PackagePublished):
|
// publishedPins are the newest version a registry seat said published, by package path and series (PackagePublished):
|
||||||
// a package with no pin waits for one (H-A-192).
|
// a package with no pin waits for one (H-A-192).
|
||||||
publishedPins map[string]map[string]string
|
publishedPins map[string]map[string]string
|
||||||
|
// supersededSaid are the build keys refused as superseded (H-A-489), so each is said once.
|
||||||
|
supersededSaid sync.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
type planned struct {
|
type planned struct {
|
||||||
@@ -310,11 +315,49 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog.
|
|||||||
if superseded != nil {
|
if superseded != nil {
|
||||||
// A newer fingerprint of the module: the build of the older one in flight is taken out, and its asks are withdrawn
|
// A newer fingerprint of the module: the build of the older one in flight is taken out, and its asks are withdrawn
|
||||||
// from the build seats (ADR 0664 §4).
|
// from the build seats (ADR 0664 §4).
|
||||||
superseded(buildrun.Withdrawn{Why: "the build of " + key + " at " + old.Fp2 + " was superseded by the fingerprint " + m.Fp2})
|
superseded(buildrun.Withdrawn{Why: supersededWhy(key, old.Fp2, m.Fp2)})
|
||||||
}
|
}
|
||||||
b.consider(ctx, key, m)
|
b.consider(ctx, key, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// supersededWhy is the words of a build withdrawn because a newer fingerprint of its module superseded it.
|
||||||
|
func supersededWhy(module, fp, newer string) string {
|
||||||
|
return "the build of " + module + " at " + fp + " was superseded by the fingerprint " + newer
|
||||||
|
}
|
||||||
|
|
||||||
|
// withdrawnPrefix opens the error of a key whose build was withdrawn (H-A-225, ADR 0664 §4). It is final for its fingerprint
|
||||||
|
// (H-A-489): no look builds it again; a person's build again does.
|
||||||
|
const withdrawnPrefix = "withdrawn: "
|
||||||
|
|
||||||
|
// supersededBy is the fingerprint that supersedes fp, a fingerprint of module whose build key is key, when fp is of its
|
||||||
|
// registration's first watched branch and is no longer the newest entry heard on that branch (H-A-489); "" otherwise. A key no
|
||||||
|
// entry named is of the first branch, as originOf has it.
|
||||||
|
func (b *Builder) supersededBy(module, key, fp string) string {
|
||||||
|
b.mu.Lock()
|
||||||
|
defer b.mu.Unlock()
|
||||||
|
o, ok := b.origin[key]
|
||||||
|
if !ok {
|
||||||
|
o = Origin{First: true}
|
||||||
|
}
|
||||||
|
if !o.First {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
newest, heard := b.heard[o.Branch+"\x00"+module]
|
||||||
|
if !heard || newest.Fp2 == "" || newest.Fp2 == fp {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return newest.Fp2
|
||||||
|
}
|
||||||
|
|
||||||
|
// saySuperseded says, once per key, that the build of fp is refused as superseded by newer (H-A-489), and gives the words.
|
||||||
|
func (b *Builder) saySuperseded(module, key, fp, newer string) string {
|
||||||
|
why := "is not built: superseded by " + newer + ", the newest entry heard on its first branch"
|
||||||
|
if _, said := b.supersededSaid.LoadOrStore(key, true); !said {
|
||||||
|
b.logf("%s at %s: %s", module, fp, why)
|
||||||
|
}
|
||||||
|
return why
|
||||||
|
}
|
||||||
|
|
||||||
// ModuleOf is a catalog entry in the form the builder builds by: its fingerprint, manifest digest, source (repository,
|
// ModuleOf is a catalog entry in the form the builder builds by: its fingerprint, manifest digest, source (repository,
|
||||||
// directory, commit; no source stamp, design 47 H H-A-48), the toolchains its fingerprint was computed with, the bases it is
|
// directory, commit; no source stamp, design 47 H H-A-48), the toolchains its fingerprint was computed with, the bases it is
|
||||||
// built against, its packages and needs, and the named paths of its artifacts when every artifact names them.
|
// built against, its packages and needs, and the named paths of its artifacts when every artifact names them.
|
||||||
@@ -637,6 +680,12 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
|||||||
whyEnded = fmt.Sprintf(format, args...)
|
whyEnded = fmt.Sprintf(format, args...)
|
||||||
b.logf("%s at %s: %s", module, m.Fp2, whyEnded)
|
b.logf("%s at %s: %s", module, m.Fp2, whyEnded)
|
||||||
}
|
}
|
||||||
|
// A fingerprint no longer the newest entry heard on its first branch is neither reserved for nor built (H-A-489): two
|
||||||
|
// fingerprints of one module never take the series from each other.
|
||||||
|
if newer := b.supersededBy(module, key, m.Fp2); newer != "" {
|
||||||
|
whyEnded = b.saySuperseded(module, key, m.Fp2, newer)
|
||||||
|
return
|
||||||
|
}
|
||||||
plan, planErr, read := b.planOf(ctx, m.Manifest)
|
plan, planErr, read := b.planOf(ctx, m.Manifest)
|
||||||
var noModule *NoBuildModule
|
var noModule *NoBuildModule
|
||||||
if errors.As(planErr, &noModule) {
|
if errors.As(planErr, &noModule) {
|
||||||
@@ -680,6 +729,12 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
|||||||
}
|
}
|
||||||
// Only a build of the registration's first watched branch reserves and releases a version (design 47 G §371).
|
// Only a build of the registration's first watched branch reserves and releases a version (design 47 G §371).
|
||||||
reserving := trunk && b.originOf(key).First && planErr == nil && !nothing && b.reserves(ctx, module, m, plan)
|
reserving := trunk && b.originOf(key).First && planErr == nil && !nothing && b.reserves(ctx, module, m, plan)
|
||||||
|
if trunk && b.originOf(key).First && planErr == nil && !nothing && !reserving {
|
||||||
|
// A done build whose digests its end did not record is recorded at the next look (design 47 H2 H-A-492).
|
||||||
|
if _, err := b.RecordAgain(ctx, module, m.Fp2, "at a look"); err != nil {
|
||||||
|
b.logf("%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
if reserving && b.waitFill(module, m) {
|
if reserving && b.waitFill(module, m) {
|
||||||
end("is not built yet: wait-held, the catalog has not said versions-filled")
|
end("is not built yet: wait-held, the catalog has not said versions-filled")
|
||||||
return
|
return
|
||||||
@@ -727,7 +782,7 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var reserved versions.ReservedVersion
|
var reserved versions.ReservedVersion
|
||||||
hasReserved := false
|
hasReserved, supersededNow := false, ""
|
||||||
if rebuild && cl.Build.State == builds.BuildBuilding {
|
if rebuild && cl.Build.State == builds.BuildBuilding {
|
||||||
// Reserved as A-490b amended by H-A-225 has it: this fingerprint's standing reservation is kept while it is unreleased
|
// Reserved as A-490b amended by H-A-225 has it: this fingerprint's standing reservation is kept while it is unreleased
|
||||||
// and above the highest the catalog's versions answers, else the next above that highest is taken (A-455); the build's
|
// and above the highest the catalog's versions answers, else the next above that highest is taken (A-455); the build's
|
||||||
@@ -737,10 +792,16 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
|||||||
}
|
}
|
||||||
reserving = true
|
reserving = true
|
||||||
} else if reserving && cl.Build.State != builds.BuildDone {
|
} else if reserving && cl.Build.State != builds.BuildDone {
|
||||||
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), false)
|
// Looked at again just before it reserves (H-A-489): a newer entry heard since the claim is not taken over.
|
||||||
|
if supersededNow = b.supersededBy(module, key, m.Fp2); supersededNow == "" {
|
||||||
|
reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var result builds.BuilderBuild
|
var result builds.BuilderBuild
|
||||||
if reserving && !hasReserved && cl.Build.State != builds.BuildDone {
|
if supersededNow != "" {
|
||||||
|
// Ended as the newer entry's take-in withdraws a build in flight: final for this fingerprint.
|
||||||
|
result = builds.BuilderBuild{State: builds.BuildFailed, Error: keyError([]string{withdrawnPrefix + supersededWhy(module, m.Fp2, supersededNow)})}
|
||||||
|
} else if reserving && !hasReserved && cl.Build.State != builds.BuildDone {
|
||||||
// A trunk build that reserves is never built without its version: it would end done and publish nothing, and its key would
|
// A trunk build that reserves is never built without its version: it would end done and publish nothing, and its key would
|
||||||
// stay done, never built again (A-490). The key fails with why and is taken again at the next look or by builder_build_again.
|
// stay done, never built again (A-490). The key fails with why and is taken again at the next look or by builder_build_again.
|
||||||
result = failed("no version is reserved for this build: the builder's journal says why, and it is built again once one can be")
|
result = failed("no version is reserved for this build: the builder's journal says why, and it is built again once one can be")
|
||||||
@@ -765,7 +826,7 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
|||||||
var w buildrun.Withdrawn
|
var w buildrun.Withdrawn
|
||||||
if ctx.Err() == nil && errors.As(context.Cause(run), &w) {
|
if ctx.Err() == nil && errors.As(context.Cause(run), &w) {
|
||||||
// Taken out, not stopped: the key says so, and the asks are withdrawn (the asker dropped them).
|
// Taken out, not stopped: the key says so, and the asks are withdrawn (the asker dropped them).
|
||||||
result = builds.BuilderBuild{State: builds.BuildFailed, Error: keyError([]string{"withdrawn: " + w.Why})}
|
result = builds.BuilderBuild{State: builds.BuildFailed, Error: keyError([]string{withdrawnPrefix + w.Why})}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
@@ -807,8 +868,13 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB
|
|||||||
for _, a := range result.Artifacts {
|
for _, a := range result.Artifacts {
|
||||||
digests[module+":"+a.Name] = a.Digest
|
digests[module+":"+a.Name] = a.Digest
|
||||||
}
|
}
|
||||||
if err := b.Reserved.Built(ctx, module, reserved.Version, digests, b.takeDependencies(key)); err != nil {
|
// Under the builder's own bound, never the build's context: a takeover or an end that cancels it no longer leaves a passed
|
||||||
b.logf("%s: the digests of %s are not recorded: %v", cl.Key, reserved.Version, err)
|
// build unrecorded, so unreleased (design 47 H2 H-A-492).
|
||||||
|
rec, stop := b.recordContext(ctx)
|
||||||
|
err := b.Reserved.Built(rec, module, reserved.Version, digests, b.takeDependencies(key))
|
||||||
|
stop()
|
||||||
|
if err != nil {
|
||||||
|
b.logf("%s: the digests of %s are not recorded: %v; recorded again at the builder's next look or start", cl.Key, reserved.Version, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if result.State == builds.BuildFailed {
|
if result.State == builds.BuildFailed {
|
||||||
|
|||||||
@@ -333,8 +333,9 @@ func TestAWithdrawnBuildEndsWithdrawn(t *testing.T) {
|
|||||||
r := newRig(t, goBundle)
|
r := newRig(t, goBundle)
|
||||||
asked, release := make(chan struct{}), make(chan struct{})
|
asked, release := make(chan struct{}), make(chan struct{})
|
||||||
answer := r.answer
|
answer := r.answer
|
||||||
|
var once sync.Once
|
||||||
r.asks.Answer = func(a buildstep.StepAsk) buildstep.Step {
|
r.asks.Answer = func(a buildstep.StepAsk) buildstep.Step {
|
||||||
close(asked)
|
once.Do(func() { close(asked) })
|
||||||
<-release
|
<-release
|
||||||
return answer(a)
|
return answer(a)
|
||||||
}
|
}
|
||||||
@@ -356,6 +357,85 @@ func TestAWithdrawnBuildEndsWithdrawn(t *testing.T) {
|
|||||||
if v := valueOf(t, r.st, r.key); v.State != builds.BuildFailed || !strings.Contains(v.Error, "withdrawn: its reservation 0.1.3 was taken over") {
|
if v := valueOf(t, r.st, r.key); v.State != builds.BuildFailed || !strings.Contains(v.Error, "withdrawn: its reservation 0.1.3 was taken over") {
|
||||||
t.Fatalf("the key = %+v, want failed withdrawn naming the take-over", v)
|
t.Fatalf("the key = %+v, want failed withdrawn naming the take-over", v)
|
||||||
}
|
}
|
||||||
|
// H-A-489: withdrawn is final for the fingerprint: a later look builds it not again; a person's build again does.
|
||||||
|
n, rev := len(r.asks.Asks()), r.st.revs[r.key]
|
||||||
|
r.b.Reconsider(context.Background())
|
||||||
|
r.b.Wait()
|
||||||
|
if v := valueOf(t, r.st, r.key); len(r.asks.Asks()) != n || r.st.revs[r.key] != rev || !strings.HasPrefix(v.Error, "withdrawn: ") {
|
||||||
|
t.Errorf("a later look built the withdrawn key again: %d asks (was %d), the key %+v", len(r.asks.Asks()), n, v)
|
||||||
|
}
|
||||||
|
if cl, err := r.b.Claimer.Claim(context.Background(), "m", fp1, mdigest('a'), ClaimOptions{ByHand: true}); err != nil || cl == nil {
|
||||||
|
t.Errorf("a person's build again of the withdrawn key was not claimed: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// H-A-489 (review round 1): a newer entry of the first branch heard between the older build's claim and its reservation is
|
||||||
|
// not taken over: the older key ends failed withdrawn with no reservation, and the newer reserves.
|
||||||
|
func TestANewerEntryHeardBeforeTheReservationIsNotTakenOver(t *testing.T) {
|
||||||
|
r := newRig(t, goBundle)
|
||||||
|
r.mf.byDigest[mdigest('a')] = catalogue.Manifest{Module: "m", Version: "0.1", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{goBundle}}}
|
||||||
|
res := &fakeReservations{filled: true}
|
||||||
|
r.b.Reserved = res
|
||||||
|
newer, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20",
|
||||||
|
Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
r.st.before = func() { r.b.Module(context.Background(), "m", newer) } // at the older key's claim
|
||||||
|
r.b.Module(context.Background(), "m", moduleValue(t, "modules/m"))
|
||||||
|
r.b.Wait()
|
||||||
|
if v := valueOf(t, r.st, r.key); v.State != builds.BuildFailed || !strings.HasPrefix(v.Error, "withdrawn: ") || !strings.Contains(v.Error, "superseded by the fingerprint "+fp2) {
|
||||||
|
t.Errorf("the older key = %+v, want failed withdrawn, superseded by %s", v, fp2)
|
||||||
|
}
|
||||||
|
if len(res.sources) != 1 || res.sources[0].Fingerprint != fp2 {
|
||||||
|
t.Errorf("reserved %+v, want one reservation, the newer's", res.sources)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// H-A-489: a fingerprint of the first branch that is no longer its newest entry heard is neither reserved for nor built, and
|
||||||
|
// said once; the again loop that looks at it later builds nothing.
|
||||||
|
func TestAnOlderFingerprintAskedAfterANewerEntryIsRefused(t *testing.T) {
|
||||||
|
r := newRig(t, goBundle)
|
||||||
|
var mu sync.Mutex
|
||||||
|
var said []string
|
||||||
|
r.b.Logf = func(f string, a ...any) { mu.Lock(); said = append(said, fmt.Sprintf(f, a...)); mu.Unlock() }
|
||||||
|
r.bm.fails["ace/build_go_build"] = "go build of tool: boom"
|
||||||
|
older := meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp2: fp1, Manifest: mdigest('a'),
|
||||||
|
Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}
|
||||||
|
r.b.Module(context.Background(), "m", moduleValue(t, "modules/m"))
|
||||||
|
r.b.Wait()
|
||||||
|
delete(r.bm.fails, "ace/build_go_build")
|
||||||
|
newer := older
|
||||||
|
newer.Fp2 = fp2
|
||||||
|
data, err := meshcatalogclient.EncodeModule(newer)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
r.b.Module(context.Background(), "m", data)
|
||||||
|
r.b.Wait()
|
||||||
|
rev := r.st.revs[r.key]
|
||||||
|
for range 2 {
|
||||||
|
r.b.consider(context.Background(), "m", older) // as consider's again loop or a step's look takes it
|
||||||
|
r.b.Wait()
|
||||||
|
}
|
||||||
|
if v := valueOf(t, r.st, r.key); v.State != builds.BuildFailed || r.st.revs[r.key] != rev {
|
||||||
|
t.Errorf("the older key = %+v at revision %d (was %d), want it left as it failed", v, r.st.revs[r.key], rev)
|
||||||
|
}
|
||||||
|
k2, _ := builds.BuilderBuildKey("m", fp2)
|
||||||
|
if v := valueOf(t, r.st, k2); v.State != builds.BuildDone {
|
||||||
|
t.Errorf("the newer key = %+v, want done", v)
|
||||||
|
}
|
||||||
|
mu.Lock()
|
||||||
|
defer mu.Unlock()
|
||||||
|
n := 0
|
||||||
|
for _, l := range said {
|
||||||
|
if strings.Contains(l, fp1+": is not built: superseded by "+fp2) {
|
||||||
|
n++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if n != 1 {
|
||||||
|
t.Errorf("superseded said %d times, want once: %q", n, said)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1887/AC1, AC2: a trunk fingerprint with no key is one ask on the Go seat's delivery stream, named in the building key
|
// 1887/AC1, AC2: a trunk fingerprint with no key is one ask on the Go seat's delivery stream, named in the building key
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ import (
|
|||||||
// number is needed, and the builder follows no candidate.
|
// number is needed, and the builder follows no candidate.
|
||||||
|
|
||||||
// BuildStep builds the entries of the step ask ask and answers its end: passed when every entry's build is done, failed when
|
// BuildStep builds the entries of the step ask ask and answers its end: passed when every entry's build is done, failed when
|
||||||
// one failed (said), could not run when an entry could not be read, nothing to run for an ask naming none. The node is the
|
// one failed (said), superseded when none failed and a newer entry of its branch superseded one (H-A-508), could not run when
|
||||||
|
// an entry could not be read, nothing to run for an ask naming none. The node is the
|
||||||
// caller's to set.
|
// caller's to set.
|
||||||
func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.StepRun) meshbuilds.StepEnded {
|
func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.StepRun) meshbuilds.StepEnded {
|
||||||
b.init()
|
b.init()
|
||||||
started := b.now()
|
started := b.now()
|
||||||
end := meshbuilds.StepEnded{V: 1, ID: ask, Pipeline: run.Pipeline, Step: meshbuilds.StepEndedStepBuild, Rerun: run.Rerun, By: run.By, Entries: run.Entries, Node: b.Node, Started: &started}
|
end := meshbuilds.StepEnded{V: 1, Form: meshbuilds.Form, ID: ask, Pipeline: run.Pipeline, Step: meshbuilds.StepEndedStepBuild, Rerun: run.Rerun, By: run.By, Entries: run.Entries, Node: b.Node, Started: &started}
|
||||||
// finish is the one place the ask is answered: one journal line, "answered <ask> <pipeline> <movers> <step> <outcome>"
|
// finish is the one place the ask is answered: one journal line, "answered <ask> <pipeline> <movers> <step> <outcome>"
|
||||||
// (design 47 H2 §792; H-A-320 (1), H-A-333).
|
// (design 47 H2 §792; H-A-320 (1), H-A-333).
|
||||||
finish := func(outcome, said string) meshbuilds.StepEnded {
|
finish := func(outcome, said string) meshbuilds.StepEnded {
|
||||||
@@ -58,7 +59,7 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step
|
|||||||
return finish(outcome, said)
|
return finish(outcome, said)
|
||||||
}
|
}
|
||||||
b.askedRevision(run)
|
b.askedRevision(run)
|
||||||
var failed []string
|
var failed, superseded []string
|
||||||
for _, e := range run.Entries {
|
for _, e := range run.Entries {
|
||||||
var pins map[string]string
|
var pins map[string]string
|
||||||
outcome, said := b.buildEntry(ctx, run.Pipeline, e, &pins)
|
outcome, said := b.buildEntry(ctx, run.Pipeline, e, &pins)
|
||||||
@@ -77,11 +78,16 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step
|
|||||||
return finish(outcome, said)
|
return finish(outcome, said)
|
||||||
case meshbuilds.StepEndedOutcomeFailed:
|
case meshbuilds.StepEndedOutcomeFailed:
|
||||||
failed = append(failed, said)
|
failed = append(failed, said)
|
||||||
|
case meshbuilds.StepEndedOutcomeSuperseded:
|
||||||
|
superseded = append(superseded, said)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(failed) > 0 {
|
if len(failed) > 0 {
|
||||||
return finish(meshbuilds.StepEndedOutcomeFailed, strings.Join(failed, "; "))
|
return finish(meshbuilds.StepEndedOutcomeFailed, strings.Join(failed, "; "))
|
||||||
}
|
}
|
||||||
|
if len(superseded) > 0 {
|
||||||
|
return finish(meshbuilds.StepEndedOutcomeSuperseded, strings.Join(superseded, "; "))
|
||||||
|
}
|
||||||
return finish(meshbuilds.StepEndedOutcomePassed, "")
|
return finish(meshbuilds.StepEndedOutcomePassed, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +139,19 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds.
|
|||||||
b.logf("%s@%s build step answered %s for %s (%s)", entry.Module, entry.Fp, outcome, pipeline, how)
|
b.logf("%s@%s build step answered %s for %s (%s)", entry.Module, entry.Fp, outcome, pipeline, how)
|
||||||
return outcome, said
|
return outcome, said
|
||||||
}
|
}
|
||||||
if done, failedWords, found := b.keyEnd(ctx, key); found {
|
done, failedWords, found := b.keyEnd(ctx, key)
|
||||||
|
// The fingerprint is judged against its branch's newest entry first, for a done build as for one not built (H-A-508): a
|
||||||
|
// superseded one ends the step superseded, naming the superseding fingerprint, never failed. One not built is refused, not
|
||||||
|
// waited on (H-A-489): no look builds a superseded fingerprint, so its end would never come.
|
||||||
|
if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" {
|
||||||
|
how := "existing build"
|
||||||
|
if !found {
|
||||||
|
how = "refused"
|
||||||
|
b.saySuperseded(entry.Module, key, entry.Fp, newer)
|
||||||
|
}
|
||||||
|
return answered(meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer), how)
|
||||||
|
}
|
||||||
|
if found {
|
||||||
if done {
|
if done {
|
||||||
// A key done before reports the pins it was built with, kept with it, never the ones a publish gives now.
|
// A key done before reports the pins it was built with, kept with it, never the ones a publish gives now.
|
||||||
*pins = b.keptPins(ctx, key)
|
*pins = b.keptPins(ctx, key)
|
||||||
@@ -147,6 +165,11 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds.
|
|||||||
b.consider(ctx, entry.Module, m)
|
b.consider(ctx, entry.Module, m)
|
||||||
select {
|
select {
|
||||||
case log := <-ended:
|
case log := <-ended:
|
||||||
|
// A fingerprint a newer entry superseded while it built (its build withdrawn, or done) ends superseded, judged before
|
||||||
|
// the log's outcome (H-A-508).
|
||||||
|
if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" {
|
||||||
|
return answered(meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer), "built now")
|
||||||
|
}
|
||||||
if log.Outcome == builds.BuildDone {
|
if log.Outcome == builds.BuildDone {
|
||||||
*pins = b.keptPins(ctx, key)
|
*pins = b.keptPins(ctx, key)
|
||||||
outcome, said := b.passedWithItsVersion(ctx, entry)
|
outcome, said := b.passedWithItsVersion(ctx, entry)
|
||||||
@@ -164,13 +187,18 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds.
|
|||||||
// that can never be released, and one whose series another fingerprint took over fails saying it is stale, naming that
|
// that can never be released, and one whose series another fingerprint took over fails saying it is stale, naming that
|
||||||
// fingerprint and its version (design 47 H H-A-244). A build that reserves none (a candidate's, a series of before G) passes as it did.
|
// fingerprint and its version (design 47 H H-A-244). A build that reserves none (a candidate's, a series of before G) passes as it did.
|
||||||
func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.CatalogEntry) (outcome, said string) {
|
func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.CatalogEntry) (outcome, said string) {
|
||||||
if b.Reserved == nil {
|
|
||||||
return meshbuilds.StepEndedOutcomePassed, ""
|
|
||||||
}
|
|
||||||
key, err := builds.BuilderBuildKey(entry.Module, entry.Fp)
|
key, err := builds.BuilderBuildKey(entry.Module, entry.Fp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return meshbuilds.StepEndedOutcomeCouldNotRun, err.Error()
|
return meshbuilds.StepEndedOutcomeCouldNotRun, err.Error()
|
||||||
}
|
}
|
||||||
|
// The fingerprint is judged against its branch's newest entry first (H-A-508): a superseded one ends superseded, whatever
|
||||||
|
// its reservation, release or takeover says.
|
||||||
|
if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" {
|
||||||
|
return meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer)
|
||||||
|
}
|
||||||
|
if b.Reserved == nil {
|
||||||
|
return meshbuilds.StepEndedOutcomePassed, ""
|
||||||
|
}
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
reserving := b.trunkFP[key] && b.origin[key].First
|
reserving := b.trunkFP[key] && b.origin[key].First
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
@@ -205,6 +233,11 @@ func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.Ca
|
|||||||
return meshbuilds.StepEndedOutcomePassed, ""
|
return meshbuilds.StepEndedOutcomePassed, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stepSuperseded is the why of a build step ended superseded (H-A-508): the fingerprint and the newer entry that superseded it.
|
||||||
|
func stepSuperseded(module, fp, newer string) string {
|
||||||
|
return fmt.Sprintf("%s at %s is superseded by %s, the newest entry heard on its first branch", module, fp, newer)
|
||||||
|
}
|
||||||
|
|
||||||
// keptPins are the pins a done key keeps it was built with (H-A-207); none when it keeps none or cannot be read, so the
|
// keptPins are the pins a done key keeps it was built with (H-A-207); none when it keeps none or cannot be read, so the
|
||||||
// runner ends the steps that waited for them could not run, loud.
|
// runner ends the steps that waited for them could not run, loud.
|
||||||
func (b *Builder) keptPins(ctx context.Context, key string) map[string]string {
|
func (b *Builder) keptPins(ctx context.Context, key string) map[string]string {
|
||||||
@@ -232,7 +265,7 @@ func (b *Builder) keyEnd(ctx context.Context, key string) (done bool, failed str
|
|||||||
switch {
|
switch {
|
||||||
case v.State == builds.BuildDone && !Unpublished(v, b.Seats):
|
case v.State == builds.BuildDone && !Unpublished(v, b.Seats):
|
||||||
return true, "", true
|
return true, "", true
|
||||||
case v.State == builds.BuildFailed && builds.FailedUntilChanged(v.Error):
|
case v.State == builds.BuildFailed && (builds.FailedUntilChanged(v.Error) || strings.HasPrefix(v.Error, withdrawnPrefix)):
|
||||||
return false, key + ": " + v.Error, true
|
return false, key + ": " + v.Error, true
|
||||||
}
|
}
|
||||||
return false, "", false
|
return false, "", false
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -12,7 +13,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||||
@@ -74,6 +77,21 @@ func TestABuildStepAnswersItsEnd(t *testing.T) {
|
|||||||
if end := ask(entries...); end.Outcome != meshbuilds.StepEndedOutcomePassed || end.Step != meshbuilds.StepEndedStepBuild || len(end.Entries) != 1 || end.Entries[0].Commit != "c1" || end.Pipeline != "main.1.m" {
|
if end := ask(entries...); end.Outcome != meshbuilds.StepEndedOutcomePassed || end.Step != meshbuilds.StepEndedStepBuild || len(end.Entries) != 1 || end.Entries[0].Commit != "c1" || end.Pipeline != "main.1.m" {
|
||||||
t.Errorf("a done build: %+v", end)
|
t.Errorf("a done build: %+v", end)
|
||||||
}
|
}
|
||||||
|
// H-A-489 (review round 1): a withdrawn key whose fingerprint is still the newest entry is answered failed at once, naming
|
||||||
|
// withdrawn: no look builds it again, so its end is never waited for.
|
||||||
|
rw := newRig(t, catalogue.Artifact{Name: "files", Kind: "archive"})
|
||||||
|
rw.b.StepEntry = r.b.StepEntry
|
||||||
|
withdrawn, _ := builds.EncodeBuilderBuild(builds.BuilderBuild{State: builds.BuildFailed, Manifest: mdigest('a'), Error: withdrawnPrefix + "its reservation 0.1.3 was taken over"})
|
||||||
|
if _, err := rw.st.Create(t.Context(), rw.key, withdrawn); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
rw.b.Module(t.Context(), "m", moduleValue(t, "modules/m")) // the newest entry heard is fp1
|
||||||
|
rw.b.Wait()
|
||||||
|
bounded, cancel := context.WithTimeout(t.Context(), 2*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
if end := rw.b.BuildStep(bounded, "ask1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: entries}); end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "withdrawn: ") {
|
||||||
|
t.Errorf("a withdrawn key asked: %+v, want failed at once naming withdrawn", end)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A step ask waits for the end of its build without a timer: the log entry of that end wakes it (design 47 G A-97).
|
// A step ask waits for the end of its build without a timer: the log entry of that end wakes it (design 47 G A-97).
|
||||||
@@ -109,15 +127,20 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T)
|
|||||||
for _, c := range []struct {
|
for _, c := range []struct {
|
||||||
name, version string
|
name, version string
|
||||||
reserve, released, unreadable bool
|
reserve, released, unreadable bool
|
||||||
takenOver bool
|
takenOver, superseded bool
|
||||||
want, said string
|
want, said string
|
||||||
}{
|
}{
|
||||||
{"no version reserved", "0.1", false, false, false, false, meshbuilds.StepEndedOutcomeFailed, "built at " + fp1 + ", but no version is reserved for it"},
|
{"no version reserved", "0.1", false, false, false, false, false, meshbuilds.StepEndedOutcomeFailed, "built at " + fp1 + ", but no version is reserved for it"},
|
||||||
{"H-A-244: its series was taken over by a newer fingerprint", "0.1", false, false, false, true, meshbuilds.StepEndedOutcomeFailed, "m: built at " + fp1 + " but its series moved to " + fp2 + " 0.1.7: stale"},
|
{"H-A-244: its series was taken over by a newer fingerprint", "0.1", false, false, false, true, false, meshbuilds.StepEndedOutcomeFailed, "m: built at " + fp1 + " but its series moved to " + fp2 + " 0.1.7: stale"},
|
||||||
{"a version reserved", "0.1", true, false, false, false, meshbuilds.StepEndedOutcomePassed, ""},
|
// H-A-508: a done build a newer entry of its branch superseded is judged against that entry first, its takeover lost
|
||||||
{"a released build whose reservation is gone", "0.1", false, true, false, false, meshbuilds.StepEndedOutcomePassed, ""},
|
// with the release that deleted it: superseded, naming the newer fingerprint, never "no version is reserved".
|
||||||
{"the plan cannot be read", "0.1", false, false, true, false, meshbuilds.StepEndedOutcomeCouldNotRun, "plan cannot be read"},
|
{"H-A-508: a done build a newer entry superseded", "0.1", false, false, false, false, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2},
|
||||||
{"a series of before G", "1", false, false, false, false, meshbuilds.StepEndedOutcomePassed, ""},
|
{"H-A-508: a done build a newer entry superseded, though a version is reserved", "0.1", true, false, false, false, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2},
|
||||||
|
{"H-A-508: a done build a newer entry superseded, its series taken over", "0.1", false, false, false, true, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2},
|
||||||
|
{"a version reserved", "0.1", true, false, false, false, false, meshbuilds.StepEndedOutcomePassed, ""},
|
||||||
|
{"a released build whose reservation is gone", "0.1", false, true, false, false, false, meshbuilds.StepEndedOutcomePassed, ""},
|
||||||
|
{"the plan cannot be read", "0.1", false, false, true, false, false, meshbuilds.StepEndedOutcomeCouldNotRun, "plan cannot be read"},
|
||||||
|
{"a series of before G", "1", false, false, false, false, false, meshbuilds.StepEndedOutcomePassed, ""},
|
||||||
} {
|
} {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
r := newRig(t, goBundle)
|
r := newRig(t, goBundle)
|
||||||
@@ -129,6 +152,15 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T)
|
|||||||
if v := r.consider(t, "modules/m"); v.State != builds.BuildDone { // built while the builder reserved nothing, as the live key was
|
if v := r.consider(t, "modules/m"); v.State != builds.BuildDone { // built while the builder reserved nothing, as the live key was
|
||||||
t.Fatalf("build = %+v, want done", v)
|
t.Fatalf("build = %+v, want done", v)
|
||||||
}
|
}
|
||||||
|
if c.superseded { // a newer entry of the branch heard after the build
|
||||||
|
newer, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20",
|
||||||
|
Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
r.b.Module(t.Context(), "m", newer)
|
||||||
|
r.b.Wait()
|
||||||
|
}
|
||||||
r.b.Reserved = res
|
r.b.Reserved = res
|
||||||
if c.reserve {
|
if c.reserve {
|
||||||
res.sources = append(res.sources, versions.Source{Fingerprint: fp1})
|
res.sources = append(res.sources, versions.Source{Fingerprint: fp1})
|
||||||
@@ -140,8 +172,16 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T)
|
|||||||
if end.Outcome != c.want || !strings.Contains(end.Said, c.said) || (c.want == meshbuilds.StepEndedOutcomeFailed && strings.Contains(end.Said, "builder_reserve_done") == c.takenOver) {
|
if end.Outcome != c.want || !strings.Contains(end.Said, c.said) || (c.want == meshbuilds.StepEndedOutcomeFailed && strings.Contains(end.Said, "builder_reserve_done") == c.takenOver) {
|
||||||
t.Errorf("end = %+v, want %s saying %q", end, c.want, c.said)
|
t.Errorf("end = %+v, want %s saying %q", end, c.want, c.said)
|
||||||
}
|
}
|
||||||
|
// The verdict of a build that ended done, as a build ended now is judged, says the same (H-A-508: the newest entry first).
|
||||||
|
if c.superseded {
|
||||||
|
entry, _ := r.b.StepEntry(t.Context(), fp1)
|
||||||
|
if outcome, said := r.b.passedWithItsVersion(t.Context(), entry); outcome != c.want || !strings.Contains(said, c.said) {
|
||||||
|
t.Errorf("built now: %s %q, want %s saying %q", outcome, said, c.want, c.said)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
t.Run("H-A-508: built now, superseded: a newer entry heard while the build runs ends the step superseded", aNewerEntryWhileTheBuildRunsSupersedesTheStep)
|
||||||
t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision)
|
t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision)
|
||||||
t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails)
|
t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails)
|
||||||
t.Run("H-A-205: an ask of a revision below the picture's newest is read by number and built", anOlderKeptRevisionIsReadByNumber)
|
t.Run("H-A-205: an ask of a revision below the picture's newest is read by number and built", anOlderKeptRevisionIsReadByNumber)
|
||||||
@@ -434,9 +474,10 @@ func aStepAskWaitsForItsRevision(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// H-A-205: two pipelines of consecutive revisions run at once; the picture holds source revision 46, whose entry of m moved
|
// H-A-205: two pipelines of consecutive revisions run at once; the picture holds source revision 46, while the older pipeline
|
||||||
// on, while the older pipeline asks the build of revision 45. Its kept catalog revision is read by number and the build runs;
|
// asks the build of revision 45. Its kept catalog revision is read by number and the build runs while the picture never heard
|
||||||
// a kept revision naming another fingerprint fails the step, naming it.
|
// a newer entry of m (a restart); once it heard one on the first branch, H-A-489 overrides H-A-205 and the older ask is refused
|
||||||
|
// superseded. A kept revision naming another fingerprint ends the step superseded, naming it (H-A-508 second addendum).
|
||||||
func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
|
func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
|
||||||
var held atomic.Int64
|
var held atomic.Int64
|
||||||
held.Store(46)
|
held.Store(46)
|
||||||
@@ -460,13 +501,33 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
|
|||||||
if len(res.sources) != 1 || res.sources[0].Revision != 45 || res.sources[0].CatalogRevision != 47 {
|
if len(res.sources) != 1 || res.sources[0].Revision != 45 || res.sources[0].CatalogRevision != 47 {
|
||||||
t.Errorf("reserved from %+v; want one version reserved from source revision 45 at catalog revision 47 (H-A-218)", res.sources)
|
t.Errorf("reserved from %+v; want one version reserved from source revision 45 at catalog revision 47 (H-A-218)", res.sources)
|
||||||
}
|
}
|
||||||
|
// H-A-489, H-A-508: once the picture heard the newer entry of m on the first branch, the older ask ends superseded (never
|
||||||
|
// failed) and nothing is built or reserved for it; the newer entry's build keeps the series.
|
||||||
|
rn, resn, entryn := revisionRig(t, &held, make(chan struct{}, 1))
|
||||||
|
rn.b.RevisionWait = time.Nanosecond
|
||||||
|
rn.b.FirstBranch = r.b.FirstBranch
|
||||||
|
rn.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) {
|
||||||
|
return 45, map[string]string{"m": fp1}, nil
|
||||||
|
}
|
||||||
|
entryn.Fp = fp2
|
||||||
|
rn.b.Entry(context.Background(), Origin{Branch: "main", Source: 46, First: true}, entryn)
|
||||||
|
rn.b.Wait()
|
||||||
|
if endn := rn.b.BuildStep(t.Context(), "a1", run); endn.Outcome != meshbuilds.StepEndedOutcomeSuperseded || !strings.Contains(endn.Said, "superseded by "+fp2) {
|
||||||
|
t.Errorf("the older ask after the newer entry: end = %+v; want superseded by %s", endn, fp2)
|
||||||
|
}
|
||||||
|
rn.b.Wait()
|
||||||
|
if _, built := rn.st.vals[rn.key]; built || len(resn.sources) != 1 || resn.sources[0].Fingerprint != fp2 {
|
||||||
|
t.Errorf("built %v, reserved %+v; want nothing built for the older, one reservation, the newer's", built, resn.sources)
|
||||||
|
}
|
||||||
r2, _, _ := revisionRig(t, &held, make(chan struct{}, 1))
|
r2, _, _ := revisionRig(t, &held, make(chan struct{}, 1))
|
||||||
r2.b.RevisionWait = time.Nanosecond
|
r2.b.RevisionWait = time.Nanosecond
|
||||||
r2.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) {
|
r2.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) {
|
||||||
return 45, map[string]string{"m": "src2:other"}, nil
|
return 45, map[string]string{"m": "src2:other"}, nil
|
||||||
}
|
}
|
||||||
if end := r2.b.BuildStep(t.Context(), "a1", run); end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "names m at \"src2:other\"") {
|
// H-A-508 second addendum: below the picture, a kept revision naming another fingerprint of the module superseded the
|
||||||
t.Errorf("end = %+v; want failed naming the fingerprint the kept revision names", end)
|
// ask's: the step ends superseded naming it, never failed with the "below" words.
|
||||||
|
if end := r2.b.BuildStep(t.Context(), "a1", run); end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || end.Said != stepSuperseded("m", fp1, "src2:other") {
|
||||||
|
t.Errorf("end = %+v; want superseded naming the fingerprint the kept revision names", end)
|
||||||
}
|
}
|
||||||
// H-A-222: an ask of the very source the picture holds, whose entries the picture no longer names (a re-pin kept revision 48
|
// H-A-222: an ask of the very source the picture holds, whose entries the picture no longer names (a re-pin kept revision 48
|
||||||
// of the same source 46 and the picture took its entries in), is held by its revision read by number, never waited for.
|
// of the same source 46 and the picture took its entries in), is held by its revision read by number, never waited for.
|
||||||
@@ -485,7 +546,7 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
|
|||||||
if end3.Outcome != meshbuilds.StepEndedOutcomePassed || !slices.Equal(read3, []string{"main 48"}) || len(res3.sources) != 1 || res3.sources[0].CatalogRevision != 48 {
|
if end3.Outcome != meshbuilds.StepEndedOutcomePassed || !slices.Equal(read3, []string{"main 48"}) || len(res3.sources) != 1 || res3.sources[0].CatalogRevision != 48 {
|
||||||
t.Errorf("end = %+v, kept revisions read %v, reserved %+v; want passed, revision 48 of main read once and reserved at it", end3, read3, res3.sources)
|
t.Errorf("end = %+v, kept revisions read %v, reserved %+v; want passed, revision 48 of main read once and reserved at it", end3, read3, res3.sources)
|
||||||
}
|
}
|
||||||
// H-A-218, H-A-222: a kept revision of another source than the ask names, or naming another fingerprint, is a mismatch:
|
// H-A-218, H-A-222: a kept revision of another source than the ask names is a mismatch:
|
||||||
// the step fails at once naming it, never waiting out its bound (the bound here is long, the ask is not below the picture).
|
// the step fails at once naming it, never waiting out its bound (the bound here is long, the ask is not below the picture).
|
||||||
for _, c := range []struct {
|
for _, c := range []struct {
|
||||||
name string
|
name string
|
||||||
@@ -494,7 +555,6 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
|
|||||||
said string
|
said string
|
||||||
}{
|
}{
|
||||||
{"another source", 45, fp1, "the catalog's revision 48 is of source revision 45, the ask names 46"},
|
{"another source", 45, fp1, "the catalog's revision 48 is of source revision 45, the ask names 46"},
|
||||||
{"another fingerprint", 46, "src2:other", "names m at \"src2:other\""},
|
|
||||||
} {
|
} {
|
||||||
rc, resc, _ := revisionRig(t, &held, make(chan struct{}, 1))
|
rc, resc, _ := revisionRig(t, &held, make(chan struct{}, 1))
|
||||||
rc.b.RevisionWait = time.Hour
|
rc.b.RevisionWait = time.Hour
|
||||||
@@ -507,6 +567,18 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) {
|
|||||||
t.Errorf("%s: end = %+v, reserved %+v; want failed at once saying %q, nothing reserved", c.name, end, resc.sources, c.said)
|
t.Errorf("%s: end = %+v, reserved %+v; want failed at once saying %q, nothing reserved", c.name, end, resc.sources, c.said)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// H-A-508 second addendum, found by either check: a revision read by its number (H-A-222) whose kept revision names another
|
||||||
|
// fingerprint of m superseded the ask's: it ends superseded at once naming it, never failed and never waiting its bound.
|
||||||
|
rs, ress, _ := revisionRig(t, &held, make(chan struct{}, 1))
|
||||||
|
rs.b.RevisionWait = time.Hour
|
||||||
|
rs.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) {
|
||||||
|
return 46, map[string]string{"m": "src2:other"}, nil
|
||||||
|
}
|
||||||
|
ends := rs.b.BuildStep(t.Context(), "a1", same)
|
||||||
|
rs.b.Wait()
|
||||||
|
if ends.Outcome != meshbuilds.StepEndedOutcomeSuperseded || ends.Said != stepSuperseded("m", fp1, "src2:other") || len(ress.sources) != 0 {
|
||||||
|
t.Errorf("by its number, another fingerprint: end = %+v, reserved %+v; want superseded by src2:other at once, nothing reserved", ends, ress.sources)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func aStepAskPastItsRevisionBoundFails(t *testing.T) {
|
func aStepAskPastItsRevisionBoundFails(t *testing.T) {
|
||||||
@@ -534,3 +606,65 @@ func digestOf(unreadable bool) string {
|
|||||||
}
|
}
|
||||||
return mdigest('a')
|
return mdigest('a')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// H-A-508 (review rounds 1, 2): a newer entry of the branch heard while the step's build runs withdraws that build (the key
|
||||||
|
// ends "withdrawn: … superseded by …", as main.327's mesh-delivery-gate build did); the step waiting on it ends superseded,
|
||||||
|
// naming the newer fingerprint, judged before the build's failed end, never failed.
|
||||||
|
func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) {
|
||||||
|
r := newRig(t, goBundle)
|
||||||
|
var asked int32
|
||||||
|
running := make(chan struct{})
|
||||||
|
r.asks.Answer = func(a buildstep.StepAsk) buildstep.Step {
|
||||||
|
if atomic.AddInt32(&asked, 1) == 1 { // fp1's ask runs until it is withdrawn
|
||||||
|
defer close(running)
|
||||||
|
return buildstep.Step{ID: a.ID, Node: "ace", State: buildstep.StepRunning, Started: time.Now()}
|
||||||
|
}
|
||||||
|
return r.answer(a)
|
||||||
|
}
|
||||||
|
r.b.Asks = buildrun.Asker{Seats: testSeats(), Publisher: r.asks, Waiter: r.asks, Bound: 2 * time.Second, Dropper: &seatDrops{}}
|
||||||
|
r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) {
|
||||||
|
return meshcatalog.CatalogEntry{Module: "m", Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp: fp1, ManifestDigest: mdigest('a'), Path: "modules/m"}, nil
|
||||||
|
}
|
||||||
|
r.b.Module(t.Context(), "m", moduleValue(t, "modules/m")) // fp1, the newest entry heard, is built
|
||||||
|
<-running
|
||||||
|
ended := make(chan meshbuilds.StepEnded, 1)
|
||||||
|
go func() {
|
||||||
|
ended <- r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||||
|
}()
|
||||||
|
// The step waits on the end of fp1's build in flight before the newer entry is heard.
|
||||||
|
for deadline := time.Now().Add(5 * time.Second); ; runtime.Gosched() {
|
||||||
|
r.b.mu.Lock()
|
||||||
|
n := len(r.b.stepWaits[r.key])
|
||||||
|
r.b.mu.Unlock()
|
||||||
|
if n > 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case end := <-ended:
|
||||||
|
t.Fatalf("the step ended before it waited on the build in flight: %+v", end)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
if time.Now().After(deadline) {
|
||||||
|
t.Fatal("the step never waited on the build in flight")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newer, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20",
|
||||||
|
Fp: "src1:" + hex64('f'), Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
r.b.Module(t.Context(), "m", newer)
|
||||||
|
var end meshbuilds.StepEnded
|
||||||
|
select {
|
||||||
|
case end = <-ended:
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.Fatal("the step never ended")
|
||||||
|
}
|
||||||
|
r.b.Wait()
|
||||||
|
if v := valueOf(t, r.st, r.key); v.State != builds.BuildFailed || !strings.HasPrefix(v.Error, withdrawnPrefix) || !strings.Contains(v.Error, "superseded by the fingerprint "+fp2) {
|
||||||
|
t.Fatalf("fp1's key = %+v, want its build withdrawn, superseded by %s", v, fp2)
|
||||||
|
}
|
||||||
|
if end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || !strings.Contains(end.Said, "m at "+fp1+" is superseded by "+fp2) {
|
||||||
|
t.Errorf("end = %+v, want superseded by %s", end, fp2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -74,14 +74,11 @@ const ModePublish = "publish"
|
|||||||
// optional, name what to publish again; the builder answers with the versions it queued (Queued).
|
// optional, name what to publish again; the builder answers with the versions it queued (Queued).
|
||||||
const ModeRepublish = "republish"
|
const ModeRepublish = "republish"
|
||||||
|
|
||||||
// ModePublishDrop and ModePublishFirst are the Modes of a reasks value of builder_publish_drop and builder_publish_first (design
|
// ModePublishDrop is the Mode of a reasks value of builder_publish_drop (design 47 H2 §793): Module and Version name the item;
|
||||||
// 47 H2 §793): Module and Version name the item; the builder terminates it, or puts it again as live and terminates the old.
|
// the builder terminates it.
|
||||||
const (
|
const ModePublishDrop = "publish-drop"
|
||||||
ModePublishDrop = "publish-drop"
|
|
||||||
ModePublishFirst = "publish-first"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewPublishAct is the value builder_publish_drop (mode ModePublishDrop) or builder_publish_first (ModePublishFirst) writes
|
// NewPublishAct is the value builder_publish_drop (mode ModePublishDrop) writes
|
||||||
// (§793): its key, `<mode>.<unix nanoseconds>` (a call is one value), and the value. Module, version and why are required.
|
// (§793): its key, `<mode>.<unix nanoseconds>` (a call is one value), and the value. Module, version and why are required.
|
||||||
func NewPublishAct(mode, module, version, why, by string, at time.Time) (string, []byte, error) {
|
func NewPublishAct(mode, module, version, why, by string, at time.Time) (string, []byte, error) {
|
||||||
module, version = strings.TrimSpace(module), strings.TrimSpace(version)
|
module, version = strings.TrimSpace(module), strings.TrimSpace(version)
|
||||||
|
|||||||
@@ -27,10 +27,8 @@ type Acts struct {
|
|||||||
ReserveDone func(ctx context.Context, module, fp, by, why string, at time.Time) (string, error)
|
ReserveDone func(ctx context.Context, module, fp, by, why string, at time.Time) (string, error)
|
||||||
// DropReserved drops a module's reservation of one MAJOR.MINOR by hand (builder_reserved_drop): its answer, or why not.
|
// DropReserved drops a module's reservation of one MAJOR.MINOR by hand (builder_reserved_drop): its answer, or why not.
|
||||||
DropReserved func(ctx context.Context, module, series, by, why string, at time.Time) (string, error)
|
DropReserved func(ctx context.Context, module, series, by, why string, at time.Time) (string, error)
|
||||||
// PublishDrop terminates one publish item, and PublishFirst puts it again as live and terminates the old (builder_publish_drop,
|
// PublishDrop terminates one publish item (builder_publish_drop, design 47 H2 §793): the answer, or why not.
|
||||||
// builder_publish_first, design 47 H2 §793): the answer, or why not.
|
PublishDrop func(ctx context.Context, module, version, by, why string) (string, error)
|
||||||
PublishDrop func(ctx context.Context, module, version, by, why string) (string, error)
|
|
||||||
PublishFirst func(ctx context.Context, module, version, by, why string) (string, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FloorAgain is builder_floor_again of name: refused, since the builder numbers nothing of its own and no claim asks a floor
|
// FloorAgain is builder_floor_again of name: refused, since the builder numbers nothing of its own and no claim asks a floor
|
||||||
|
|||||||
@@ -37,9 +37,8 @@ const (
|
|||||||
PublishQueueTool = "builder_publish_queue"
|
PublishQueueTool = "builder_publish_queue"
|
||||||
// QueueFull is what version-unreleased says of a version the work queue's cap refused.
|
// QueueFull is what version-unreleased says of a version the work queue's cap refused.
|
||||||
QueueFull = "queue full"
|
QueueFull = "queue full"
|
||||||
// PublishDropTool and PublishFirstTool are builder_publish_drop and builder_publish_first (§793).
|
// PublishDropTool is builder_publish_drop (§793); builder_publish_first is retired (H-A-483, third addendum).
|
||||||
PublishDropTool = "builder_publish_drop"
|
PublishDropTool = "builder_publish_drop"
|
||||||
PublishFirstTool = "builder_publish_first"
|
|
||||||
// NotStoredWords opens what a refused artifact is said as.
|
// NotStoredWords opens what a refused artifact is said as.
|
||||||
NotStoredWords = "not stored: "
|
NotStoredWords = "not stored: "
|
||||||
// VerbPublish is the registry seats' verb a publish again sends, VerbVersions the one whose record says what a seat holds
|
// VerbPublish is the registry seats' verb a publish again sends, VerbVersions the one whose record says what a seat holds
|
||||||
@@ -48,7 +47,7 @@ const (
|
|||||||
VerbVersions = "versions"
|
VerbVersions = "versions"
|
||||||
// PublishClassLive is the class of a publish whose build ended in this run, which a pipeline's build step waits on;
|
// PublishClassLive is the class of a publish whose build ended in this run, which a pipeline's build step waits on;
|
||||||
// PublishClassStart that of a publish asked again at a start, of a build that ended before it. A holder's items are pulled
|
// PublishClassStart that of a publish asked again at a start, of a build that ended before it. A holder's items are pulled
|
||||||
// live first, each class oldest first (design 47 H H-A-290 (1), H2 §793).
|
// by its one consumer in the order they are put (design 47 H H-A-290 (1), H2 §793, H-A-483).
|
||||||
PublishClassLive = "live"
|
PublishClassLive = "live"
|
||||||
PublishClassStart = "again"
|
PublishClassStart = "again"
|
||||||
// PublishSendsAtOnce bounds the sends of one holder that run at once, its consumers' max ack pending (H-A-290 (3), §793).
|
// PublishSendsAtOnce bounds the sends of one holder that run at once, its consumers' max ack pending (H-A-290 (3), §793).
|
||||||
@@ -97,21 +96,19 @@ type QueuedPublish struct {
|
|||||||
Class string `json:"class,omitempty"`
|
Class string `json:"class,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// rank is the place of q's class in a holder's queue: the live first.
|
// streamOrder sorts the keys of the work queue's items in stream order: each key is its item's stream sequence (the builder's
|
||||||
func (q QueuedPublish) rank() int {
|
// reader, publishitem.go), compared as a number; a key that is no number sorts after them by its words.
|
||||||
if q.Class == PublishClassLive {
|
func streamOrder(keys []string) {
|
||||||
return 0
|
sort.SliceStable(keys, func(i, j int) bool {
|
||||||
}
|
a, aerr := strconv.ParseUint(keys[i], 10, 64)
|
||||||
return 1
|
b, berr := strconv.ParseUint(keys[j], 10, 64)
|
||||||
}
|
switch {
|
||||||
|
case aerr == nil && berr == nil:
|
||||||
// sortQueued sorts a holder's queued versions in the order they are sent: the live class first, each class oldest first.
|
|
||||||
func sortQueued(qs []QueuedPublish) {
|
|
||||||
sort.SliceStable(qs, func(i, j int) bool {
|
|
||||||
if a, b := qs[i].rank(), qs[j].rank(); a != b {
|
|
||||||
return a < b
|
return a < b
|
||||||
|
case aerr == nil || berr == nil:
|
||||||
|
return aerr == nil
|
||||||
}
|
}
|
||||||
return qs[i].Queued.Before(qs[j].Queued)
|
return keys[i] < keys[j]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +453,7 @@ func (r *Republisher) Republish(ctx context.Context, module, version string) ([]
|
|||||||
type Queued struct {
|
type Queued struct {
|
||||||
Total int `json:"total"`
|
Total int `json:"total"`
|
||||||
Counts []QueueCount `json:"counts"`
|
Counts []QueueCount `json:"counts"`
|
||||||
// Queue are the first queued versions, per holder in the order they are sent (the live class first, each class oldest first);
|
// Queue are the first queued versions, in stream order, the order each holder's one consumer gives them (H-A-483);
|
||||||
// with a module named, only that module's.
|
// with a module named, only that module's.
|
||||||
Queue []QueuedPublish `json:"queue"`
|
Queue []QueuedPublish `json:"queue"`
|
||||||
// Listed says how many of Total the answer lists.
|
// Listed says how many of Total the answer lists.
|
||||||
@@ -512,7 +509,8 @@ func PublishItemKey(module, version string) string {
|
|||||||
|
|
||||||
// PublishQueueOf is the seat mesh-builds' verb publish-queue (design 47 H2 §793; H-A-454): the builder's read of its own work queue
|
// PublishQueueOf is the seat mesh-builds' verb publish-queue (design 47 H2 §793; H-A-454): the builder's read of its own work queue
|
||||||
// publishes (queue, its items read in bulk, capped past its bound), small at any size of the queue (H-A-290 (5)): the items' count
|
// publishes (queue, its items read in bulk, capped past its bound), small at any size of the queue (H-A-290 (5)): the items' count
|
||||||
// per holder and class with the oldest and newest queue time, and the first PublishQueueListCap in the order they are sent; module
|
// per holder and class with the oldest and newest queue time, and the first PublishQueueListCap in stream order, the order the
|
||||||
|
// holder's one consumer gives them (H-A-483, third addendum); module
|
||||||
// (and version) narrow the list to one module's (one version's), so an item's class can be read.
|
// (and version) narrow the list to one module's (one version's), so an item's class can be read.
|
||||||
func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQueueAnswer, error) {
|
func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQueueAnswer, error) {
|
||||||
out := meshbuilds.PublishQueueAnswer{Counts: []meshbuilds.PublishQueueAnswerCountsItem{}, Queue: []meshbuilds.PublishQueueAnswerQueueItem{}}
|
out := meshbuilds.PublishQueueAnswer{Counts: []meshbuilds.PublishQueueAnswerCountsItem{}, Queue: []meshbuilds.PublishQueueAnswerQueueItem{}}
|
||||||
@@ -525,7 +523,13 @@ func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQue
|
|||||||
}
|
}
|
||||||
counts := map[[2]string]*meshbuilds.PublishQueueAnswerCountsItem{}
|
counts := map[[2]string]*meshbuilds.PublishQueueAnswerCountsItem{}
|
||||||
var listed []QueuedPublish
|
var listed []QueuedPublish
|
||||||
for _, raw := range vals {
|
keys := make([]string, 0, len(vals))
|
||||||
|
for k := range vals {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
streamOrder(keys)
|
||||||
|
for _, k := range keys {
|
||||||
|
raw := vals[k]
|
||||||
var q QueuedPublish
|
var q QueuedPublish
|
||||||
if json.Unmarshal(raw, &q) != nil {
|
if json.Unmarshal(raw, &q) != nil {
|
||||||
continue
|
continue
|
||||||
@@ -559,25 +563,12 @@ func PublishQueueOf(queue Reader, module, version string) (meshbuilds.PublishQue
|
|||||||
}
|
}
|
||||||
return out.Counts[i].Class < out.Counts[j].Class
|
return out.Counts[i].Class < out.Counts[j].Class
|
||||||
})
|
})
|
||||||
sort.SliceStable(listed, func(i, j int) bool { return listed[i].Holder < listed[j].Holder })
|
|
||||||
byHolder := map[string][]QueuedPublish{}
|
|
||||||
var holders []string
|
|
||||||
for _, q := range listed {
|
for _, q := range listed {
|
||||||
if byHolder[q.Holder] == nil {
|
if len(out.Queue) == PublishQueueListCap {
|
||||||
holders = append(holders, q.Holder)
|
break
|
||||||
}
|
|
||||||
byHolder[q.Holder] = append(byHolder[q.Holder], q)
|
|
||||||
}
|
|
||||||
for _, h := range holders {
|
|
||||||
qs := byHolder[h]
|
|
||||||
sortQueued(qs)
|
|
||||||
for _, q := range qs {
|
|
||||||
if len(out.Queue) == PublishQueueListCap {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
out.Queue = append(out.Queue, meshbuilds.PublishQueueAnswerQueueItem{Holder: q.Holder, Module: q.Module, Version: q.Version,
|
|
||||||
Class: q.Class, Artifacts: q.Artifacts, Queued: q.Queued})
|
|
||||||
}
|
}
|
||||||
|
out.Queue = append(out.Queue, meshbuilds.PublishQueueAnswerQueueItem{Holder: q.Holder, Module: q.Module, Version: q.Version,
|
||||||
|
Class: q.Class, Artifacts: q.Artifacts, Queued: q.Queued})
|
||||||
}
|
}
|
||||||
out.Listed = int64(len(out.Queue))
|
out.Listed = int64(len(out.Queue))
|
||||||
return out, nil
|
return out, nil
|
||||||
@@ -631,20 +622,17 @@ func AnswerQueue(q meshbuilds.PublishQueueAnswer, acted, reasks Reader) (Queued,
|
|||||||
|
|
||||||
// PublishQueueDescription is builder_publish_queue's description.
|
// PublishQueueDescription is builder_publish_queue's description.
|
||||||
const PublishQueueDescription = "The versions the builder will publish again (its work queue " + PublishesLocal + ", design 47 G section 588, H2 section 793): " +
|
const PublishQueueDescription = "The versions the builder will publish again (its work queue " + PublishesLocal + ", design 47 G section 588, H2 section 793): " +
|
||||||
"how many each registry seat holder's items hold per class (live, a build a pipeline's step waits on, pulled first, or again, asked again at a start) " +
|
"how many each registry seat holder's items hold per class (live, a build a pipeline's step waits on, or again, asked again at a start) " +
|
||||||
"with the oldest and newest queue time; the first 50 in the order they are pulled, each with its class, its artifacts' digests and when it was " +
|
"with the oldest and newest queue time; the first 50 in stream order, the order each holder's one consumer pulls them, each with its class, its artifacts' digests and when it was " +
|
||||||
"queued (module, and version, list only that module's, so one item's class can be read); the keys of the state " + ActedState + ", the last stream " +
|
"queued (module, and version, list only that module's, so one item's class can be read); the keys of the state " + ActedState + ", the last stream " +
|
||||||
"sequence the builder acted on for each subject; and the publish items (design 47 G A-457a), counted, the first 50 by next try, each version's " +
|
"sequence the builder acted on for each subject; and the publish items (design 47 G A-457a), counted, the first 50 by next try, each version's " +
|
||||||
"tries and next try, and why one ended (its tries spent, or dropped). A read past its pages is answered capped, naming the items read and the " +
|
"tries and next try, and why one ended (its tries spent, or dropped). A read past its pages is answered capped, naming the items read and the " +
|
||||||
"queue's size (H-A-293). Read-only."
|
"queue's size (H-A-293). Read-only."
|
||||||
|
|
||||||
// PublishDropDescription and PublishFirstDescription are builder_publish_drop's and builder_publish_first's (§793).
|
// PublishDropDescription is builder_publish_drop's (§793).
|
||||||
const PublishDropDescription = "Drop one version's publish (design 47 H2 section 793): its items on the work queue " + PublishesLocal + " are " +
|
const PublishDropDescription = "Drop one version's publish (design 47 H2 section 793): its items on the work queue " + PublishesLocal + " are " +
|
||||||
"terminated at every holder, and its publish item ended with who dropped it and why, so it is never sent or put again; builder_publish_again " +
|
"terminated at every holder, and its publish item ended with who dropped it and why, so it is never sent or put again; builder_publish_again " +
|
||||||
"asks it anew. A hand act, recorded in the hand-act log first."
|
"asks it anew. A hand act, recorded in the hand-act log first."
|
||||||
const PublishFirstDescription = "Put one version's publish first (design 47 H2 section 793): each of its again items on the work queue " +
|
|
||||||
PublishesLocal + " is put again as live, under the message id <holder>.live.<module>.<version>, pulled before every again item, and the old " +
|
|
||||||
"terminated. A hand act, recorded in the hand-act log first."
|
|
||||||
|
|
||||||
// PublishAgainDescription is builder_publish_again's description.
|
// PublishAgainDescription is builder_publish_again's description.
|
||||||
const PublishAgainDescription = "Publish reserved versions again (design 47 G section 588), which builds nothing: with module and version, that reserved " +
|
const PublishAgainDescription = "Publish reserved versions again (design 47 G section 588), which builds nothing: with module and version, that reserved " +
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"maps"
|
"maps"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -404,8 +405,9 @@ func answerOf(queue, acted, reasks Reader, module, version string) (Queued, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestThePublishQueueToolAnswersAtAnySize: design 47 H H-A-290 (5) — builder_publish_queue over two thousand queued versions answers
|
// TestThePublishQueueToolAnswersAtAnySize: design 47 H H-A-290 (5) — builder_publish_queue over two thousand queued versions answers
|
||||||
// within a second and small: counts per holder and class with the oldest and newest queue time, a list capped at fifty in the
|
// within a second and small: counts per holder and class with the oldest and newest queue time, a list capped at fifty in stream
|
||||||
// order they are sent, and one module's item with its class; each state read in bulk where the reader can.
|
// order (H-A-483, third addendum: each key is its item's stream sequence), and one module's item with its class; each state read
|
||||||
|
// in bulk where the reader can.
|
||||||
func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
||||||
at := time.Date(2026, 11, 20, 17, 0, 0, 0, time.UTC)
|
at := time.Date(2026, 11, 20, 17, 0, 0, 0, time.UTC)
|
||||||
vals := map[string]json.RawMessage{}
|
vals := map[string]json.RawMessage{}
|
||||||
@@ -418,7 +420,7 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
|||||||
class = PublishClassLive
|
class = PublishClassLive
|
||||||
}
|
}
|
||||||
q := QueuedPublish{V: 1, Holder: holder, Module: fmt.Sprintf("m%d", i), Version: "0.1.0", Artifacts: map[string]string{"a": "sha256:aa"}, Queued: at.Add(time.Duration(i) * time.Second), Class: class}
|
q := QueuedPublish{V: 1, Holder: holder, Module: fmt.Sprintf("m%d", i), Version: "0.1.0", Artifacts: map[string]string{"a": "sha256:aa"}, Queued: at.Add(time.Duration(i) * time.Second), Class: class}
|
||||||
vals[QueueKey(holder, q.Module, q.Version)], _ = json.Marshal(q)
|
vals[strconv.Itoa(i+1)], _ = json.Marshal(q) // the reader keys each item by its stream sequence
|
||||||
}
|
}
|
||||||
gets := 0
|
gets := 0
|
||||||
queue := Reader{All: func() (StatePage, error) { return StatePage{Values: vals}, nil },
|
queue := Reader{All: func() (StatePage, error) { return StatePage{Values: vals}, nil },
|
||||||
@@ -435,8 +437,10 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) {
|
|||||||
if fmt.Sprintln(a.Counts[1].Holder, a.Counts[1].Class, a.Counts[1].Count, a.Counts[1].Oldest.Equal(at.Add(1991*time.Second)), a.Counts[1].Newest.Equal(at.Add(1999*time.Second))) != "go "+PublishClassLive+" 5 true true\n" || len(a.Counts) != 4 {
|
if fmt.Sprintln(a.Counts[1].Holder, a.Counts[1].Class, a.Counts[1].Count, a.Counts[1].Oldest.Equal(at.Add(1991*time.Second)), a.Counts[1].Newest.Equal(at.Add(1999*time.Second))) != "go "+PublishClassLive+" 5 true true\n" || len(a.Counts) != 4 {
|
||||||
t.Errorf("counts %+v, want per holder and class with their oldest and newest", a.Counts)
|
t.Errorf("counts %+v, want per holder and class with their oldest and newest", a.Counts)
|
||||||
}
|
}
|
||||||
if a.Queue[0].Class != PublishClassLive || a.Queue[0].Holder != "go" {
|
for i, q := range a.Queue {
|
||||||
t.Errorf("the list opens with %+v, want the go holder's live class, sent first", a.Queue[0])
|
if q.Module != fmt.Sprintf("m%d", i) {
|
||||||
|
t.Fatalf("the list holds %s at %d, want m%d: the items in stream order, whatever their holder or class", q.Module, i, i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
one, err := answerOf(queue, none, none, "m1995", "")
|
one, err := answerOf(queue, none, none, "m1995", "")
|
||||||
if err != nil || len(one.Queue) != 1 || one.Queue[0].Class != PublishClassLive || one.Total != 2000 {
|
if err != nil || len(one.Queue) != 1 || one.Queue[0].Class != PublishClassLive || one.Total != 2000 {
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git"
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
)
|
)
|
||||||
@@ -42,8 +40,8 @@ const (
|
|||||||
// VersionHeldElsewhere is the finding of a number a registry seat already holds, skipped at reserving or moved from (design 47
|
// VersionHeldElsewhere is the finding of a number a registry seat already holds, skipped at reserving or moved from (design 47
|
||||||
// H H-A-275), scope module.
|
// H H-A-275), scope module.
|
||||||
VersionHeldElsewhere = "version-held-elsewhere"
|
VersionHeldElsewhere = "version-held-elsewhere"
|
||||||
// VersionTaggedElsewhere is the finding of a number whose git tag stands at another commit, skipped at reserving (design 47
|
// VersionTaggedElsewhere is the finding of a number whose git tag stood at another commit, which a reserve skipped before no
|
||||||
// H2 §796), scope module; cleared at the module's next version-released.
|
// tag was read (design 47 H2 H-A-494); one raised before is cleared at the module's next version-released.
|
||||||
VersionTaggedElsewhere = "version-tagged-elsewhere"
|
VersionTaggedElsewhere = "version-tagged-elsewhere"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -55,6 +53,10 @@ type ReservedVersion struct {
|
|||||||
Version string `json:"version"` // MAJOR.MINOR.PATCH
|
Version string `json:"version"` // MAJOR.MINOR.PATCH
|
||||||
// Artifacts are the module's artifacts at the version: the digest once built, empty before.
|
// Artifacts are the module's artifacts at the version: the digest once built, empty before.
|
||||||
Artifacts map[string]string `json:"artifacts"`
|
Artifacts map[string]string `json:"artifacts"`
|
||||||
|
// Upstream are the artifacts of kind upstream, by reference (design 47 H2 H-A-486): kept in Artifacts with their digest for the
|
||||||
|
// record, never awaited, as design 51 copies an upstream image by its pinned digest and no registry seat says it published at
|
||||||
|
// a version. A reservation written before carries none.
|
||||||
|
Upstream []string `json:"upstream,omitempty"`
|
||||||
// BuiltAt is when the build ended with every digest known; the publish's bound counts from it.
|
// BuiltAt is when the build ended with every digest known; the publish's bound counts from it.
|
||||||
BuiltAt time.Time `json:"built-at,omitzero"`
|
BuiltAt time.Time `json:"built-at,omitzero"`
|
||||||
// Published are the artifacts a registry seat said published at this version with the built digest.
|
// Published are the artifacts a registry seat said published at this version with the built digest.
|
||||||
@@ -63,8 +65,8 @@ type ReservedVersion struct {
|
|||||||
// was kept.
|
// was kept.
|
||||||
PublishedAt map[string]time.Time `json:"published-at,omitempty"`
|
PublishedAt map[string]time.Time `json:"published-at,omitempty"`
|
||||||
At time.Time `json:"at"`
|
At time.Time `json:"at"`
|
||||||
// Repository and Commit are what the build was made from, and Tag the git tag its release is written as (a Go
|
// Repository and Commit are what the build was made from. Tag is kept for a reservation written before design 47 H2 H-A-494:
|
||||||
// package's, GoTagOf): empty for a module with no Go package (design 47 G §370), or whose Go package's directory is not known.
|
// no git tag is written at a release any more, and a new reservation names none.
|
||||||
Repository string `json:"repository,omitempty"`
|
Repository string `json:"repository,omitempty"`
|
||||||
Commit string `json:"commit,omitempty"`
|
Commit string `json:"commit,omitempty"`
|
||||||
Tag string `json:"tag,omitempty"`
|
Tag string `json:"tag,omitempty"`
|
||||||
@@ -110,22 +112,19 @@ type KeptPublished struct {
|
|||||||
Digest string `json:"digest"`
|
Digest string `json:"digest"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source is what a build reserving a version is made from (design 47 G §370): the repository and commit the git tag is
|
// Source is what a build reserving a version is made from (design 47 G §370): the repository and commit, kept on the reservation.
|
||||||
// written at, and whether the module has a Go package, whose version is tagged.
|
|
||||||
type Source struct {
|
type Source struct {
|
||||||
Repository, Commit string
|
Repository, Commit string
|
||||||
// Fingerprint is the fingerprint of the catalog entry the build is made from (design 47 G A-76).
|
// Fingerprint is the fingerprint of the catalog entry the build is made from (design 47 G A-76).
|
||||||
Fingerprint string
|
Fingerprint string
|
||||||
GoPackage bool
|
|
||||||
// GoArtifact is the artifact that is the module's Go package, whose module path names the directory its tag is written in
|
|
||||||
// (design 47 H2 §796).
|
|
||||||
GoArtifact string
|
|
||||||
// Branch is the watched branch of the catalog revision whose entry the build came from, and Revision the source revision of
|
// Branch is the watched branch of the catalog revision whose entry the build came from, and Revision the source revision of
|
||||||
// that catalog revision (design 47 G §371, A-57), kept on the reservation for the publication.
|
// that catalog revision (design 47 G §371, A-57), kept on the reservation for the publication.
|
||||||
Branch string
|
Branch string
|
||||||
Revision int64
|
Revision int64
|
||||||
// CatalogRevision is the catalog revision number the build's step ask named (H-A-218), 0 when none did.
|
// CatalogRevision is the catalog revision number the build's step ask named (H-A-218), 0 when none did.
|
||||||
CatalogRevision int64
|
CatalogRevision int64
|
||||||
|
// Upstream are the artifacts of kind upstream among those reserved, by reference (H-A-486), kept on the reservation.
|
||||||
|
Upstream []string
|
||||||
// Rebuild marks a build again of a done key whose version is not released: the standing reservation of Fingerprint is replaced
|
// Rebuild marks a build again of a done key whose version is not released: the standing reservation of Fingerprint is replaced
|
||||||
// and is no floor, so the number is the next above the catalog's highest alone (design 47 G A-490b).
|
// and is no floor, so the number is the next above the catalog's highest alone (design 47 G A-490b).
|
||||||
Rebuild bool
|
Rebuild bool
|
||||||
@@ -171,92 +170,6 @@ type Reserver struct {
|
|||||||
HeldNumbers func(ctx context.Context, module, fingerprint string, refs []string) ([]string, error)
|
HeldNumbers func(ctx context.Context, module, fingerprint string, refs []string) ([]string, error)
|
||||||
// HeldElsewhere is told the numbers of module a reserve skipped because a registry holds them (H-A-275); nil is told none.
|
// HeldElsewhere is told the numbers of module a reserve skipped because a registry holds them (H-A-275); nil is told none.
|
||||||
HeldElsewhere func(ctx context.Context, module string, skipped []string)
|
HeldElsewhere func(ctx context.Context, module string, skipped []string)
|
||||||
// Names answers a Go package's module path, which names the directory its tag is written in (design 47 H2 §796); nil, or a
|
|
||||||
// name not known, tags the version nowhere, said.
|
|
||||||
Names PackageNames
|
|
||||||
// Tags reads repository's tags starting with prefix, each with the commit it names, through the seat git's tags (design 47
|
|
||||||
// H2 §796); away says the read met a transport fault or the error kind away, which lets the reservation go on, said. Nil
|
|
||||||
// reads none.
|
|
||||||
Tags func(ctx context.Context, repository, prefix string) (tags []git.Tag, away bool, err error)
|
|
||||||
// TaggedElsewhere is told the numbers of module a reserve skipped because their tag stands at another commit (§796); nil
|
|
||||||
// is told none.
|
|
||||||
TaggedElsewhere func(ctx context.Context, module string, skipped []string)
|
|
||||||
|
|
||||||
tagsMu sync.Mutex
|
|
||||||
// tagsRead are the tags last read of each module, by series patch to the commit, with the catalog revision they were read
|
|
||||||
// under: a module's tags are read once per catalog revision it reserves under (§796).
|
|
||||||
tagsRead map[string]tagsAt
|
|
||||||
}
|
|
||||||
|
|
||||||
// tagsAt are a module's tags of one series read under one catalog revision: patch to the commit its tag names.
|
|
||||||
type tagsAt struct {
|
|
||||||
revision, prefix string
|
|
||||||
commits map[int]string
|
|
||||||
}
|
|
||||||
|
|
||||||
// goDirectory is the directory of module's Go package in its repository (§796), from its module path; ok is false, said, when
|
|
||||||
// no name or no directory of the repository is known.
|
|
||||||
func (r *Reserver) goDirectory(ctx context.Context, module string, src Source) (string, bool) {
|
|
||||||
if r.Names == nil {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
path, known, err := r.Names(ctx, module, src.GoArtifact)
|
|
||||||
switch {
|
|
||||||
case err != nil:
|
|
||||||
r.said(fmt.Errorf("%s: its Go package's name cannot be read, so its version is tagged nowhere: %w", module, err))
|
|
||||||
return "", false
|
|
||||||
case !known:
|
|
||||||
r.said(fmt.Errorf("%s: no name of its Go package %s is known yet, so its version is tagged nowhere", module, src.GoArtifact))
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
dir, ok := GoDirectory(path, src.Repository)
|
|
||||||
if !ok {
|
|
||||||
r.said(fmt.Errorf("%s: its Go package %s is not a module path of the repository %s, so its version is tagged nowhere", module, path, src.Repository))
|
|
||||||
}
|
|
||||||
return dir, ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// taggedAt are the patches of series whose tag `<directory>/v<series>.<patch>` stands, each with its commit, read once per
|
|
||||||
// catalog revision the module reserves under (§796). A read that meets a transport fault or away answers none, said, and the
|
|
||||||
// reservation goes on; any other failure refuses the reservation, naming it.
|
|
||||||
func (r *Reserver) taggedAt(ctx context.Context, module, series, dir string, src Source) (map[int]string, error) {
|
|
||||||
if r.Tags == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
prefix := TagPrefix(dir) + series + "."
|
|
||||||
revision := ""
|
|
||||||
if src.CatalogRevision > 0 {
|
|
||||||
revision = fmt.Sprintf("%s.%d", src.Branch, src.CatalogRevision)
|
|
||||||
r.tagsMu.Lock()
|
|
||||||
got, ok := r.tagsRead[module]
|
|
||||||
r.tagsMu.Unlock()
|
|
||||||
if ok && got.revision == revision && got.prefix == prefix {
|
|
||||||
return got.commits, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tags, away, err := r.Tags(ctx, src.Repository, prefix)
|
|
||||||
if err != nil && away {
|
|
||||||
r.said(fmt.Errorf("%s: its tags %s* cannot be read (%w), so the reservation goes on without them", module, prefix, err))
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("the tags %s* of %s cannot be read: %w", prefix, module, err)
|
|
||||||
}
|
|
||||||
commits := map[int]string{}
|
|
||||||
for _, t := range tags {
|
|
||||||
if s, p, err := SplitVersion(strings.TrimPrefix(t.Tag, TagPrefix(dir))); err == nil && s == series && strings.HasPrefix(t.Tag, prefix) {
|
|
||||||
commits[p] = t.Commit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if revision != "" {
|
|
||||||
r.tagsMu.Lock()
|
|
||||||
if r.tagsRead == nil {
|
|
||||||
r.tagsRead = map[string]tagsAt{}
|
|
||||||
}
|
|
||||||
r.tagsRead[module] = tagsAt{revision: revision, prefix: prefix, commits: commits}
|
|
||||||
r.tagsMu.Unlock()
|
|
||||||
}
|
|
||||||
return commits, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// heldNumbers are the patches of series a registry holds of module's artifacts (H-A-275); a read that fails is said, and none.
|
// heldNumbers are the patches of series a registry holds of module's artifacts (H-A-275); a read that fails is said, and none.
|
||||||
@@ -277,19 +190,15 @@ func (r *Reserver) heldNumbers(ctx context.Context, module, series, fingerprint
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
// nextFree is the first patch after after that no registry holds and whose tag stands at no other commit than commit, with the
|
// nextFree is the first patch after after that no registry holds, with the held numbers it skipped (H-A-275). No git tag is
|
||||||
// held numbers it skipped (H-A-275) and those tagged elsewhere (design 47 H2 §796).
|
// read: a series is numbered from the catalog's versions and the registries' alone (design 47 H2 H-A-494).
|
||||||
func nextFree(series string, after int, held map[int]bool, tagged map[int]string, commit string) (int, []string, []string) {
|
func nextFree(series string, after int, held map[int]bool) (int, []string) {
|
||||||
var skipped, elsewhere []string
|
var skipped []string
|
||||||
for p := after + 1; ; p++ {
|
for p := after + 1; ; p++ {
|
||||||
switch c, ok := tagged[p]; {
|
if !held[p] {
|
||||||
case held[p]:
|
return p, skipped
|
||||||
skipped = append(skipped, fmt.Sprintf("%s.%d", series, p))
|
|
||||||
case ok && c != commit:
|
|
||||||
elsewhere = append(elsewhere, fmt.Sprintf("%s.%d (tagged at %s)", series, p, c))
|
|
||||||
default:
|
|
||||||
return p, skipped, elsewhere
|
|
||||||
}
|
}
|
||||||
|
skipped = append(skipped, fmt.Sprintf("%s.%d", series, p))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,15 +251,6 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts
|
|||||||
}
|
}
|
||||||
key := ReservedKey(module, series)
|
key := ReservedKey(module, series)
|
||||||
held := r.heldNumbers(ctx, module, series, src.Fingerprint, artifacts)
|
held := r.heldNumbers(ctx, module, series, src.Fingerprint, artifacts)
|
||||||
dir, tagged := "", false
|
|
||||||
var tags map[int]string
|
|
||||||
if src.GoPackage {
|
|
||||||
if dir, tagged = r.goDirectory(ctx, module, src); tagged {
|
|
||||||
if tags, err = r.taggedAt(ctx, module, series, dir, src); err != nil {
|
|
||||||
return ReservedVersion{}, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
cur, rev, found, err := r.get(ctx, key)
|
cur, rev, found, err := r.get(ctx, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -368,15 +268,13 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts
|
|||||||
next = p
|
next = p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
patch, skipped, elsewhere := nextFree(series, next, held, tags, src.Commit)
|
patch, skipped := nextFree(series, next, held)
|
||||||
out := ReservedVersion{V: 1, Module: module, Series: series, Version: fmt.Sprintf("%s.%d", series, patch), Artifacts: map[string]string{}, At: r.now(),
|
out := ReservedVersion{V: 1, Module: module, Series: series, Version: fmt.Sprintf("%s.%d", series, patch), Artifacts: map[string]string{}, At: r.now(),
|
||||||
Repository: src.Repository, Commit: src.Commit, Fingerprint: src.Fingerprint, Branch: src.Branch, Source: src.Revision, Revision: src.CatalogRevision}
|
Repository: src.Repository, Commit: src.Commit, Fingerprint: src.Fingerprint, Branch: src.Branch, Source: src.Revision, Revision: src.CatalogRevision}
|
||||||
if tagged {
|
|
||||||
out.Tag = GoTagOf(dir, out.Version)
|
|
||||||
}
|
|
||||||
for _, a := range artifacts {
|
for _, a := range artifacts {
|
||||||
out.Artifacts[a] = ""
|
out.Artifacts[a] = ""
|
||||||
}
|
}
|
||||||
|
out.Upstream = slices.Clone(src.Upstream)
|
||||||
if found {
|
if found {
|
||||||
out.Withdrawn = maps.Clone(cur.Withdrawn)
|
out.Withdrawn = maps.Clone(cur.Withdrawn)
|
||||||
if cur.Fingerprint != src.Fingerprint {
|
if cur.Fingerprint != src.Fingerprint {
|
||||||
@@ -410,9 +308,6 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts
|
|||||||
if len(skipped) > 0 && r.HeldElsewhere != nil {
|
if len(skipped) > 0 && r.HeldElsewhere != nil {
|
||||||
r.HeldElsewhere(ctx, module, skipped)
|
r.HeldElsewhere(ctx, module, skipped)
|
||||||
}
|
}
|
||||||
if len(elsewhere) > 0 && r.TaggedElsewhere != nil {
|
|
||||||
r.TaggedElsewhere(ctx, module, elsewhere)
|
|
||||||
}
|
|
||||||
if found && r.Took != nil {
|
if found && r.Took != nil {
|
||||||
r.Took(ctx, cur, out)
|
r.Took(ctx, cur, out)
|
||||||
}
|
}
|
||||||
@@ -529,6 +424,9 @@ type ReleasedBuild struct {
|
|||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
// Digests are the published digest of each artifact, by reference (H-A-331); absent for a release kept before.
|
// Digests are the published digest of each artifact, by reference (H-A-331); absent for a release kept before.
|
||||||
Digests map[string]string `json:"digests,omitempty"`
|
Digests map[string]string `json:"digests,omitempty"`
|
||||||
|
// Withdrawn are the fingerprints whose numbers the released version took over, by the number withdrawn (H-A-226), so a
|
||||||
|
// takeover still answers once the release deleted the series key (H-A-508); absent for a release that took none over.
|
||||||
|
Withdrawn map[string]string `json:"withdrawn,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleasedFor says whether the builder saw a version released for the build of fingerprint among the module's last releases.
|
// ReleasedFor says whether the builder saw a version released for the build of fingerprint among the module's last releases.
|
||||||
@@ -599,7 +497,7 @@ func (r *Reserver) PublishedOf(ctx context.Context, module, artifact, fingerprin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// keepRelease adds a release to the module's record, dropping the oldest past ReleasedKept.
|
// keepRelease adds a release to the module's record, dropping the oldest past ReleasedKept.
|
||||||
func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string, digests map[string]string) error {
|
func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string, digests, withdrawn map[string]string) error {
|
||||||
n := r.ReleasedKept
|
n := r.ReleasedKept
|
||||||
if n < 1 {
|
if n < 1 {
|
||||||
n = DefaultReleasedKept
|
n = DefaultReleasedKept
|
||||||
@@ -619,7 +517,7 @@ func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version
|
|||||||
kept = append(kept, k)
|
kept = append(kept, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kept = append(kept, ReleasedBuild{Fingerprint: fingerprint, Version: version, Digests: digests})
|
kept = append(kept, ReleasedBuild{Fingerprint: fingerprint, Version: version, Digests: digests, Withdrawn: maps.Clone(withdrawn)})
|
||||||
if len(kept) > n {
|
if len(kept) > n {
|
||||||
kept = kept[len(kept)-n:]
|
kept = kept[len(kept)-n:]
|
||||||
}
|
}
|
||||||
@@ -658,7 +556,7 @@ func (r *Reserver) Released(ctx context.Context, module, version string) ([]stri
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cur.Version == version && cur.Fingerprint != "" && r.Releases != nil {
|
if cur.Version == version && cur.Fingerprint != "" && r.Releases != nil {
|
||||||
if err := r.keepRelease(ctx, module, cur.Fingerprint, version, cur.Artifacts); err != nil {
|
if err := r.keepRelease(ctx, module, cur.Fingerprint, version, cur.Artifacts, cur.Withdrawn); err != nil {
|
||||||
return gone, fmt.Errorf("the release of %s %s cannot be recorded: %w", module, version, err)
|
return gone, fmt.Errorf("the release of %s %s cannot be recorded: %w", module, version, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -730,7 +628,9 @@ func (r *Reserver) All(ctx context.Context) ([]ReservedVersion, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TakenOver is the reservation of module's series whose withdrawn numbers hold one of the build of fingerprint (design 47 H
|
// TakenOver is the reservation of module's series whose withdrawn numbers hold one of the build of fingerprint (design 47 H
|
||||||
// H-A-226), and whether there is one: the series moved to that reservation's fingerprint and version (H-A-244).
|
// H-A-226), and whether there is one: the series moved to that reservation's fingerprint and version (H-A-244). Once that
|
||||||
|
// version is released and its series key deleted, the release record answers it, naming the fingerprints it withdrew
|
||||||
|
// (H-A-508): the newest such release, as a reservation of its fingerprint and version.
|
||||||
func (r *Reserver) TakenOver(ctx context.Context, module, fingerprint string) (ReservedVersion, bool, error) {
|
func (r *Reserver) TakenOver(ctx context.Context, module, fingerprint string) (ReservedVersion, bool, error) {
|
||||||
all, err := r.All(ctx)
|
all, err := r.All(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -746,6 +646,30 @@ func (r *Reserver) TakenOver(ctx context.Context, module, fingerprint string) (R
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if r.Releases == nil {
|
||||||
|
return ReservedVersion{}, false, nil
|
||||||
|
}
|
||||||
|
raw, _, found, err := r.Releases.Get(ctx, ReleasedKey(module))
|
||||||
|
if err != nil || !found {
|
||||||
|
return ReservedVersion{}, false, err
|
||||||
|
}
|
||||||
|
var rec ReleasedRecord
|
||||||
|
if err := json.Unmarshal(raw, &rec); err != nil {
|
||||||
|
// A record that cannot be read answers no "not taken over": the caller says it cannot judge (H-A-508).
|
||||||
|
return ReservedVersion{}, false, fmt.Errorf("the release record of %s cannot be read: %w", module, err)
|
||||||
|
}
|
||||||
|
for i := len(rec.Kept) - 1; i >= 0; i-- {
|
||||||
|
k := rec.Kept[i]
|
||||||
|
if k.Fingerprint == fingerprint {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, fp := range k.Withdrawn {
|
||||||
|
if fp == fingerprint {
|
||||||
|
series, _, _ := SplitVersion(k.Version)
|
||||||
|
return ReservedVersion{V: 1, Module: module, Series: series, Version: k.Version, Fingerprint: k.Fingerprint}, true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return ReservedVersion{}, false, nil
|
return ReservedVersion{}, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1134,11 +1058,11 @@ const (
|
|||||||
ReservedVerb = meshbuilds.VerbReserved
|
ReservedVerb = meshbuilds.VerbReserved
|
||||||
)
|
)
|
||||||
|
|
||||||
// Missing are the artifacts of v no registry seat said published, sorted.
|
// Missing are the artifacts of v no registry seat said published, sorted; an upstream one is never awaited (H-A-486).
|
||||||
func (v ReservedVersion) Missing() []string {
|
func (v ReservedVersion) Missing() []string {
|
||||||
var out []string
|
var out []string
|
||||||
for a := range v.Artifacts {
|
for a := range v.Artifacts {
|
||||||
if !v.Published[a] {
|
if !v.Published[a] && !slices.Contains(v.Upstream, a) {
|
||||||
out = append(out, a)
|
out = append(out, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/git"
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -171,6 +169,23 @@ func TestReservationIsReadAndMarkedPublished(t *testing.T) {
|
|||||||
if got := cur.Missing(); !reflect.DeepEqual(got, []string{"m:b"}) {
|
if got := cur.Missing(); !reflect.DeepEqual(got, []string{"m:b"}) {
|
||||||
t.Errorf("missing = %v, want m:b", got)
|
t.Errorf("missing = %v, want m:b", got)
|
||||||
}
|
}
|
||||||
|
// H-A-486: an upstream artifact is reserved and recorded with its digest, but never awaited: once the others are published
|
||||||
|
// nothing is missing.
|
||||||
|
up, err := r.Reserve(ctx, "u", "0.1", []string{"u:server", "u:tools"}, Source{Upstream: []string{"u:server"}})
|
||||||
|
if err != nil || !reflect.DeepEqual(up.Upstream, []string{"u:server"}) {
|
||||||
|
t.Fatalf("reserved %+v (%v), want u:server kept as upstream", up, err)
|
||||||
|
}
|
||||||
|
for _, a := range []string{"u:server", "u:tools"} {
|
||||||
|
if _, err := r.Built(ctx, "u", up.Version, a, "sha256:"+a, nil); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if marked, _, err := r.Published(ctx, "u-tools", up.Version, "sha256:u:tools"); err != nil || len(marked) != 1 {
|
||||||
|
t.Fatalf("the published of u:tools marked %v (%v)", marked, err)
|
||||||
|
}
|
||||||
|
if cur, _, _ := r.At(ctx, ReservedKey("u", "0.1")); len(cur.Missing()) != 0 || cur.Artifacts["u:server"] != "sha256:u:server" {
|
||||||
|
t.Errorf("missing = %v with artifacts %v, want none missing and the upstream digest kept", cur.Missing(), cur.Artifacts)
|
||||||
|
}
|
||||||
if key, ok := ReservedBoundOf(ReservedBoundKey("m", "1.4")); !ok || key != ReservedKey("m", "1.4") || ReservedBoundFor(key) != ReservedBoundKey("m", "1.4") {
|
if key, ok := ReservedBoundOf(ReservedBoundKey("m", "1.4")); !ok || key != ReservedKey("m", "1.4") || ReservedBoundFor(key) != ReservedBoundKey("m", "1.4") {
|
||||||
t.Errorf("the bound key does not name the reservation back: %q %v", key, ok)
|
t.Errorf("the bound key does not name the reservation back: %q %v", key, ok)
|
||||||
}
|
}
|
||||||
@@ -311,7 +326,7 @@ func TestTheWithdrawnVersionsAreDroppedOnceReleasedPast(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
store := &reserveMem{mem: newMem()}
|
store := &reserveMem{mem: newMem()}
|
||||||
highest := "0.1.3"
|
highest := "0.1.3"
|
||||||
r := &Reserver{Store: store, Filled: func() bool { return true },
|
r := &Reserver{Store: store, Releases: &reserveMem{mem: newMem()}, Filled: func() bool { return true },
|
||||||
ReleasedOf: func(context.Context, string) ([]string, error) { return []string{highest}, nil }}
|
ReleasedOf: func(context.Context, string) ([]string, error) { return []string{highest}, nil }}
|
||||||
for _, fp := range []string{"src2:a", "src2:b", "src2:c"} {
|
for _, fp := range []string{"src2:a", "src2:b", "src2:c"} {
|
||||||
if _, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp}); err != nil {
|
if _, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp}); err != nil {
|
||||||
@@ -334,6 +349,27 @@ func TestTheWithdrawnVersionsAreDroppedOnceReleasedPast(t *testing.T) {
|
|||||||
if err != nil || got.Version != "0.1.7" || len(got.Withdrawn) != 1 || got.Withdrawn["0.1.6"] != "src2:c" {
|
if err != nil || got.Version != "0.1.7" || len(got.Withdrawn) != 1 || got.Withdrawn["0.1.6"] != "src2:c" {
|
||||||
t.Errorf("reserved %+v (%v); want 0.1.7 keeping only 0.1.6 withdrawn", got, err)
|
t.Errorf("reserved %+v (%v); want 0.1.7 keeping only 0.1.6 withdrawn", got, err)
|
||||||
}
|
}
|
||||||
|
// H-A-508: the release of the version that took over deletes the series key; the release record still names the
|
||||||
|
// fingerprint it withdrew, so the stale build finds the series moved, never "no version is reserved".
|
||||||
|
if _, err := r.Released(ctx, "m", "0.1.7"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, _, found, _ := r.get(ctx, ReservedKey("m", "0.1")); found {
|
||||||
|
t.Fatal("the released series key stands")
|
||||||
|
}
|
||||||
|
if by, took, err := r.TakenOver(ctx, "m", "src2:c"); err != nil || !took || by.Fingerprint != "src2:d" || by.Version != "0.1.7" {
|
||||||
|
t.Errorf("after the release taken over from src2:c by %+v (%v, %v); want src2:d 0.1.7", by, took, err)
|
||||||
|
}
|
||||||
|
if _, took, err := r.TakenOver(ctx, "m", "src2:d"); err != nil || took {
|
||||||
|
t.Errorf("the released build src2:d is said taken over (%v, %v)", took, err)
|
||||||
|
}
|
||||||
|
// A release record that cannot be read answers its error, never "not taken over".
|
||||||
|
if _, err := r.Releases.Create(ctx, ReleasedKey("n"), []byte("{not json")); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, took, err := r.TakenOver(ctx, "n", "src2:x"); err == nil || took {
|
||||||
|
t.Errorf("an unreadable release record answered taken over %v, %v; want its error", took, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b as H-A-225 amends it — a build again
|
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b as H-A-225 amends it — a build again
|
||||||
@@ -399,7 +435,7 @@ func TestANumberARegistryHoldsIsNeverReserved(t *testing.T) {
|
|||||||
return held, readErr
|
return held, readErr
|
||||||
},
|
},
|
||||||
HeldElsewhere: func(_ context.Context, _ string, s []string) { skipped = append(skipped, s...) }}
|
HeldElsewhere: func(_ context.Context, _ string, s []string) { skipped = append(skipped, s...) }}
|
||||||
v, err := r.Reserve(ctx, "node-tools", "0.1", []string{"node-tools:program"}, Source{Fingerprint: "fp1", GoPackage: true})
|
v, err := r.Reserve(ctx, "node-tools", "0.1", []string{"node-tools:program"}, Source{Fingerprint: "fp1", Repository: "o/r", Commit: "c1"})
|
||||||
if err != nil || v.Version != "0.1.39" || len(skipped) != 2 {
|
if err != nil || v.Version != "0.1.39" || len(skipped) != 2 {
|
||||||
t.Fatalf("reserved %q (%v), skipped %v: want 0.1.39 past the two numbers the registry holds", v.Version, err, skipped)
|
t.Fatalf("reserved %q (%v), skipped %v: want 0.1.39 past the two numbers the registry holds", v.Version, err, skipped)
|
||||||
}
|
}
|
||||||
@@ -413,9 +449,9 @@ func TestANumberARegistryHoldsIsNeverReserved(t *testing.T) {
|
|||||||
}
|
}
|
||||||
held = []string{"0.1.37", "0.1.38", "0.1.39", "0.1.40", "0.2.0"}
|
held = []string{"0.1.37", "0.1.38", "0.1.39", "0.1.40", "0.2.0"}
|
||||||
// The build again of a done key reserves as a rebuild (A-490b): a withdrawn number is never its floor's to reuse.
|
// The build again of a done key reserves as a rebuild (A-490b): a withdrawn number is never its floor's to reuse.
|
||||||
again, err := r.Reserve(ctx, "node-tools", "0.1", []string{"node-tools:program"}, Source{Fingerprint: "fp1", GoPackage: true, Rebuild: true})
|
again, err := r.Reserve(ctx, "node-tools", "0.1", []string{"node-tools:program"}, Source{Fingerprint: "fp1", Repository: "o/r", Commit: "c1", Rebuild: true})
|
||||||
if err != nil || again.Version != "0.1.41" || again.Artifacts["node-tools:program"] != "" || again.Withdrawn["0.1.39"] != "fp1" || again.Tag != "" {
|
if err != nil || again.Version != "0.1.41" || again.Artifacts["node-tools:program"] != "" || again.Withdrawn["0.1.39"] != "fp1" || again.Tag != "" {
|
||||||
t.Fatalf("the build again reserved %+v (%v), want 0.1.41 with no digest, 0.1.39 kept withdrawn, and no tag (no Go package name known)", again, err)
|
t.Fatalf("the build again reserved %+v (%v), want 0.1.41 with no digest, 0.1.39 kept withdrawn, and no tag (design 47 H2 H-A-494)", again, err)
|
||||||
}
|
}
|
||||||
if at, _ := r.AtVersion(ctx, "0.1.39"); len(at) != 0 {
|
if at, _ := r.AtVersion(ctx, "0.1.39"); len(at) != 0 {
|
||||||
t.Errorf("the index by version still names the withdrawn number: %v", at)
|
t.Errorf("the index by version still names the withdrawn number: %v", at)
|
||||||
@@ -428,50 +464,4 @@ func TestANumberARegistryHoldsIsNeverReserved(t *testing.T) {
|
|||||||
if v, err := r.Reserve(ctx, "node-tools", "0.2", []string{"node-tools:program"}, Source{Fingerprint: "fp1"}); err != nil || v.Version != "0.2.1" {
|
if v, err := r.Reserve(ctx, "node-tools", "0.2", []string{"node-tools:program"}, Source{Fingerprint: "fp1"}); err != nil || v.Version != "0.2.1" {
|
||||||
t.Errorf("with the registry down reserved %q (%v), want 0.2.1 (what it answered still skipped)", v.Version, err)
|
t.Errorf("with the registry down reserved %q (%v), want 0.2.1 (what it answered still skipped)", v.Version, err)
|
||||||
}
|
}
|
||||||
// Design 47 H2 §796: a Go package's tags are read before it reserves, once per catalog revision; a number whose tag
|
|
||||||
// `<directory>/v<version>` stands at another commit is skipped and said, one at the build's own commit is not; the version's
|
|
||||||
// tag names the Go module's directory; a read met away lets the reservation go on, any other failure refuses it.
|
|
||||||
r.HeldNumbers = nil
|
|
||||||
var tagReads int
|
|
||||||
var tagsErr error
|
|
||||||
var tagsAway bool
|
|
||||||
var elsewhere []string
|
|
||||||
tags := []git.Tag{{Tag: "modules/nt/v0.3.0", Commit: "c-other"}, {Tag: "modules/nt/v0.3.1", Commit: "c-mine"}, {Tag: "modules/nt/v0.3.2", Commit: "c-other2"}}
|
|
||||||
r.Names = func(_ context.Context, module, artifact string) (string, bool, error) {
|
|
||||||
return "git.example/o/r/modules/nt", module == "node-tools" && artifact == "lib", nil
|
|
||||||
}
|
|
||||||
r.Tags = func(_ context.Context, repository, prefix string) ([]git.Tag, bool, error) {
|
|
||||||
tagReads++
|
|
||||||
if repository != "o/r" || prefix != "modules/nt/v0.3." {
|
|
||||||
t.Errorf("tags read of %s %q, want o/r modules/nt/v0.3.", repository, prefix)
|
|
||||||
}
|
|
||||||
return tags, tagsAway, tagsErr
|
|
||||||
}
|
|
||||||
r.TaggedElsewhere = func(_ context.Context, _ string, s []string) { elsewhere = append(elsewhere, s...) }
|
|
||||||
at := Source{Fingerprint: "fp3", GoPackage: true, GoArtifact: "lib", Repository: "o/r", Commit: "c-mine", Branch: "main", CatalogRevision: 7}
|
|
||||||
v3, err := r.Reserve(ctx, "node-tools", "0.3", []string{"node-tools:lib"}, at)
|
|
||||||
if err != nil || v3.Version != "0.3.1" || v3.Tag != "modules/nt/v0.3.1" || len(elsewhere) != 1 || !strings.Contains(elsewhere[0], "0.3.0") {
|
|
||||||
t.Fatalf("reserved %+v (%v), tagged elsewhere %v: want 0.3.1 (0.3.0 tagged at another commit, 0.3.1 at the build's own), tag modules/nt/v0.3.1", v3, err, elsewhere)
|
|
||||||
}
|
|
||||||
at.Fingerprint, at.Commit, elsewhere = "fp4", "c-new", nil
|
|
||||||
if v4, err := r.Reserve(ctx, "node-tools", "0.3", []string{"node-tools:lib"}, at); err != nil || v4.Version != "0.3.3" || tagReads != 1 || len(elsewhere) != 1 || !strings.Contains(elsewhere[0], "0.3.2") {
|
|
||||||
t.Fatalf("reserved %+v (%v) after %d reads, tagged elsewhere %v: want 0.3.3 past 0.3.2's tag, the tags read once for revision main.7", v4, err, tagReads, elsewhere)
|
|
||||||
}
|
|
||||||
at.CatalogRevision, at.Fingerprint, tagsErr, tagsAway = 8, "fp5", errors.New("the forge is away"), true
|
|
||||||
if v5, err := r.Reserve(ctx, "node-tools", "0.3", []string{"node-tools:lib"}, at); err != nil || v5.Version != "0.3.4" || tagReads != 2 {
|
|
||||||
t.Fatalf("with the tags away reserved %+v (%v) after %d reads, want 0.3.4 and the reservation going on", v5, err, tagReads)
|
|
||||||
}
|
|
||||||
at.CatalogRevision, at.Fingerprint, tagsAway = 9, "fp6", false
|
|
||||||
if _, err := r.Reserve(ctx, "node-tools", "0.3", []string{"node-tools:lib"}, at); err == nil || !strings.Contains(err.Error(), "tags") {
|
|
||||||
t.Errorf("a tags read refused not away reserved anyway (%v), want the reservation refused naming the tags", err)
|
|
||||||
}
|
|
||||||
if d, ok := GoDirectory("git.example/novox/mesh-sdk/go", "https://git.example/novox/mesh-sdk.git"); !ok || d != "go" || GoTagOf(d, "0.1.9") != "go/v0.1.9" {
|
|
||||||
t.Errorf("mesh-sdk's Go package: directory %q (%v), want go and the tag go/v0.1.9", d, ok)
|
|
||||||
}
|
|
||||||
if d, ok := GoDirectory("git.example/o/r", "o/r"); !ok || d != "" || GoTagOf(d, "1.0.0") != "v1.0.0" {
|
|
||||||
t.Errorf("a root Go module: directory %q (%v), want the root and the tag v1.0.0", d, ok)
|
|
||||||
}
|
|
||||||
if _, ok := GoDirectory("git.example/o/rr/x", "o/r"); ok {
|
|
||||||
t.Error("a module path of another repository was given a directory")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
package versions
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GoTagOf is the git tag a Go package's released version is written as (design 47 H2 §796): `<directory>/v<version>`, the
|
|
||||||
// directory of its Go module in the repository, which the Go toolchain's direct fallback reads; `v<version>` at the root. The
|
|
||||||
// `go/v<version>` tags go from new versions.
|
|
||||||
func GoTagOf(directory, version string) string { return TagPrefix(directory) + version }
|
|
||||||
|
|
||||||
// GoDirectory is the directory of the Go module path modulePath in repository (`<owner>/<name>`, or a clone address naming
|
|
||||||
// it): the part of the path after the repository's own, as the Go toolchain reads a module kept in a subdirectory; empty at
|
|
||||||
// the root. ok is false when the path is not one of that repository.
|
|
||||||
func GoDirectory(modulePath, repository string) (string, bool) {
|
|
||||||
repo := "/" + strings.ToLower(trunk.RepositoryName(repository))
|
|
||||||
lower := strings.ToLower(modulePath)
|
|
||||||
for from := 0; ; {
|
|
||||||
i := strings.Index(lower[from:], repo)
|
|
||||||
if i < 0 || repo == "/" {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
end := from + i + len(repo)
|
|
||||||
if end == len(lower) || lower[end] == '/' {
|
|
||||||
return strings.Trim(modulePath[end:], "/"), true
|
|
||||||
}
|
|
||||||
from = end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -152,7 +152,7 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
|||||||
// Design 51 *The floor*: the floor's three sources, the registry seats' versions, git.tags and indexer_requirements.
|
// Design 51 *The floor*: the floor's three sources, the registry seats' versions, git.tags and indexer_requirements.
|
||||||
// The watchdogs seat's presence says a node's machine is heard (issue 1966, ADR 0596 §2, ADR 0668 §3).
|
// The watchdogs seat's presence says a node's machine is heard (issue 1966, ADR 0596 §2, ADR 0668 §3).
|
||||||
if want := []string{"seat:mesh-catalog.entry", "seat:mesh-catalog.registrations", "seat:mesh-catalog.seat-definitions", "seat:mesh-catalog.revision", "seat:mesh-delivery.source", "seat:container-image-registry.publish", "seat:container-image-registry.remove", "seat:container-image-registry.versions",
|
if want := []string{"seat:mesh-catalog.entry", "seat:mesh-catalog.registrations", "seat:mesh-catalog.seat-definitions", "seat:mesh-catalog.revision", "seat:mesh-delivery.source", "seat:container-image-registry.publish", "seat:container-image-registry.remove", "seat:container-image-registry.versions",
|
||||||
"seat:git.tag", "seat:git.tags",
|
"seat:git.tags", // the floor's source alone: no tag is written at a release (design 47 H2 H-A-494)
|
||||||
"seat:go-package-registry.publish", "seat:go-package-registry.remove", "seat:go-package-registry.versions", "seat:mesh-artifact-sweep.held", "seat:mesh-builds.reserved", "seat:mesh-builds.drop", "seat:mesh-builds.publish-queue", "seat:mesh-catalog.versions", "seat:mesh-hand-acts.hand-act", "seat:mesh-module-assigner.assignments", "seat:mesh-watchdogs.presence", "seat:node-build-go.drop", "seat:node-build-image.drop", "seat:node-build-node.drop", "seat:node-build-go.answer", "seat:node-build-image.answer", "seat:node-build-node.answer", "seat:node-engine.manifest-reads", "seat:npm-package-registry.publish", "seat:npm-package-registry.remove",
|
"seat:go-package-registry.publish", "seat:go-package-registry.remove", "seat:go-package-registry.versions", "seat:mesh-artifact-sweep.held", "seat:mesh-builds.reserved", "seat:mesh-builds.drop", "seat:mesh-builds.publish-queue", "seat:mesh-catalog.versions", "seat:mesh-hand-acts.hand-act", "seat:mesh-module-assigner.assignments", "seat:mesh-watchdogs.presence", "seat:node-build-go.drop", "seat:node-build-image.drop", "seat:node-build-node.drop", "seat:node-build-go.answer", "seat:node-build-image.answer", "seat:node-build-node.answer", "seat:node-engine.manifest-reads", "seat:npm-package-registry.publish", "seat:npm-package-registry.remove",
|
||||||
"seat:npm-package-registry.versions", "seat:oci-artifact-registry.publish", "seat:oci-artifact-registry.remove", "seat:oci-artifact-registry.versions",
|
"seat:npm-package-registry.versions", "seat:oci-artifact-registry.publish", "seat:oci-artifact-registry.remove", "seat:oci-artifact-registry.versions",
|
||||||
// A-231: the build asks on each build seat's queue delivery (accept.delivery.<asker>).
|
// A-231: the build asks on each build seat's queue delivery (accept.delivery.<asker>).
|
||||||
@@ -199,15 +199,17 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
|||||||
m.Streams[3].Duplicates != 24 || m.Streams[3].MaxDeliveries != 10 || m.Streams[3].MaxAgeDays != 7 || m.Streams[3].MaxMiB != 64 {
|
m.Streams[3].Duplicates != 24 || m.Streams[3].MaxDeliveries != 10 || m.Streams[3].MaxAgeDays != 7 || m.Streams[3].MaxMiB != 64 {
|
||||||
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
|
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
|
||||||
}
|
}
|
||||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 12 ||
|
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 13 ||
|
||||||
// design 47 H2 §775, H-A-381 (2): the kept-call pace and the taken key's bound, read by the process
|
// design 47 H2 §775, H-A-381 (2): the kept-call pace and the taken key's bound, read by the process
|
||||||
m.Config["kept-call-pace-first"].Default != "1s" || m.Config["kept-call-pace-max"].Default != "30s" || m.Config["ask-taken-bound"].Default != "10m" ||
|
m.Config["kept-call-pace-first"].Default != "1s" || m.Config["kept-call-pace-max"].Default != "30s" || m.Config["ask-taken-bound"].Default != "10m" ||
|
||||||
!m.Config["kept-call-pace-first"].Runtime || !m.Config["kept-call-pace-max"].Runtime || !m.Config["ask-taken-bound"].Runtime ||
|
!m.Config["kept-call-pace-first"].Runtime || !m.Config["kept-call-pace-max"].Runtime || !m.Config["ask-taken-bound"].Runtime ||
|
||||||
// H-A-461 (2): the bounds of §794 are settings read at run time, 100 ms and 5 minutes by default
|
// H-A-461 (2): the bounds of §794 are settings read at run time, 100 ms and 5 minutes by default
|
||||||
m.Config["slow-event"].Default != "100ms" || m.Config["events-behind-bound"].Default != "5m" || !m.Config["slow-event"].Runtime || !m.Config["events-behind-bound"].Runtime ||
|
m.Config["slow-event"].Default != "100ms" || m.Config["events-behind-bound"].Default != "5m" || !m.Config["slow-event"].Runtime || !m.Config["events-behind-bound"].Runtime ||
|
||||||
m.Config["revision-wait-minutes"].Default != float64(2) || m.Config["package-wait-minutes"].Default != float64(10) ||
|
m.Config["revision-wait-minutes"].Default != float64(2) || m.Config["package-wait-minutes"].Default != float64(10) ||
|
||||||
|
// H-A-492: the record of a version's digests runs under the builder's own bound, a setting of 60 s by default
|
||||||
|
m.Config["record-bound-seconds"].Default != float64(60) ||
|
||||||
m.Config["publish-pause"].Default != float64(30) || m.Config["publish-pause-max"].Default != float64(30) || m.Config["publish-tries"].Default != float64(5) || m.Config["publish-tries"].Maximum != 10 {
|
m.Config["publish-pause"].Default != float64(30) || m.Config["publish-pause-max"].Default != float64(30) || m.Config["publish-tries"].Default != float64(5) || m.Config["publish-tries"].Maximum != 10 {
|
||||||
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, revision-wait-minutes of 2 (H-A-156), package-wait-minutes of 10 (H-A-165), the publish settings 30 s, 30 min and 5 tries, at most 10 (design 47 G §588, §633, A-457a; H2 H-A-446 (2))", m.Config)
|
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, revision-wait-minutes of 2 (H-A-156), package-wait-minutes of 10 (H-A-165), record-bound-seconds of 60 (H-A-492), the publish settings 30 s, 30 min and 5 tries, at most 10 (design 47 G §588, §633, A-457a; H2 H-A-446 (2))", m.Config)
|
||||||
}
|
}
|
||||||
// Design 47 G §349: version.numbered is no longer said; old-form-closed on the family version, apart from the builds' ends.
|
// Design 47 G §349: version.numbered is no longer said; old-form-closed on the family version, apart from the builds' ends.
|
||||||
if want := []string{"build.asked-again", "version.old-form-closed"}; !reflect.DeepEqual(m.Emits, want) {
|
if want := []string{"build.asked-again", "version.old-form-closed"}; !reflect.DeepEqual(m.Emits, want) {
|
||||||
@@ -266,7 +268,7 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1
|
|||||||
t.Errorf("health = %v, want kind unit alone", p["health"])
|
t.Errorf("health = %v, want kind unit alone", p["health"])
|
||||||
}
|
}
|
||||||
env, _ := p["env"].(map[string]any)
|
env, _ := p["env"].(map[string]any)
|
||||||
if len(env) != 8 || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PACKAGE_WAIT_FILE"] != "${dir:state}/package-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
if len(env) != 9 || env["MESH_BUILDER_RECORD_BOUND_FILE"] != "${dir:state}/record-bound-seconds" || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PACKAGE_WAIT_FILE"] != "${dir:state}/package-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
||||||
t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"])
|
t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"])
|
||||||
}
|
}
|
||||||
for k, v := range env {
|
for k, v := range env {
|
||||||
@@ -274,14 +276,16 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1
|
|||||||
t.Errorf("env %s = %v: a setting reaches the process as a file, never its environment (A-71)", k, v)
|
t.Errorf("env %s = %v: a setting reaches the process as a file, never its environment (A-71)", k, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
found := false
|
for _, setting := range []string{"toolchain-wait-minutes", "record-bound-seconds"} { // H-A-492: the record's bound too
|
||||||
for _, r := range m.Resources {
|
found := false
|
||||||
if r["type"] == "file" && r["path"] == "${dir:state}/toolchain-wait-minutes" && r["content"] == "${config:toolchain-wait-minutes}" {
|
for _, r := range m.Resources {
|
||||||
found = true
|
if r["type"] == "file" && r["path"] == "${dir:state}/"+setting && r["content"] == "${config:"+setting+"}" {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("no file resource with the content ${config:%s}: A-71", setting)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
t.Errorf("no file resource with the content ${config:toolchain-wait-minutes}: A-71")
|
|
||||||
}
|
}
|
||||||
for _, r := range m.Resources {
|
for _, r := range m.Resources {
|
||||||
if r["id"] == "settings" {
|
if r["id"] == "settings" {
|
||||||
|
|||||||
@@ -91,7 +91,6 @@
|
|||||||
"invokes": [
|
"invokes": [
|
||||||
"seat:container-image-registry.remove",
|
"seat:container-image-registry.remove",
|
||||||
"seat:container-image-registry.versions",
|
"seat:container-image-registry.versions",
|
||||||
"seat:git.tag",
|
|
||||||
"seat:git.tags",
|
"seat:git.tags",
|
||||||
"seat:go-package-registry.remove",
|
"seat:go-package-registry.remove",
|
||||||
"seat:go-package-registry.versions",
|
"seat:go-package-registry.versions",
|
||||||
@@ -183,6 +182,14 @@
|
|||||||
"trusted": false,
|
"trusted": false,
|
||||||
"default": 10
|
"default": 10
|
||||||
},
|
},
|
||||||
|
"record-bound-seconds": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "seconds the builder gives the record of a version's digests after its build ends, under its own bound and never the build's (design 47 H2 H-A-492).",
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 3600,
|
||||||
|
"trusted": false,
|
||||||
|
"default": 60
|
||||||
|
},
|
||||||
"ask-taken-bound": {
|
"ask-taken-bound": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "how long the builder keeps the id of an ask it took from the seat mesh-builds' work queue, so a repeat of it is taken once, a Go duration such as 10m (design 47 H2 §775; H-A-381 (2)).",
|
"description": "how long the builder keeps the id of an ask it took from the seat mesh-builds' work queue, so a repeat of it is taken once, a Go duration such as 10m (design 47 H2 §775; H-A-381 (2)).",
|
||||||
@@ -310,6 +317,14 @@
|
|||||||
"mode": "0600",
|
"mode": "0600",
|
||||||
"content": "${config:package-wait-minutes}"
|
"content": "${config:package-wait-minutes}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "record-bound",
|
||||||
|
"type": "file",
|
||||||
|
"path": "${dir:state}/record-bound-seconds",
|
||||||
|
"owner": "mesh-delivery-builder",
|
||||||
|
"mode": "0600",
|
||||||
|
"content": "${config:record-bound-seconds}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "publish-pause",
|
"id": "publish-pause",
|
||||||
"type": "file",
|
"type": "file",
|
||||||
@@ -361,6 +376,7 @@
|
|||||||
"MESH_BUILDER_TOOLCHAIN_WAIT_FILE": "${dir:state}/toolchain-wait-minutes",
|
"MESH_BUILDER_TOOLCHAIN_WAIT_FILE": "${dir:state}/toolchain-wait-minutes",
|
||||||
"MESH_BUILDER_REVISION_WAIT_FILE": "${dir:state}/revision-wait-minutes",
|
"MESH_BUILDER_REVISION_WAIT_FILE": "${dir:state}/revision-wait-minutes",
|
||||||
"MESH_BUILDER_PACKAGE_WAIT_FILE": "${dir:state}/package-wait-minutes",
|
"MESH_BUILDER_PACKAGE_WAIT_FILE": "${dir:state}/package-wait-minutes",
|
||||||
|
"MESH_BUILDER_RECORD_BOUND_FILE": "${dir:state}/record-bound-seconds",
|
||||||
"MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause",
|
"MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause",
|
||||||
"MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max",
|
"MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max",
|
||||||
"MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries",
|
"MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries",
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ const Seat = "mesh-builds"
|
|||||||
|
|
||||||
// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780):
|
// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780):
|
||||||
// a reader of a value of another form says "form N, this reader knows M".
|
// a reader of a value of another form says "form N, this reader knows M".
|
||||||
const Form = 1
|
const Form = 2
|
||||||
|
|
||||||
// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition
|
// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition
|
||||||
// whose fields changed while its forms did not (design 47 H2 §780).
|
// whose fields changed while its forms did not (design 47 H2 §780).
|
||||||
const (
|
const (
|
||||||
generatedForms = "1"
|
generatedForms = "2"
|
||||||
generatedFieldsDigest = "AskTakenEvent=6d5d3da7ac39 BuildEntry=3c829a0a3d58 Dependency=90a32b07c563 DropAnswer=7538f2f5e68e PackagePublished=34dd069a6aab PackagePublishedEvent=8e12888c1559 PublishQueueAnswer=0f1326e35e17 PublishQueueAnswerCountsItem=b770db2f0920 PublishQueueAnswerQueueItem=b1eebc09f41e PublishedAnswer=69a801982819 ReservedAnswer=2272a4d6f0f4 ReservedAnswerArtifactsItem=d74eb6e00abb StepAccept=18efeefb6c34 StepEnded=09a07bfbcb15 StepEndedEvent=207787118dac StepRun=dc5893aef7e5 ToolchainAgreed=f3d9ce993734 ToolchainAgreedDigestsItem=1d42893a96b9 ToolchainAgreedEvent=e3502d6f194d VersionReservedEvent=984547d6ad07"
|
generatedFieldsDigest = "AskTakenEvent=6d5d3da7ac39 BuildEntry=3c829a0a3d58 Dependency=90a32b07c563 DropAnswer=7538f2f5e68e PackagePublished=34dd069a6aab PackagePublishedEvent=8e12888c1559 PublishQueueAnswer=0f1326e35e17 PublishQueueAnswerCountsItem=b770db2f0920 PublishQueueAnswerQueueItem=b1eebc09f41e PublishedAnswer=69a801982819 ReservedAnswer=2272a4d6f0f4 ReservedAnswerArtifactsItem=d74eb6e00abb StepAccept=18efeefb6c34 StepEnded=40a0090f7cb5 StepEndedEvent=207787118dac StepRun=dc5893aef7e5 ToolchainAgreed=f3d9ce993734 ToolchainAgreedDigestsItem=1d42893a96b9 ToolchainAgreedEvent=e3502d6f194d VersionReservedEvent=984547d6ad07"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -57,7 +57,7 @@ func VerbDescription(verb string) string {
|
|||||||
case VerbDrop:
|
case VerbDrop:
|
||||||
return "End an ask on the seat's work queue for a caller that no longer waits for it (its step ended by its bound): one waiting is ended dropped when it is pulled, one taken is cancelled; both end the step could-not-run, its why naming the drop and who asked it, so no holder works on it after (design 47 H2 §778; H-A-401; ADR 0664 §4)."
|
return "End an ask on the seat's work queue for a caller that no longer waits for it (its step ended by its bound): one waiting is ended dropped when it is pulled, one taken is cancelled; both end the step could-not-run, its why naming the drop and who asked it, so no holder works on it after (design 47 H2 §778; H-A-401; ADR 0664 §4)."
|
||||||
case VerbPublishQueue:
|
case VerbPublishQueue:
|
||||||
return "What the builder's work queue publishes holds, read by the builder from its own stream (design 47 H2 §793; H-A-454): the items' count per registry seat holder and class with the oldest and newest queue time, and the first 50 in the order they are pulled (the live class first, each class oldest first); module, and version, list only that module's items. A queue read past 4,000 items is answered capped, naming the items read and the queue's size."
|
return "What the builder's work queue publishes holds, read by the builder from its own stream (design 47 H2 §793; H-A-454): the items' count per registry seat holder and class with the oldest and newest queue time, and the first 50 in stream order, the order each holder's one consumer pulls them (H-A-483); module, and version, list only that module's items. A queue read past 4,000 items is answered capped, naming the items read and the queue's size."
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@@ -163,13 +163,13 @@ type StepEnded struct {
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
// the node the builder ran it on, as in the subject
|
// the node the builder ran it on, as in the subject
|
||||||
Node string `json:"node"`
|
Node string `json:"node"`
|
||||||
// never passed for a build that built nothing
|
// never passed for a build that built nothing; superseded for an entry whose fingerprint a newer entry of its branch superseded, built or not (design 47 H2 H-A-508): the mover moved to the newer revision's pipeline, never a failure
|
||||||
Outcome string `json:"outcome"`
|
Outcome string `json:"outcome"`
|
||||||
// the pins the step's entries were built with, each mesh package's version by its module path, the ones the builder took from the registry for a package the entry named with none included; the runner asks the entry's held test steps with them (H-A-207)
|
// the pins the step's entries were built with, each mesh package's version by its module path, the ones the builder took from the registry for a package the entry named with none included; the runner asks the entry's held test steps with them (H-A-207)
|
||||||
Packages map[string]string `json:"packages,omitempty"`
|
Packages map[string]string `json:"packages,omitempty"`
|
||||||
Pipeline string `json:"pipeline"`
|
Pipeline string `json:"pipeline"`
|
||||||
Rerun bool `json:"rerun,omitempty"`
|
Rerun bool `json:"rerun,omitempty"`
|
||||||
// why it failed or could not run: the entry not built, the part not heard
|
// why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint
|
||||||
Said string `json:"said,omitempty"`
|
Said string `json:"said,omitempty"`
|
||||||
Started *time.Time `json:"started,omitempty"`
|
Started *time.Time `json:"started,omitempty"`
|
||||||
Step string `json:"step"`
|
Step string `json:"step"`
|
||||||
@@ -183,6 +183,7 @@ const (
|
|||||||
StepEndedOutcomeFailed = "failed"
|
StepEndedOutcomeFailed = "failed"
|
||||||
StepEndedOutcomeNothingToRun = "nothing to run"
|
StepEndedOutcomeNothingToRun = "nothing to run"
|
||||||
StepEndedOutcomeCouldNotRun = "could not run"
|
StepEndedOutcomeCouldNotRun = "could not run"
|
||||||
|
StepEndedOutcomeSuperseded = "superseded"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The values of StepEnded's step.
|
// The values of StepEnded's step.
|
||||||
@@ -338,7 +339,7 @@ const (
|
|||||||
type PublishQueueAnswerQueueItem struct {
|
type PublishQueueAnswerQueueItem struct {
|
||||||
// each artifact reference, <module>:<artifact>, with the digest to publish
|
// each artifact reference, <module>:<artifact>, with the digest to publish
|
||||||
Artifacts map[string]string `json:"artifacts,omitempty"`
|
Artifacts map[string]string `json:"artifacts,omitempty"`
|
||||||
// live, a build a pipeline's step waits on, pulled first; again, asked again at a start
|
// live, a build a pipeline's step waits on; again, asked again at a start
|
||||||
Class string `json:"class"`
|
Class string `json:"class"`
|
||||||
// the registry seat's holder the item is sent to, a module
|
// the registry seat's holder the item is sent to, a module
|
||||||
Holder string `json:"holder"`
|
Holder string `json:"holder"`
|
||||||
@@ -368,7 +369,7 @@ type PublishQueueAnswer struct {
|
|||||||
ItemsRead int64 `json:"items-read,omitempty"`
|
ItemsRead int64 `json:"items-read,omitempty"`
|
||||||
// how many of total the answer lists
|
// how many of total the answer lists
|
||||||
Listed int64 `json:"listed"`
|
Listed int64 `json:"listed"`
|
||||||
// the first 50 items listed, per holder in the order they are pulled
|
// the first 50 items listed, in stream order
|
||||||
Queue []PublishQueueAnswerQueueItem `json:"queue"`
|
Queue []PublishQueueAnswerQueueItem `json:"queue"`
|
||||||
// with capped: the queue's size in bytes
|
// with capped: the queue's size in bytes
|
||||||
QueueBytes int64 `json:"queue-bytes,omitempty"`
|
QueueBytes int64 `json:"queue-bytes,omitempty"`
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ func TestFixtures(t *testing.T) {
|
|||||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")},
|
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||||
{name: "the build step failed on its entry", subject: "mesh.seat.mesh-builds.event.step-ended.laptop", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}",
|
{name: "the build step failed on its entry", subject: "mesh.seat.mesh-builds.event.step-ended.laptop", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}",
|
||||||
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")},
|
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||||
|
{name: "the build step ended superseded: a newer entry of its branch superseded its fingerprint (H-A-508)", subject: "mesh.seat.mesh-builds.event.step-ended.laptop", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":2,\"id\":\"m2kx9a1b3c4d6c\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":2,\"id\":\"m2kx9a1b3c4d6c\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}",
|
||||||
|
decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")},
|
||||||
{name: "an ask taken at the pull", subject: "mesh.seat.mesh-builds.event.ask-taken.main-3589-mesh-sdk-unit", given: "{\"ask\":\"main-3589-mesh-sdk-unit\",\"at\":\"2026-11-21T22:00:00Z\",\"node\":\"anchor\"}", wire: "{\"ask\":\"main-3589-mesh-sdk-unit\",\"at\":\"2026-11-21T22:00:00Z\",\"node\":\"anchor\"}",
|
{name: "an ask taken at the pull", subject: "mesh.seat.mesh-builds.event.ask-taken.main-3589-mesh-sdk-unit", given: "{\"ask\":\"main-3589-mesh-sdk-unit\",\"at\":\"2026-11-21T22:00:00Z\",\"node\":\"anchor\"}", wire: "{\"ask\":\"main-3589-mesh-sdk-unit\",\"at\":\"2026-11-21T22:00:00Z\",\"node\":\"anchor\"}",
|
||||||
decode: func(b []byte) (any, error) { var v AskTakenEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.ask-taken\\.[^.*> ]+$")},
|
decode: func(b []byte) (any, error) { var v AskTakenEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.ask-taken\\.[^.*> ]+$")},
|
||||||
{name: "a version reserved at a fingerprint", subject: "mesh.seat.mesh-builds.event.version-reserved", given: "{\"artifact\":\"mesh-sdk:go\",\"fingerprint\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"form\":1,\"module\":\"mesh-sdk\",\"path\":\"git.novox.be/novox/mesh-sdk/go\",\"revision\":\"412\",\"version\":\"0.1.21\"}", wire: "{\"artifact\":\"mesh-sdk:go\",\"fingerprint\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"form\":1,\"module\":\"mesh-sdk\",\"path\":\"git.novox.be/novox/mesh-sdk/go\",\"revision\":\"412\",\"version\":\"0.1.21\"}",
|
{name: "a version reserved at a fingerprint", subject: "mesh.seat.mesh-builds.event.version-reserved", given: "{\"artifact\":\"mesh-sdk:go\",\"fingerprint\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"form\":1,\"module\":\"mesh-sdk\",\"path\":\"git.novox.be/novox/mesh-sdk/go\",\"revision\":\"412\",\"version\":\"0.1.21\"}", wire: "{\"artifact\":\"mesh-sdk:go\",\"fingerprint\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"form\":1,\"module\":\"mesh-sdk\",\"path\":\"git.novox.be/novox/mesh-sdk/go\",\"revision\":\"412\",\"version\":\"0.1.21\"}",
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ const Seat = "mesh-pipeline-runner"
|
|||||||
|
|
||||||
// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780):
|
// Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780):
|
||||||
// a reader of a value of another form says "form N, this reader knows M".
|
// a reader of a value of another form says "form N, this reader knows M".
|
||||||
const Form = 6
|
const Form = 10
|
||||||
|
|
||||||
// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition
|
// The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition
|
||||||
// whose fields changed while its forms did not (design 47 H2 §780).
|
// whose fields changed while its forms did not (design 47 H2 §780).
|
||||||
const (
|
const (
|
||||||
generatedForms = "6"
|
generatedForms = "10"
|
||||||
generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverEnded=4b35095f6829 MoverRow=b61f41d131a3 Pipeline=2663792125bf PipelineEnded=523f8fc0fe41 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=64600be410e9 PipelineStarted=a3d000f095db PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=48b8cecc529a StandsAnswer=0afa3693bf3b StartAnswer=ed94ced4513a StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=0dac0e15d017 StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466"
|
generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverEnded=4b35095f6829 MoverRow=b61f41d131a3 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=f58dbdcaf2d4 PipelineStarted=582f8ff3b28d PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=48b8cecc529a StandsAnswer=0afa3693bf3b StartAnswer=ed94ced4513a StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=0dac0e15d017 StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -69,11 +69,11 @@ func VerbDescription(verb string) string {
|
|||||||
case VerbRun:
|
case VerbRun:
|
||||||
return "The run on request of one or more members, each a module at a named commit, through their pipelines; delivers nothing, replacing the checker's try (ADR 0666 section 18). Says run-started."
|
return "The run on request of one or more members, each a module at a named commit, through their pipelines; delivers nothing, replacing the checker's try (ADR 0666 section 18). Says run-started."
|
||||||
case VerbStart:
|
case VerbStart:
|
||||||
return "A delivering pipeline for a watched branch's head, by hand; written in the hand-act log."
|
return "A delivering pipeline for a watched branch's head, by hand; written in the hand-act log. With modules, a pipeline at the head keyed <branch>.<revision>.again.<n> carrying the named modules whose newest entry has no passed pipeline, at the take-in's tiers; a module whose newest entry passed is refused by name. Exactly one of module or modules (design 47 H2 H-A-479)."
|
||||||
case VerbShow:
|
case VerbShow:
|
||||||
return "One pipeline: naming a mover, its steps alone; with no mover, each mover's row (its module, outcome and failed step), never every step of every mover, or the steps of any mover the step and state filters hold; and its step log, with the stores' fill (design 47 H2 §789, H-A-376). Reads only."
|
return "One pipeline: naming a mover, its steps alone; with no mover, each mover's row (its module, outcome and failed step), never every step of every mover, or the steps of any mover the step and state filters hold; and its step log, with the stores' fill (design 47 H2 §789, H-A-376). Reads only."
|
||||||
case VerbList:
|
case VerbList:
|
||||||
return "The pipelines and runs of a module, a branch or a commit, newest first: by default one short row per pipeline, the newest 20 (its key, call, start, end, outcome, movers' count and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376). Reads only."
|
return "The pipelines and runs of a module, a branch or a commit, newest first: by default one short row per pipeline, the newest 20 (its key, call, source, revision, start, end, outcome, movers' count, its steps counted per outcome and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376, H-A-467). Reads only."
|
||||||
case VerbStands:
|
case VerbStands:
|
||||||
return "What stands still, and since when: each step not ended and each wait held. Reads only."
|
return "What stands still, and since when: each step not ended and each wait held. Reads only."
|
||||||
case VerbWhyCarried:
|
case VerbWhyCarried:
|
||||||
@@ -354,6 +354,44 @@ func DecodePipelinesByBranchRevisionUnfinishedModuleValue(raw []byte) (Pipelines
|
|||||||
return v, formRead(raw), nil
|
return v, formRead(raw), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PipelinesByBranchRevisionAgainNKey is the key of one value of the state pipelines under the form "<branch>.<revision>.again.<n>".
|
||||||
|
func PipelinesByBranchRevisionAgainNKey(branch, revision, n string) string {
|
||||||
|
return branch + "." + revision + ".again." + n
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParsePipelinesByBranchRevisionAgainNKey reads the parts of a key of the form "<branch>.<revision>.again.<n>", in the order of the form; the last result is false for a key of another form.
|
||||||
|
func ParsePipelinesByBranchRevisionAgainNKey(key string) (string, string, string, bool) {
|
||||||
|
rest := key
|
||||||
|
v0, after0, found0 := strings.Cut(rest, ".")
|
||||||
|
if !found0 || v0 == "" {
|
||||||
|
return "", "", "", false
|
||||||
|
}
|
||||||
|
rest = after0
|
||||||
|
v2, after2, found2 := strings.Cut(rest, ".again.")
|
||||||
|
if !found2 || v2 == "" {
|
||||||
|
return "", "", "", false
|
||||||
|
}
|
||||||
|
rest = after2
|
||||||
|
if rest == "" {
|
||||||
|
return "", "", "", false
|
||||||
|
}
|
||||||
|
v4 := rest
|
||||||
|
rest = ""
|
||||||
|
if rest != "" {
|
||||||
|
return "", "", "", false
|
||||||
|
}
|
||||||
|
return v0, v2, v4, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecodePipelinesByBranchRevisionAgainNValue reads one value of the state pipelines under the form "<branch>.<revision>.again.<n>" as another part wrote it: a field PipelinesByBranchRevisionAgainNValue does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780).
|
||||||
|
func DecodePipelinesByBranchRevisionAgainNValue(raw []byte) (PipelinesByBranchRevisionAgainNValue, int, error) {
|
||||||
|
var v PipelinesByBranchRevisionAgainNValue
|
||||||
|
if err := json.Unmarshal(raw, &v); err != nil {
|
||||||
|
return v, 0, err
|
||||||
|
}
|
||||||
|
return v, formRead(raw), nil
|
||||||
|
}
|
||||||
|
|
||||||
// PipelinesByStepsPipelineMoverKey is the key of one value of the state pipelines under the form "steps.<pipeline>.<mover>".
|
// PipelinesByStepsPipelineMoverKey is the key of one value of the state pipelines under the form "steps.<pipeline>.<mover>".
|
||||||
func PipelinesByStepsPipelineMoverKey(pipeline, mover string) string {
|
func PipelinesByStepsPipelineMoverKey(pipeline, mover string) string {
|
||||||
return "steps." + pipeline + "." + mover
|
return "steps." + pipeline + "." + mover
|
||||||
@@ -737,7 +775,7 @@ type Pipeline struct {
|
|||||||
Revision int64 `json:"revision,omitempty"`
|
Revision int64 `json:"revision,omitempty"`
|
||||||
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
||||||
Run string `json:"run,omitempty"`
|
Run string `json:"run,omitempty"`
|
||||||
// for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748)
|
// its place in the runner's sequence: the runner's counter queue.next at its write, taken for every pipeline it writes, queued or placed at once, so it grows across the pipelines of a branch (design 47 H §748; H2 §813 (1), H-A-504 addendum)
|
||||||
Seq int64 `json:"seq,omitempty"`
|
Seq int64 `json:"seq,omitempty"`
|
||||||
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
||||||
Source int64 `json:"source"`
|
Source int64 `json:"source"`
|
||||||
@@ -859,6 +897,8 @@ type PipelineEnded struct {
|
|||||||
Revision int64 `json:"revision,omitempty"`
|
Revision int64 `json:"revision,omitempty"`
|
||||||
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
// the run on request's id, for a pipeline of a run; such a pipeline delivers nothing
|
||||||
Run string `json:"run,omitempty"`
|
Run string `json:"run,omitempty"`
|
||||||
|
// the pipeline's sequence, its record's seq: the assigner writes it as the run of the wants the pipeline's pass writes (design 47 H2 §813 (1), H-A-504 addendum)
|
||||||
|
Seq int64 `json:"seq,omitempty"`
|
||||||
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
// the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9)
|
||||||
Source int64 `json:"source"`
|
Source int64 `json:"source"`
|
||||||
Started *time.Time `json:"started,omitempty"`
|
Started *time.Time `json:"started,omitempty"`
|
||||||
@@ -879,7 +919,7 @@ const (
|
|||||||
PipelineEndedOutcomeCancelled = "cancelled"
|
PipelineEndedOutcomeCancelled = "cancelled"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PipelineRow is one pipeline in list's short form (design 47 H2 H-A-376).
|
// PipelineRow is one pipeline in list's short form, with its source, revision and its steps counted per outcome (design 47 H2 H-A-376, H-A-467).
|
||||||
type PipelineRow struct {
|
type PipelineRow struct {
|
||||||
// the merge call whose source revision the take-in took in
|
// the merge call whose source revision the take-in took in
|
||||||
Call string `json:"call,omitempty"`
|
Call string `json:"call,omitempty"`
|
||||||
@@ -889,8 +929,14 @@ type PipelineRow struct {
|
|||||||
MoverCount int64 `json:"mover-count"`
|
MoverCount int64 `json:"mover-count"`
|
||||||
Outcome string `json:"outcome"`
|
Outcome string `json:"outcome"`
|
||||||
// the pipeline's key
|
// the pipeline's key
|
||||||
Pipeline string `json:"pipeline"`
|
Pipeline string `json:"pipeline"`
|
||||||
Started *time.Time `json:"started,omitempty"`
|
// the catalog graph revision of the branch the pipeline runs for (design 47 H2 H-A-467)
|
||||||
|
Revision int64 `json:"revision,omitempty"`
|
||||||
|
// the source revision of the watched branch the pipeline runs for, its key (design 47 H2 H-A-467)
|
||||||
|
Source int64 `json:"source,omitempty"`
|
||||||
|
Started *time.Time `json:"started,omitempty"`
|
||||||
|
// how many of the pipeline's steps hold each outcome, by the step's outcome (design 47 H2 H-A-467)
|
||||||
|
Steps map[string]int64 `json:"steps,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// The values of PipelineRow's outcome.
|
// The values of PipelineRow's outcome.
|
||||||
@@ -904,7 +950,7 @@ const (
|
|||||||
PipelineRowOutcomeCancelled = "cancelled"
|
PipelineRowOutcomeCancelled = "cancelled"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PipelineStarted is a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52).
|
// PipelineStarted is a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52), and again at a re-pin with its kept revisions (H2 H-A-496).
|
||||||
type PipelineStarted struct {
|
type PipelineStarted struct {
|
||||||
At *time.Time `json:"at,omitempty"`
|
At *time.Time `json:"at,omitempty"`
|
||||||
// the watched branch, or the branch of a run on request
|
// the watched branch, or the branch of a run on request
|
||||||
@@ -913,6 +959,8 @@ type PipelineStarted struct {
|
|||||||
Call string `json:"call,omitempty"`
|
Call string `json:"call,omitempty"`
|
||||||
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
||||||
Form int64 `json:"form,omitempty"`
|
Form int64 `json:"form,omitempty"`
|
||||||
|
// every catalog revision the pipeline's movers are kept at, said again in full at each re-pin, so the indexer pins each while the pipeline runs (design 47 H2 H-A-496 and its addendum)
|
||||||
|
Kept []int64 `json:"kept,omitempty"`
|
||||||
// the pipeline's movers
|
// the pipeline's movers
|
||||||
Movers []Mover `json:"movers"`
|
Movers []Mover `json:"movers"`
|
||||||
// the pipeline's key, <branch>.<revision>, or <branch>.<source>.published.<package>.<version> for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)
|
// the pipeline's key, <branch>.<revision>, or <branch>.<source>.published.<package>.<version> for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747)
|
||||||
@@ -1238,7 +1286,10 @@ type RunAnswer struct {
|
|||||||
// StartInput is what start takes.
|
// StartInput is what start takes.
|
||||||
type StartInput struct {
|
type StartInput struct {
|
||||||
Branch string `json:"branch"`
|
Branch string `json:"branch"`
|
||||||
Module string `json:"module"`
|
// the one mover of the head's pipeline <branch>.<revision>; absent when modules is given
|
||||||
|
Module string `json:"module,omitempty"`
|
||||||
|
// the modules started again at the head, each whose newest entry has no passed pipeline (a failed, cut or superseded one); absent when module is given (design 47 H2 H-A-479)
|
||||||
|
Modules []string `json:"modules,omitempty"`
|
||||||
// why, written with the caller the runtime proves in the hand-act log
|
// why, written with the caller the runtime proves in the hand-act log
|
||||||
Why string `json:"why"`
|
Why string `json:"why"`
|
||||||
}
|
}
|
||||||
@@ -1631,6 +1682,9 @@ type PipelinesByBranchRunRunValue = Pipeline
|
|||||||
// PipelinesByBranchRevisionUnfinishedModuleValue is one value of the state pipelines under the key <branch>.<revision>.unfinished.<module>.
|
// PipelinesByBranchRevisionUnfinishedModuleValue is one value of the state pipelines under the key <branch>.<revision>.unfinished.<module>.
|
||||||
type PipelinesByBranchRevisionUnfinishedModuleValue = Pipeline
|
type PipelinesByBranchRevisionUnfinishedModuleValue = Pipeline
|
||||||
|
|
||||||
|
// PipelinesByBranchRevisionAgainNValue is one value of the state pipelines under the key <branch>.<revision>.again.<n>.
|
||||||
|
type PipelinesByBranchRevisionAgainNValue = Pipeline
|
||||||
|
|
||||||
// PipelinesByStepsPipelineMoverValue is one value of the state pipelines under the key steps.<pipeline>.<mover>.
|
// PipelinesByStepsPipelineMoverValue is one value of the state pipelines under the key steps.<pipeline>.<mover>.
|
||||||
type PipelinesByStepsPipelineMoverValue struct {
|
type PipelinesByStepsPipelineMoverValue struct {
|
||||||
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
// is the form of what this value carries, left out while it is 1 (design 47 H2 §780).
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ func TestFixtures(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{name: "a take-in's pipeline started with its two movers", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.3589", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}",
|
{name: "a take-in's pipeline started with its two movers", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.3589", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}",
|
||||||
decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+$")},
|
decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||||
|
{name: "a pipeline started again at a re-pin, with the three revisions its movers are kept at (H-A-496)", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.291", given: "{\"at\":\"2026-11-22T20:00:00Z\",\"branch\":\"main\",\"kept\":[292,295,298],\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"pipeline\":\"main.291\",\"revision\":291,\"source\":114,\"v\":1}", wire: "{\"at\":\"2026-11-22T20:00:00Z\",\"branch\":\"main\",\"kept\":[292,295,298],\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"pipeline\":\"main.291\",\"revision\":291,\"source\":114,\"v\":1}",
|
||||||
|
decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||||
|
{name: "an again pipeline ended passed, with its sequence (H-A-504 addendum)", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.320", given: "{\"branch\":\"main\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"node-tools\",\"steps\":[],\"tier\":1,\"version\":\"0.1.115\"}],\"outcome\":\"passed\",\"pipeline\":\"main.320.again.1\",\"revision\":320,\"seq\":269,\"source\":119,\"v\":1}", wire: "{\"branch\":\"main\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"node-tools\",\"steps\":[],\"tier\":1,\"version\":\"0.1.115\"}],\"outcome\":\"passed\",\"pipeline\":\"main.320.again.1\",\"revision\":320,\"seq\":269,\"source\":119,\"v\":1}",
|
||||||
|
decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||||
{name: "a pipeline ended passed: per mover its version, steps and tier, an optional step failed", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}",
|
{name: "a pipeline ended passed: per mover its version, steps and tier, an optional step failed", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}",
|
||||||
decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+$")},
|
decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+$")},
|
||||||
{name: "a pipeline of two movers ended with its phases and one mover left unfinished", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"form\":2,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"phases\":{\"build\":{\"end\":\"2026-11-21T22:02:00Z\",\"start\":\"2026-11-21T22:00:06Z\"},\"composition\":{\"end\":\"2026-11-21T22:06:00Z\",\"start\":\"2026-11-21T22:04:01Z\"},\"ended\":\"2026-11-21T22:06:00Z\",\"placed\":\"2026-11-21T22:00:05Z\",\"taken\":\"2026-11-21T22:00:00Z\",\"unit\":{\"end\":\"2026-11-21T22:04:00Z\",\"start\":\"2026-11-21T22:02:01Z\"}},\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"unfinished\":[\"mesh-delivery-view\"],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"form\":2,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"phases\":{\"build\":{\"end\":\"2026-11-21T22:02:00Z\",\"start\":\"2026-11-21T22:00:06Z\"},\"composition\":{\"end\":\"2026-11-21T22:06:00Z\",\"start\":\"2026-11-21T22:04:01Z\"},\"ended\":\"2026-11-21T22:06:00Z\",\"placed\":\"2026-11-21T22:00:05Z\",\"taken\":\"2026-11-21T22:00:00Z\",\"unit\":{\"end\":\"2026-11-21T22:04:00Z\",\"start\":\"2026-11-21T22:02:01Z\"}},\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"unfinished\":[\"mesh-delivery-view\"],\"v\":1}",
|
{name: "a pipeline of two movers ended with its phases and one mover left unfinished", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"form\":2,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"phases\":{\"build\":{\"end\":\"2026-11-21T22:02:00Z\",\"start\":\"2026-11-21T22:00:06Z\"},\"composition\":{\"end\":\"2026-11-21T22:06:00Z\",\"start\":\"2026-11-21T22:04:01Z\"},\"ended\":\"2026-11-21T22:06:00Z\",\"placed\":\"2026-11-21T22:00:05Z\",\"taken\":\"2026-11-21T22:00:00Z\",\"unit\":{\"end\":\"2026-11-21T22:04:00Z\",\"start\":\"2026-11-21T22:02:01Z\"}},\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"unfinished\":[\"mesh-delivery-view\"],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"form\":2,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"phases\":{\"build\":{\"end\":\"2026-11-21T22:02:00Z\",\"start\":\"2026-11-21T22:00:06Z\"},\"composition\":{\"end\":\"2026-11-21T22:06:00Z\",\"start\":\"2026-11-21T22:04:01Z\"},\"ended\":\"2026-11-21T22:06:00Z\",\"placed\":\"2026-11-21T22:00:05Z\",\"taken\":\"2026-11-21T22:00:00Z\",\"unit\":{\"end\":\"2026-11-21T22:04:00Z\",\"start\":\"2026-11-21T22:02:01Z\"}},\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"unfinished\":[\"mesh-delivery-view\"],\"v\":1}",
|
||||||
|
|||||||
@@ -96,6 +96,27 @@
|
|||||||
"said": "nats:program did not build"
|
"said": "nats:program did not build"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "the build step ended superseded: a newer entry of its branch superseded its fingerprint (H-A-508)",
|
||||||
|
"of": "event:step-ended",
|
||||||
|
"subject": "mesh.seat.mesh-builds.event.step-ended.laptop",
|
||||||
|
"given": {
|
||||||
|
"v": 1,
|
||||||
|
"form": 2,
|
||||||
|
"id": "m2kx9a1b3c4d6c",
|
||||||
|
"pipeline": "main.12.nats",
|
||||||
|
"step": "build",
|
||||||
|
"node": "laptop",
|
||||||
|
"outcome": "superseded",
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"module": "nats",
|
||||||
|
"fingerprint": "fp-0123"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"said": "nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "an ask taken at the pull",
|
"name": "an ask taken at the pull",
|
||||||
"of": "event:ask-taken",
|
"of": "event:ask-taken",
|
||||||
|
|||||||
@@ -156,7 +156,7 @@
|
|||||||
{
|
{
|
||||||
"name": "publish-queue",
|
"name": "publish-queue",
|
||||||
"class": "read",
|
"class": "read",
|
||||||
"description": "What the builder's work queue publishes holds, read by the builder from its own stream (design 47 H2 §793; H-A-454): the items' count per registry seat holder and class with the oldest and newest queue time, and the first 50 in the order they are pulled (the live class first, each class oldest first); module, and version, list only that module's items. A queue read past 4,000 items is answered capped, naming the items read and the queue's size.",
|
"description": "What the builder's work queue publishes holds, read by the builder from its own stream (design 47 H2 §793; H-A-454): the items' count per registry seat holder and class with the oldest and newest queue time, and the first 50 in stream order, the order each holder's one consumer pulls them (H-A-483); module, and version, list only that module's items. A queue read past 4,000 items is answered capped, naming the items read and the queue's size.",
|
||||||
"input": {
|
"input": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -243,7 +243,7 @@
|
|||||||
"live",
|
"live",
|
||||||
"again"
|
"again"
|
||||||
],
|
],
|
||||||
"description": "live, a build a pipeline's step waits on, pulled first; again, asked again at a start"
|
"description": "live, a build a pipeline's step waits on; again, asked again at a start"
|
||||||
},
|
},
|
||||||
"artifacts": {
|
"artifacts": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
"queued"
|
"queued"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"description": "the first 50 items listed, per holder in the order they are pulled"
|
"description": "the first 50 items listed, in stream order"
|
||||||
},
|
},
|
||||||
"listed": {
|
"listed": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@@ -636,13 +636,14 @@
|
|||||||
"passed",
|
"passed",
|
||||||
"failed",
|
"failed",
|
||||||
"nothing to run",
|
"nothing to run",
|
||||||
"could not run"
|
"could not run",
|
||||||
|
"superseded"
|
||||||
],
|
],
|
||||||
"description": "never passed for a build that built nothing"
|
"description": "never passed for a build that built nothing; superseded for an entry whose fingerprint a newer entry of its branch superseded, built or not (design 47 H2 H-A-508): the mover moved to the newer revision's pipeline, never a failure"
|
||||||
},
|
},
|
||||||
"said": {
|
"said": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "why it failed or could not run: the entry not built, the part not heard"
|
"description": "why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint"
|
||||||
},
|
},
|
||||||
"rerun": {
|
"rerun": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@@ -703,5 +704,6 @@
|
|||||||
"fingerprint"
|
"fingerprint"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"form": 2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,53 @@
|
|||||||
"at": "2026-11-10T10:00:00Z"
|
"at": "2026-11-10T10:00:00Z"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "a pipeline started again at a re-pin, with the three revisions its movers are kept at (H-A-496)",
|
||||||
|
"of": "event:pipeline-started",
|
||||||
|
"subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.291",
|
||||||
|
"given": {
|
||||||
|
"pipeline": "main.291",
|
||||||
|
"branch": "main",
|
||||||
|
"revision": 291,
|
||||||
|
"source": 114,
|
||||||
|
"v": 1,
|
||||||
|
"movers": [
|
||||||
|
{
|
||||||
|
"module": "nats",
|
||||||
|
"commit": "0123456789abcdef0123456789abcdef01234567",
|
||||||
|
"fingerprint": "fp-0123",
|
||||||
|
"repository": "mesh-networking",
|
||||||
|
"tier": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"kept": [292, 295, 298],
|
||||||
|
"at": "2026-11-22T20:00:00Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "an again pipeline ended passed, with its sequence (H-A-504 addendum)",
|
||||||
|
"of": "event:pipeline-ended",
|
||||||
|
"subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.320",
|
||||||
|
"given": {
|
||||||
|
"pipeline": "main.320.again.1",
|
||||||
|
"branch": "main",
|
||||||
|
"revision": 320,
|
||||||
|
"seq": 269,
|
||||||
|
"source": 119,
|
||||||
|
"end-count": 1,
|
||||||
|
"v": 1,
|
||||||
|
"outcome": "passed",
|
||||||
|
"movers": [
|
||||||
|
{
|
||||||
|
"module": "node-tools",
|
||||||
|
"fingerprint": "fp-0123",
|
||||||
|
"steps": [],
|
||||||
|
"tier": 1,
|
||||||
|
"version": "0.1.115"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "a pipeline ended passed: per mover its version, steps and tier, an optional step failed",
|
"name": "a pipeline ended passed: per mover its version, steps and tier, an optional step failed",
|
||||||
"of": "event:pipeline-ended",
|
"of": "event:pipeline-ended",
|
||||||
|
|||||||
@@ -50,12 +50,20 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "start",
|
"name": "start",
|
||||||
"description": "A delivering pipeline for a watched branch's head, by hand; written in the hand-act log.",
|
"description": "A delivering pipeline for a watched branch's head, by hand; written in the hand-act log. With modules, a pipeline at the head keyed <branch>.<revision>.again.<n> carrying the named modules whose newest entry has no passed pipeline, at the take-in's tiers; a module whose newest entry passed is refused by name. Exactly one of module or modules (design 47 H2 H-A-479).",
|
||||||
"input": {
|
"input": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"module": {
|
"module": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"description": "the one mover of the head's pipeline <branch>.<revision>; absent when modules is given"
|
||||||
|
},
|
||||||
|
"modules": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"description": "the modules started again at the head, each whose newest entry has no passed pipeline (a failed, cut or superseded one); absent when module is given (design 47 H2 H-A-479)"
|
||||||
},
|
},
|
||||||
"branch": {
|
"branch": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
@@ -66,7 +74,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"module",
|
|
||||||
"branch",
|
"branch",
|
||||||
"why"
|
"why"
|
||||||
]
|
]
|
||||||
@@ -171,7 +178,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "list",
|
"name": "list",
|
||||||
"description": "The pipelines and runs of a module, a branch or a commit, newest first: by default one short row per pipeline, the newest 20 (its key, call, start, end, outcome, movers' count and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376). Reads only.",
|
"description": "The pipelines and runs of a module, a branch or a commit, newest first: by default one short row per pipeline, the newest 20 (its key, call, source, revision, start, end, outcome, movers' count, its steps counted per outcome and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376, H-A-467). Reads only.",
|
||||||
"input": {
|
"input": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -910,6 +917,13 @@
|
|||||||
},
|
},
|
||||||
"description": "a pipeline of its own of one mover kept in the runner's state unfinished, put in it by place-unfinished; the revision the unfinished entry names (design 47 H2 §86, H-A-398)"
|
"description": "a pipeline of its own of one mover kept in the runner's state unfinished, put in it by place-unfinished; the revision the unfinished entry names (design 47 H2 §86, H-A-398)"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"key": "<branch>.<revision>.again.<n>",
|
||||||
|
"value": {
|
||||||
|
"$ref": "#/defs/Pipeline"
|
||||||
|
},
|
||||||
|
"description": "a pipeline started again at the head by start with modules, its movers the named modules whose newest entry has no passed pipeline; n from 1, taken by writing on absence (design 47 H2 H-A-479)"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"key": "steps.<pipeline>.<mover>",
|
"key": "steps.<pipeline>.<mover>",
|
||||||
"value": {
|
"value": {
|
||||||
@@ -1343,7 +1357,7 @@
|
|||||||
},
|
},
|
||||||
"seq": {
|
"seq": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748)"
|
"description": "its place in the runner's sequence: the runner's counter queue.next at its write, taken for every pipeline it writes, queued or placed at once, so it grows across the pipelines of a branch (design 47 H §748; H2 §813 (1), H-A-504 addendum)"
|
||||||
},
|
},
|
||||||
"end-count": {
|
"end-count": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
@@ -1441,6 +1455,10 @@
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "the catalog graph revision of the branch the pipeline runs for"
|
"description": "the catalog graph revision of the branch the pipeline runs for"
|
||||||
},
|
},
|
||||||
|
"seq": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "the pipeline's sequence, its record's seq: the assigner writes it as the run of the wants the pipeline's pass writes (design 47 H2 §813 (1), H-A-504 addendum)"
|
||||||
|
},
|
||||||
"end-count": {
|
"end-count": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325)"
|
"description": "how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325)"
|
||||||
@@ -1661,9 +1679,16 @@
|
|||||||
"published": {
|
"published": {
|
||||||
"$ref": "#/defs/Published",
|
"$ref": "#/defs/Published",
|
||||||
"description": "for a pipeline a package's publish started, that publish (A-202)"
|
"description": "for a pipeline a package's publish started, that publish (A-202)"
|
||||||
|
},
|
||||||
|
"kept": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"description": "every catalog revision the pipeline's movers are kept at, said again in full at each re-pin, so the indexer pins each while the pipeline runs (design 47 H2 H-A-496 and its addendum)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52)",
|
"description": "a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52), and again at a re-pin with its kept revisions (H2 H-A-496)",
|
||||||
"required": [
|
"required": [
|
||||||
"v",
|
"v",
|
||||||
"pipeline",
|
"pipeline",
|
||||||
@@ -2275,6 +2300,14 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "the merge call whose source revision the take-in took in"
|
"description": "the merge call whose source revision the take-in took in"
|
||||||
},
|
},
|
||||||
|
"source": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "the source revision of the watched branch the pipeline runs for, its key (design 47 H2 H-A-467)"
|
||||||
|
},
|
||||||
|
"revision": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "the catalog graph revision of the branch the pipeline runs for (design 47 H2 H-A-467)"
|
||||||
|
},
|
||||||
"started": {
|
"started": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time"
|
"format": "date-time"
|
||||||
@@ -2301,9 +2334,16 @@
|
|||||||
},
|
},
|
||||||
"failed": {
|
"failed": {
|
||||||
"$ref": "#/defs/FailedStep"
|
"$ref": "#/defs/FailedStep"
|
||||||
|
},
|
||||||
|
"steps": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"description": "how many of the pipeline's steps hold each outcome, by the step's outcome (design 47 H2 H-A-467)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "one pipeline in list's short form (design 47 H2 H-A-376)",
|
"description": "one pipeline in list's short form, with its source, revision and its steps counted per outcome (design 47 H2 H-A-376, H-A-467)",
|
||||||
"required": [
|
"required": [
|
||||||
"pipeline",
|
"pipeline",
|
||||||
"outcome",
|
"outcome",
|
||||||
@@ -2338,5 +2378,5 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"form": 6
|
"form": 10
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,13 +104,13 @@ export interface StepEnded {
|
|||||||
"id": string;
|
"id": string;
|
||||||
/** the node the builder ran it on, as in the subject */
|
/** the node the builder ran it on, as in the subject */
|
||||||
"node": string;
|
"node": string;
|
||||||
/** never passed for a build that built nothing */
|
/** never passed for a build that built nothing; superseded for an entry whose fingerprint a newer entry of its branch superseded, built or not (design 47 H2 H-A-508): the mover moved to the newer revision's pipeline, never a failure */
|
||||||
"outcome": "passed" | "failed" | "nothing to run" | "could not run";
|
"outcome": "passed" | "failed" | "nothing to run" | "could not run" | "superseded";
|
||||||
/** the pins the step's entries were built with, each mesh package's version by its module path, the ones the builder took from the registry for a package the entry named with none included; the runner asks the entry's held test steps with them (H-A-207) */
|
/** the pins the step's entries were built with, each mesh package's version by its module path, the ones the builder took from the registry for a package the entry named with none included; the runner asks the entry's held test steps with them (H-A-207) */
|
||||||
"packages"?: Record<string, string>;
|
"packages"?: Record<string, string>;
|
||||||
"pipeline": string;
|
"pipeline": string;
|
||||||
"rerun"?: boolean;
|
"rerun"?: boolean;
|
||||||
/** why it failed or could not run: the entry not built, the part not heard */
|
/** why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint */
|
||||||
"said"?: string;
|
"said"?: string;
|
||||||
"started"?: string;
|
"started"?: string;
|
||||||
"step": "build";
|
"step": "build";
|
||||||
@@ -251,7 +251,7 @@ export interface PublishQueueAnswerCountsItem {
|
|||||||
export interface PublishQueueAnswerQueueItem {
|
export interface PublishQueueAnswerQueueItem {
|
||||||
/** each artifact reference, <module>:<artifact>, with the digest to publish */
|
/** each artifact reference, <module>:<artifact>, with the digest to publish */
|
||||||
"artifacts"?: Record<string, string>;
|
"artifacts"?: Record<string, string>;
|
||||||
/** live, a build a pipeline's step waits on, pulled first; again, asked again at a start */
|
/** live, a build a pipeline's step waits on; again, asked again at a start */
|
||||||
"class": "live" | "again";
|
"class": "live" | "again";
|
||||||
/** the registry seat's holder the item is sent to, a module */
|
/** the registry seat's holder the item is sent to, a module */
|
||||||
"holder": string;
|
"holder": string;
|
||||||
@@ -275,7 +275,7 @@ export interface PublishQueueAnswer {
|
|||||||
"items-read"?: number;
|
"items-read"?: number;
|
||||||
/** how many of total the answer lists */
|
/** how many of total the answer lists */
|
||||||
"listed": number;
|
"listed": number;
|
||||||
/** the first 50 items listed, per holder in the order they are pulled */
|
/** the first 50 items listed, in stream order */
|
||||||
"queue": PublishQueueAnswerQueueItem[];
|
"queue": PublishQueueAnswerQueueItem[];
|
||||||
/** with capped: the queue's size in bytes */
|
/** with capped: the queue's size in bytes */
|
||||||
"queue-bytes"?: number;
|
"queue-bytes"?: number;
|
||||||
|
|||||||
@@ -121,6 +121,12 @@ export declare function pipelinesByBranchRevisionUnfinishedModuleKey(branch: str
|
|||||||
/** The parts of a key of the form "<branch>.<revision>.unfinished.<module>", or undefined for a key of another form. */
|
/** The parts of a key of the form "<branch>.<revision>.unfinished.<module>", or undefined for a key of another form. */
|
||||||
export declare function parsePipelinesByBranchRevisionUnfinishedModuleKey(_key: string): { branch: string; revision: string; module: string } | undefined;
|
export declare function parsePipelinesByBranchRevisionUnfinishedModuleKey(_key: string): { branch: string; revision: string; module: string } | undefined;
|
||||||
|
|
||||||
|
/** The key of one value of the state pipelines under the form "<branch>.<revision>.again.<n>". */
|
||||||
|
export declare function pipelinesByBranchRevisionAgainNKey(branch: string, revision: string, n: string): string;
|
||||||
|
|
||||||
|
/** The parts of a key of the form "<branch>.<revision>.again.<n>", or undefined for a key of another form. */
|
||||||
|
export declare function parsePipelinesByBranchRevisionAgainNKey(_key: string): { branch: string; revision: string; n: string } | undefined;
|
||||||
|
|
||||||
/** The key of one value of the state pipelines under the form "steps.<pipeline>.<mover>". */
|
/** The key of one value of the state pipelines under the form "steps.<pipeline>.<mover>". */
|
||||||
export declare function pipelinesByStepsPipelineMoverKey(pipeline: string, mover: string): string;
|
export declare function pipelinesByStepsPipelineMoverKey(pipeline: string, mover: string): string;
|
||||||
|
|
||||||
@@ -300,7 +306,7 @@ export interface Pipeline {
|
|||||||
"revision"?: number;
|
"revision"?: number;
|
||||||
/** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */
|
/** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */
|
||||||
"run"?: string;
|
"run"?: string;
|
||||||
/** for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748) */
|
/** its place in the runner's sequence: the runner's counter queue.next at its write, taken for every pipeline it writes, queued or placed at once, so it grows across the pipelines of a branch (design 47 H §748; H2 §813 (1), H-A-504 addendum) */
|
||||||
"seq"?: number;
|
"seq"?: number;
|
||||||
/** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */
|
/** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */
|
||||||
"source": number;
|
"source": number;
|
||||||
@@ -411,6 +417,8 @@ export interface PipelineEnded {
|
|||||||
"revision"?: number;
|
"revision"?: number;
|
||||||
/** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */
|
/** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */
|
||||||
"run"?: string;
|
"run"?: string;
|
||||||
|
/** the pipeline's sequence, its record's seq: the assigner writes it as the run of the wants the pipeline's pass writes (design 47 H2 §813 (1), H-A-504 addendum) */
|
||||||
|
"seq"?: number;
|
||||||
/** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */
|
/** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */
|
||||||
"source": number;
|
"source": number;
|
||||||
"started"?: string;
|
"started"?: string;
|
||||||
@@ -420,7 +428,7 @@ export interface PipelineEnded {
|
|||||||
"why"?: string;
|
"why"?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** one pipeline in list's short form (design 47 H2 H-A-376) */
|
/** one pipeline in list's short form, with its source, revision and its steps counted per outcome (design 47 H2 H-A-376, H-A-467) */
|
||||||
export interface PipelineRow {
|
export interface PipelineRow {
|
||||||
/** the merge call whose source revision the take-in took in */
|
/** the merge call whose source revision the take-in took in */
|
||||||
"call"?: string;
|
"call"?: string;
|
||||||
@@ -431,10 +439,16 @@ export interface PipelineRow {
|
|||||||
"outcome": "waiting" | "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled";
|
"outcome": "waiting" | "running" | "passed" | "failed" | "refused" | "superseded" | "cancelled";
|
||||||
/** the pipeline's key */
|
/** the pipeline's key */
|
||||||
"pipeline": string;
|
"pipeline": string;
|
||||||
|
/** the catalog graph revision of the branch the pipeline runs for (design 47 H2 H-A-467) */
|
||||||
|
"revision"?: number;
|
||||||
|
/** the source revision of the watched branch the pipeline runs for, its key (design 47 H2 H-A-467) */
|
||||||
|
"source"?: number;
|
||||||
"started"?: string;
|
"started"?: string;
|
||||||
|
/** how many of the pipeline's steps hold each outcome, by the step's outcome (design 47 H2 H-A-467) */
|
||||||
|
"steps"?: Record<string, number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52) */
|
/** a pipeline's start, said at its write, a waiting one's too (design 47 H §746, H-A-52), and again at a re-pin with its kept revisions (H2 H-A-496) */
|
||||||
export interface PipelineStarted {
|
export interface PipelineStarted {
|
||||||
"at"?: string;
|
"at"?: string;
|
||||||
/** the watched branch, or the branch of a run on request */
|
/** the watched branch, or the branch of a run on request */
|
||||||
@@ -443,6 +457,8 @@ export interface PipelineStarted {
|
|||||||
"call"?: string;
|
"call"?: string;
|
||||||
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
|
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
|
||||||
"form"?: number;
|
"form"?: number;
|
||||||
|
/** every catalog revision the pipeline's movers are kept at, said again in full at each re-pin, so the indexer pins each while the pipeline runs (design 47 H2 H-A-496 and its addendum) */
|
||||||
|
"kept"?: number[];
|
||||||
/** the pipeline's movers */
|
/** the pipeline's movers */
|
||||||
"movers": Mover[];
|
"movers": Mover[];
|
||||||
/** the pipeline's key, <branch>.<revision>, or <branch>.<source>.published.<package>.<version> for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */
|
/** the pipeline's key, <branch>.<revision>, or <branch>.<source>.published.<package>.<version> for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */
|
||||||
@@ -693,7 +709,10 @@ export interface RunAnswer {
|
|||||||
/** is what start takes. */
|
/** is what start takes. */
|
||||||
export interface StartInput {
|
export interface StartInput {
|
||||||
"branch": string;
|
"branch": string;
|
||||||
"module": string;
|
/** the one mover of the head's pipeline <branch>.<revision>; absent when modules is given */
|
||||||
|
"module"?: string;
|
||||||
|
/** the modules started again at the head, each whose newest entry has no passed pipeline (a failed, cut or superseded one); absent when module is given (design 47 H2 H-A-479) */
|
||||||
|
"modules"?: string[];
|
||||||
/** why, written with the caller the runtime proves in the hand-act log */
|
/** why, written with the caller the runtime proves in the hand-act log */
|
||||||
"why": string;
|
"why": string;
|
||||||
}
|
}
|
||||||
@@ -1025,6 +1044,9 @@ export type PipelinesByBranchRunRunValue = Pipeline;
|
|||||||
/** is one value of the state pipelines under the key <branch>.<revision>.unfinished.<module>. */
|
/** is one value of the state pipelines under the key <branch>.<revision>.unfinished.<module>. */
|
||||||
export type PipelinesByBranchRevisionUnfinishedModuleValue = Pipeline;
|
export type PipelinesByBranchRevisionUnfinishedModuleValue = Pipeline;
|
||||||
|
|
||||||
|
/** is one value of the state pipelines under the key <branch>.<revision>.again.<n>. */
|
||||||
|
export type PipelinesByBranchRevisionAgainNValue = Pipeline;
|
||||||
|
|
||||||
/** is one value of the state pipelines under the key steps.<pipeline>.<mover>. */
|
/** is one value of the state pipelines under the key steps.<pipeline>.<mover>. */
|
||||||
export interface PipelinesByStepsPipelineMoverValue {
|
export interface PipelinesByStepsPipelineMoverValue {
|
||||||
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
|
/** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */
|
||||||
|
|||||||
@@ -199,6 +199,29 @@ export function parsePipelinesByBranchRevisionUnfinishedModuleKey(_key) {
|
|||||||
return { branch, revision, module };
|
return { branch, revision, module };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The key of one value of the state pipelines under the form "<branch>.<revision>.again.<n>". */
|
||||||
|
export function pipelinesByBranchRevisionAgainNKey(branch, revision, n) {
|
||||||
|
return branch + "." + revision + ".again." + n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The parts of a key of the form "<branch>.<revision>.again.<n>", or undefined for a key of another form. */
|
||||||
|
export function parsePipelinesByBranchRevisionAgainNKey(_key) {
|
||||||
|
let _rest = _key;
|
||||||
|
const _at0 = _rest.indexOf(".");
|
||||||
|
if (_at0 <= 0) return undefined;
|
||||||
|
const branch = _rest.slice(0, _at0);
|
||||||
|
_rest = _rest.slice(_at0 + 1);
|
||||||
|
const _at2 = _rest.indexOf(".again.");
|
||||||
|
if (_at2 <= 0) return undefined;
|
||||||
|
const revision = _rest.slice(0, _at2);
|
||||||
|
_rest = _rest.slice(_at2 + 7);
|
||||||
|
if (_rest === "") return undefined;
|
||||||
|
const n = _rest;
|
||||||
|
_rest = "";
|
||||||
|
if (_rest !== "") return undefined;
|
||||||
|
return { branch, revision, n };
|
||||||
|
}
|
||||||
|
|
||||||
/** The key of one value of the state pipelines under the form "steps.<pipeline>.<mover>". */
|
/** The key of one value of the state pipelines under the form "steps.<pipeline>.<mover>". */
|
||||||
export function pipelinesByStepsPipelineMoverKey(pipeline, mover) {
|
export function pipelinesByStepsPipelineMoverKey(pipeline, mover) {
|
||||||
return "steps." + pipeline + "." + mover;
|
return "steps." + pipeline + "." + mover;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import (
|
|||||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/gopackageregistry"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
||||||
@@ -800,8 +801,10 @@ func serveAssignerAssignments(t *testing.T, ctx context.Context, js jetstream.Je
|
|||||||
}
|
}
|
||||||
if _, err := js.CreateOrUpdateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-indexer", AckPolicy: jetstream.AckExplicitPolicy,
|
if _, err := js.CreateOrUpdateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-indexer", AckPolicy: jetstream.AckExplicitPolicy,
|
||||||
// and the build seat's step-ended the manifest's consumes names (design 47 G §713: the end of a validation ask), and the
|
// and the build seat's step-ended the manifest's consumes names (design 47 G §713: the end of a validation ask), and the
|
||||||
// builder's version-reserved, which no stream of its own keeps (design 47 H2 §805).
|
// builder's version-reserved, which no stream of its own keeps (design 47 H2 §805), and the Go package registry seat's
|
||||||
FilterSubjects: []string{"mesh.mod." + assignerHolderModule + ".event.views.>", meshcatalog.SubjectRoom, nodebuildgo.SubjectStepEndedAll, meshbuilds.SubjectVersionReserved}}); err != nil {
|
// published, a series' newest a pin names (H-A-495 addendum).
|
||||||
|
FilterSubjects: []string{"mesh.mod." + assignerHolderModule + ".event.views.>", meshcatalog.SubjectRoom, nodebuildgo.SubjectStepEndedAll, meshbuilds.SubjectVersionReserved,
|
||||||
|
gopackageregistry.SubjectPublished}}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
em := views.Emitter{Owner: assignerHolderModule, Subject: process.Account{Node: "n1", Module: assignerHolderModule}.EventSubject,
|
em := views.Emitter{Owner: assignerHolderModule, Subject: process.Account{Node: "n1", Module: assignerHolderModule}.EventSubject,
|
||||||
|
|||||||
@@ -664,7 +664,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
sources.refresh()
|
sources.refresh()
|
||||||
})
|
})
|
||||||
// The held take-ins are taken in again from the state held at the start, before a branch's consumer gives a later one
|
// The held take-ins are taken in again from the state held at the start, before a branch's consumer gives a later one
|
||||||
// (design 47 H, H-A-114, H-A-118).
|
// (design 47 H, H-A-114, H-A-118); a chain's key a stop left is deleted first (H2 H-A-497 addendum).
|
||||||
|
ix.EndChains(ctx)
|
||||||
sources.takeAgain()
|
sources.takeAgain()
|
||||||
sources.refresh()
|
sources.refresh()
|
||||||
if stopped != nil {
|
if stopped != nil {
|
||||||
|
|||||||
+76
-12
@@ -19,9 +19,11 @@ import (
|
|||||||
"github.com/nats-io/nats.go/jetstream"
|
"github.com/nats-io/nats.go/jetstream"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/gopackageregistry"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
|
||||||
|
|
||||||
"mesh-delivery-indexer/internal/index"
|
"mesh-delivery-indexer/internal/index"
|
||||||
@@ -76,10 +78,11 @@ func untilModule(t *testing.T, ctx context.Context, js jetstream.JetStream, name
|
|||||||
// of lib-a and one of lib-b, and so their trees alone, moves lib-a, lib-b and their importers alone, never the other 32
|
// of lib-a and one of lib-b, and so their trees alone, moves lib-a, lib-b and their importers alone, never the other 32
|
||||||
// modules whose repository's commit moved too.
|
// modules whose repository's commit moved too.
|
||||||
//
|
//
|
||||||
// Design 47 H2 §805 (H-A-453 (3)): the builder's twenty version-reserved of mesh-sdk in that revision's pipeline (twenty
|
// Design 47 H2 §805 (H-A-453 (3)) and H-A-495 with its addendum: the builder's twenty version-reserved of mesh-sdk in that
|
||||||
// artifacts of its Go package, as repin_test.go reads them) are kept in heard and gathered, and its pipeline-started keeps one
|
// revision's pipeline (twenty artifacts of its Go package, as repin_test.go reads them) are kept in heard and gathered, and
|
||||||
// re-pin revision of main, importer its mover pinned to the reserved version; the next pipeline's reservation keeps the
|
// they and its pipeline-started move no pin: a pin names only a published version. The release of the reserved version (the
|
||||||
// revision after it, so none came between.
|
// Go package registry seat's published and every artifact's package-published) keeps one re-pin revision of main, importer
|
||||||
|
// its mover pinned to it; the next pipeline's reservation keeps none, so the revision after it is the next release's.
|
||||||
func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
sdkGo = "git.novox.be/novox/mesh-sdk/go"
|
sdkGo = "git.novox.be/novox/mesh-sdk/go"
|
||||||
@@ -143,6 +146,24 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
|||||||
if heardKV, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.HeardState), History: 64, LimitMarkerTTL: time.Minute}); err != nil {
|
if heardKV, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.HeardState), History: 64, LimitMarkerTTL: time.Minute}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
// package-published on its kept stream with the indexer's durable, as the grants part makes them, and the state versions
|
||||||
|
// a release is recorded in (H-A-495: the release re-pins).
|
||||||
|
if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, index.VersionsState), History: 1}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: meshbuilds.StreamPackagePublished, Subjects: []string{meshbuilds.SubjectPackagePublished}}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := js.CreateOrUpdateConsumer(ctx, meshbuilds.StreamPackagePublished, jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-indexer", AckPolicy: jetstream.AckExplicitPolicy,
|
||||||
|
MaxDeliver: EventDeliveries}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// The indexer's durable on pipeline-started samples every acknowledgement, so the bed hears that the settle a
|
||||||
|
// pipeline-started makes (H-A-424 (1)) has ended before it releases, never by sleeping.
|
||||||
|
if _, err := js.CreateOrUpdateConsumer(ctx, meshpipelinerunner.StreamPipelineStarted, jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-indexer",
|
||||||
|
AckPolicy: jetstream.AckExplicitPolicy, FilterSubjects: []string{meshpipelinerunner.SubjectPipelineStartedAll}, SampleFrequency: "100%"}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
// A dry run's key left by an indexer that stopped mid-run (§804).
|
// A dry run's key left by an indexer that stopped mid-run (§804).
|
||||||
if dryRuns, err = js.KeyValue(ctx, index.Bucket(testIndexer, index.DryRunsState)); err != nil {
|
if dryRuns, err = js.KeyValue(ctx, index.Bucket(testIndexer, index.DryRunsState)); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -260,8 +281,9 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
|||||||
t.Errorf("the catalogue's commit changing lib-a's and lib-b's tests moves %v of its 36 modules, want lib-a, lib-b and their importers alone", movers)
|
t.Errorf("the catalogue's commit changing lib-a's and lib-b's tests moves %v of its 36 modules, want lib-a, lib-b and their importers alone", movers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// §805: twenty reservations of mesh-sdk's packages in main's revision of source 12, kept and gathered; its pipeline-started
|
// §805, H-A-495: twenty reservations of mesh-sdk's packages in main's revision of source 12, kept and gathered, and its
|
||||||
// keeps one re-pin revision of main, and the next pipeline's reservation the one after it.
|
// pipeline-started move no pin; the release of the reserved version keeps one re-pin revision of main, and the next
|
||||||
|
// pipeline's reservation none, so the revision after it is the next release's.
|
||||||
objects := newBusObjects(js, testAccount, index.CatalogRevisionsObjects)
|
objects := newBusObjects(js, testAccount, index.CatalogRevisionsObjects)
|
||||||
untilRevision := func(n int64) meshcatalog.CatalogRevision {
|
untilRevision := func(n int64) meshcatalog.CatalogRevision {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
@@ -299,19 +321,61 @@ func TestASourceRevisionMovingMeshSDKNamesItAndItsImporters(t *testing.T) {
|
|||||||
return v != nil && json.Unmarshal(v, &r) == nil && len(r.Reservations) == artifacts
|
return v != nil && json.Unmarshal(v, &r) == nil && len(r.Reservations) == artifacts
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// release publishes mesh-sdk's Go package at version, as the registry seat says it (the series' newest a pin names,
|
||||||
|
// H-A-495 addendum), and every artifact of mesh-sdk's entry in main's revision n, as the builder says them.
|
||||||
|
release := func(n int64, version string) {
|
||||||
|
t.Helper()
|
||||||
|
raw, _ := json.Marshal(gopackageregistry.PublishedEvent{Kind: "package", Name: sdkGo, Module: sdkGo, Version: version, Commit: m2, Digest: "sha256:" + version})
|
||||||
|
if _, err := js.Publish(ctx, gopackageregistry.SubjectPublished, raw); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
_, entries, err := index.ReadRevision(ctx, objects, index.BranchObject("main", n))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
i := slices.IndexFunc(entries, func(e meshcatalog.CatalogEntry) bool { return e.Module == "mesh-sdk" })
|
||||||
|
if i < 0 {
|
||||||
|
t.Fatalf("main.%d holds no entry of mesh-sdk", n)
|
||||||
|
}
|
||||||
|
for _, a := range entries[i].Artifacts {
|
||||||
|
raw, _ := json.Marshal(meshbuilds.PackagePublished{Module: "mesh-sdk", Artifact: a.Ref, Digest: "sha256:" + a.Ref + version, Version: version, Source: 12, Branch: "main"})
|
||||||
|
if _, err := js.Publish(ctx, meshbuilds.SubjectPackagePublished, raw); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// started says pipeline-started of main's revision n and waits for the indexer's acknowledgement of it, which follows its settle.
|
||||||
|
started := func(n int64) {
|
||||||
|
t.Helper()
|
||||||
|
acks, err := js.Conn().SubscribeSync("$JS.EVENT.METRIC.CONSUMER.ACK." + meshpipelinerunner.StreamPipelineStarted + ".n1_mesh-delivery-indexer")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer func() { _ = acks.Unsubscribe() }()
|
||||||
|
if err := js.Conn().Flush(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
sayPipeline(t, ctx, js, false, "main", n)
|
||||||
|
if _, err := acks.NextMsg(waitBound); err != nil {
|
||||||
|
t.Fatalf("the pipeline-started of main.%d is not acknowledged after %s: %v", n, waitBound, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
r := taken.Revision
|
r := taken.Revision
|
||||||
reserve(r, "0.1.28", 20)
|
reserve(r, "0.1.28", 20)
|
||||||
sayPipeline(t, ctx, js, false, "main", r)
|
started(r)
|
||||||
if rev := untilRevision(r + 1); rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease || !strings.Contains(rev.Call, index.BranchObject("main", r)+"'s") ||
|
release(r, "0.1.28")
|
||||||
|
if rev := untilRevision(r + 1); rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease || rev.Call != index.ReleaseCall("mesh-sdk", "0.1.28") ||
|
||||||
len(rev.Movers) != 1 || rev.Movers[0].Module != "importer" {
|
len(rev.Movers) != 1 || rev.Movers[0].Module != "importer" {
|
||||||
t.Errorf("main.%d = %+v, want one re-pin revision of the twenty reservations, importer its mover", r+1, rev)
|
t.Errorf("main.%d = %+v, want the re-pin revision of the release of mesh-sdk 0.1.28, importer its mover: twenty reservations move no pin", r+1, rev)
|
||||||
}
|
}
|
||||||
untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.28" })
|
untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.28" })
|
||||||
reserve(r+1, "0.1.29", 1)
|
reserve(r+1, "0.1.29", 1)
|
||||||
sayPipeline(t, ctx, js, false, "main", r+1)
|
started(r + 1)
|
||||||
if rev := untilRevision(r + 2); !strings.Contains(rev.Call, index.BranchObject("main", r+1)+"'s") {
|
release(r+1, "0.1.29")
|
||||||
t.Errorf("main.%d = %+v, want the next pipeline's re-pin: the twenty reservations kept more than one revision", r+2, rev)
|
if rev := untilRevision(r + 2); rev.Call != index.ReleaseCall("mesh-sdk", "0.1.29") {
|
||||||
|
t.Errorf("main.%d = %+v, want the re-pin of the release of mesh-sdk 0.1.29: the reservation of 0.1.29 keeps no revision", r+2, rev)
|
||||||
}
|
}
|
||||||
|
untilModule(t, ctx, js, "importer", func(m meshcatalog.ModulesByModuleValue) bool { return m.Packages[sdkGo] == "v0.1.29" })
|
||||||
|
|
||||||
// A branch's take-in moving mesh-sdk to m3 is a dry run: its packages stay in dry-runs while it runs, the trunk's are
|
// A branch's take-in moving mesh-sdk to m3 is a dry run: its packages stay in dry-runs while it runs, the trunk's are
|
||||||
// untouched, and its keys go once it answered (§804).
|
// untouched, and its keys go once it answered (§804).
|
||||||
|
|||||||
@@ -265,24 +265,34 @@ type actor struct {
|
|||||||
s *sourceMoved
|
s *sourceMoved
|
||||||
}
|
}
|
||||||
|
|
||||||
// HeldAgain takes a branch's held source revisions in again now (indexer_take_in_pending).
|
// HeldAgain takes a branch's held source revisions in again now (indexer_take_in_pending), beside the asks' loop, and answers
|
||||||
|
// at once (design 47 H2 H-A-497 and its addendum): a chain that runs already answers its state from the state takeins; held
|
||||||
|
// sources start the chain at the first, written there before it runs, answered with how many wait.
|
||||||
func (a actor) HeldAgain(ctx context.Context, branch string) index.TakenIn {
|
func (a actor) HeldAgain(ctx context.Context, branch string) index.TakenIn {
|
||||||
r := index.TakenIn{Module: branch}
|
r := index.TakenIn{Module: branch}
|
||||||
if hs, err := a.HeldOf(ctx, branch); err != nil || len(hs) == 0 {
|
if c, running, err := a.ChainOf(ctx, branch); err != nil {
|
||||||
|
r.Answer = "the state takeins is not read: " + err.Error()
|
||||||
|
return r
|
||||||
|
} else if running {
|
||||||
|
r.Held = true
|
||||||
|
r.Answer = fmt.Sprintf("a chain runs: source %d taken in since %s, %d wait", c.Source, c.Since.Format(time.RFC3339), c.Waiting)
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
hs, err := a.HeldOf(ctx, branch)
|
||||||
|
if err != nil || len(hs) == 0 {
|
||||||
r.Answer = "the branch " + branch + " holds no source-moved"
|
r.Answer = "the branch " + branch + " holds no source-moved"
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Answer = "the state held is not read: " + err.Error()
|
r.Answer = "the state held is not read: " + err.Error()
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
a.s.takeAgain()
|
c := a.StartChain(ctx, hs)
|
||||||
hs, err := a.HeldOf(ctx, branch)
|
go func() {
|
||||||
still := err != nil || len(hs) > 0
|
a.s.takeAgain()
|
||||||
r.Stored, r.Held = !still, still
|
a.EndChain(a.s.ctx, branch)
|
||||||
r.Answer = "taken in"
|
}()
|
||||||
if still {
|
r.Held = true
|
||||||
r.Answer = "still held: indexer_pending says why"
|
r.Answer = fmt.Sprintf("chain started at source %d, %d wait", c.Source, c.Waiting)
|
||||||
}
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,98 @@ func TestAHeldSourceMovedIsSkippedByHand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// chainStore is a takeins state in memory, safe beside the chain's own goroutine, which says on ended when a chain key goes.
|
||||||
|
type chainStore struct {
|
||||||
|
mu sync.Mutex
|
||||||
|
vals map[string][]byte
|
||||||
|
ended chan string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *chainStore) Get(_ context.Context, k string) ([]byte, uint64, bool, error) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
v, ok := c.vals[k]
|
||||||
|
return v, 1, ok, nil
|
||||||
|
}
|
||||||
|
func (c *chainStore) Keys(context.Context) ([]string, error) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
var out []string
|
||||||
|
for k := range c.vals {
|
||||||
|
out = append(out, k)
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
func (c *chainStore) Create(_ context.Context, k string, v []byte) error {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
c.vals[k] = v
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (c *chainStore) Update(ctx context.Context, k string, v []byte, _ uint64) error {
|
||||||
|
return c.Create(ctx, k, v)
|
||||||
|
}
|
||||||
|
func (c *chainStore) Delete(_ context.Context, k string, _ uint64) error {
|
||||||
|
c.mu.Lock()
|
||||||
|
_, had := c.vals[k]
|
||||||
|
delete(c.vals, k)
|
||||||
|
c.mu.Unlock()
|
||||||
|
if had && strings.HasPrefix(k, index.ChainPrefix) {
|
||||||
|
c.ended <- k
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Design 47 H2 H-A-497 and its addendum: a hand ask of a branch with held sources starts the chain beside the asks' loop
|
||||||
|
// and answers at once; an ask that meets the running chain answers its state, which the state takeins holds and
|
||||||
|
// indexer_pending shows; the chain's key goes at its end.
|
||||||
|
func TestAHandAskOfAHeldBranchAnswersAtOnce(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
held := &memStore{vals: map[string][]byte{}}
|
||||||
|
takeIns := &chainStore{vals: map[string][]byte{}, ended: make(chan string, 4)}
|
||||||
|
ix := &index.Indexer{Held: held, TakeIns: takeIns, Logf: func(string, ...any) {},
|
||||||
|
Now: func() time.Time { return time.Date(2026, 11, 22, 21, 7, 0, 0, time.UTC) }}
|
||||||
|
handlers := map[string]func(jetstream.Msg){}
|
||||||
|
s := &sourceMoved{ctx: ctx, ix: ix,
|
||||||
|
branches: func(context.Context) ([]string, error) { return []string{"main"}, nil },
|
||||||
|
bind: func(_ context.Context, branch string, each func(jetstream.Msg)) (func(), error) {
|
||||||
|
handlers[branch] = each
|
||||||
|
return func() {}, nil
|
||||||
|
},
|
||||||
|
logf: func(string, ...any) {}}
|
||||||
|
s.refresh()
|
||||||
|
for _, n := range []int{114, 115, 116} {
|
||||||
|
m := &fakeMsg{subject: fmt.Sprintf("mesh.seat.mesh-delivery.event.source-moved.main.%d", n),
|
||||||
|
data: []byte(fmt.Sprintf(`{"v":1,"branch":"main","source":%d,"call":"%d123456789abcde","heads":[]}`, n, n))}
|
||||||
|
handlers["main"](msgOf{f: m})
|
||||||
|
}
|
||||||
|
a := actor{ix, s}
|
||||||
|
s.again.Lock() // the chain waits for the lock, so it is still running at the second ask
|
||||||
|
if r := a.HeldAgain(ctx, "main"); r.Answer != "chain started at source 114, 2 wait" {
|
||||||
|
s.again.Unlock()
|
||||||
|
t.Fatalf("the first ask answered %+v, want the chain started at once", r)
|
||||||
|
}
|
||||||
|
r := a.HeldAgain(ctx, "main")
|
||||||
|
var pending any
|
||||||
|
var err error
|
||||||
|
for _, tool := range index.HeldTools(held, takeIns, nil, ix.Now, nil) {
|
||||||
|
if tool.Name == index.PendingTool {
|
||||||
|
pending, err = tool.Run(map[string]any{})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.again.Unlock()
|
||||||
|
chains := pending.(index.PendingAnswer).Chains
|
||||||
|
if r.Answer != "a chain runs: source 114 taken in since 2026-11-22T21:07:00Z, 2 wait" || !r.Held {
|
||||||
|
t.Errorf("the ask meeting the chain answered %+v, want its state at once", r)
|
||||||
|
}
|
||||||
|
if err != nil || len(chains) != 1 || chains[0].Branch != "main" || chains[0].Source != 114 || chains[0].Waiting != 2 {
|
||||||
|
t.Errorf("indexer_pending shows chains %+v (%v), want main's at 114 with 2 waiting", chains, err)
|
||||||
|
}
|
||||||
|
if k := <-takeIns.ended; k != index.ChainKey("main") {
|
||||||
|
t.Errorf("the key %s went, want main's chain", k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// revisionObjects is the catalog revisions' object bucket in memory.
|
// revisionObjects is the catalog revisions' object bucket in memory.
|
||||||
type revisionObjects map[string][]byte
|
type revisionObjects map[string][]byte
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ type takerIn interface {
|
|||||||
// written back, by compare-and-set at its revision, with what the indexer stored or why not. A value
|
// written back, by compare-and-set at its revision, with what the indexer stored or why not. A value
|
||||||
// answered already (this indexer's own write) or deleted is left.
|
// answered already (this indexer's own write) or deleted is left.
|
||||||
func takenIn(ctx context.Context, ix takerIn, kv jetstream.KeyValue, e jetstream.KeyValueEntry, logf func(string, ...any)) {
|
func takenIn(ctx context.Context, ix takerIn, kv jetstream.KeyValue, e jetstream.KeyValueEntry, logf func(string, ...any)) {
|
||||||
if e.Operation() != jetstream.KeyValuePut || strings.HasPrefix(e.Key(), index.RunningPrefix) {
|
if e.Operation() != jetstream.KeyValuePut || strings.HasPrefix(e.Key(), index.RunningPrefix) || strings.HasPrefix(e.Key(), index.ChainPrefix) {
|
||||||
return // a running take-in's waiting-on is the indexer's own record, no ask (H-A-409)
|
return // a running take-in's waiting-on and a running chain are the indexer's own records, no ask (H-A-409, H-A-497)
|
||||||
}
|
}
|
||||||
a, err := index.DecodeTakeIn(e.Value())
|
a, err := index.DecodeTakeIn(e.Value())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ type PendingAnswer struct {
|
|||||||
Held []HeldTakeIn `json:"held"`
|
Held []HeldTakeIn `json:"held"`
|
||||||
// Running are the take-ins that run, each with what it waits on (design 47 H2 §803, H-A-409).
|
// Running are the take-ins that run, each with what it waits on (design 47 H2 §803, H-A-409).
|
||||||
Running []RunningTakeIn `json:"running,omitempty"`
|
Running []RunningTakeIn `json:"running,omitempty"`
|
||||||
|
// Chains are the running chains of held take-ins, each branch's source being taken in, since when and how many wait
|
||||||
|
// (H-A-497 addendum).
|
||||||
|
Chains []HeldChain `json:"chains,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrHeldUnwritten says a source-moved that could not be taken in is not written into the state held either: its message
|
// ErrHeldUnwritten says a source-moved that could not be taken in is not written into the state held either: its message
|
||||||
@@ -167,26 +170,153 @@ func (ix *Indexer) unhold(ctx context.Context, branch string, source int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TakeHeldIn takes every branch's held source revisions in, each branch in its order, on the indexer's own room and at its
|
// TakeHeldIn takes every branch's held source revisions in, each branch in its order, on the indexer's own room, at its
|
||||||
// start (H-A-114, H-A-118): a branch stops at the first that still cannot be taken in, which stays held with those behind it.
|
// start and by hand (H-A-114, H-A-118): a branch stops at the first that still cannot be taken in, which stays held with those
|
||||||
|
// behind it. Once a held one is taken in, the next held of its branch is taken in at once, each such start said in the journal
|
||||||
|
// (design 47 H2 H-A-497).
|
||||||
func (ix *Indexer) TakeHeldIn(ctx context.Context) {
|
func (ix *Indexer) TakeHeldIn(ctx context.Context) {
|
||||||
all, err := ReadHeld(ctx, ix.Held)
|
all, err := ReadHeld(ctx, ix.Held)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ix.logf("take-in: the state %s is not read, so no held take-in is taken in again now: %v", HeldState, err)
|
ix.logf("take-in: the state %s is not read, so no held take-in is taken in again now: %v", HeldState, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stopped := map[string]bool{}
|
stopped, landed := map[string]bool{}, map[string]int64{}
|
||||||
|
behind := map[string]int{}
|
||||||
for _, h := range all {
|
for _, h := range all {
|
||||||
|
behind[h.Branch]++
|
||||||
|
}
|
||||||
|
for i, h := range all {
|
||||||
|
behind[h.Branch]--
|
||||||
if stopped[h.Branch] {
|
if stopped[h.Branch] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, err := ix.TakeInSource(ctx, h.Event()); err != nil {
|
if prev, ok := landed[h.Branch]; ok {
|
||||||
|
ix.logf("take-in: held source %d of %s taken in next, after %d (H-A-497)", h.Source, h.Branch, prev)
|
||||||
|
}
|
||||||
|
ix.writeChain(ctx, HeldChain{Branch: h.Branch, Source: h.Source, Since: ix.now().UTC(), Waiting: behind[h.Branch]})
|
||||||
|
if _, err := ix.TakeInSource(ctx, h.Event()); err == nil {
|
||||||
|
landed[h.Branch] = h.Source
|
||||||
|
} else {
|
||||||
ix.logf("take-in: source revision %d of %s is still held: %v", h.Source, h.Branch, err)
|
ix.logf("take-in: source revision %d of %s is still held: %v", h.Source, h.Branch, err)
|
||||||
stopped[h.Branch] = true
|
stopped[h.Branch] = true
|
||||||
}
|
}
|
||||||
|
// The chain of a branch ends at its first held again or its last held (H-A-497 addendum).
|
||||||
|
if stopped[h.Branch] || !slices.ContainsFunc(all[i+1:], func(n HeldTakeIn) bool { return n.Branch == h.Branch }) {
|
||||||
|
ix.endChain(ctx, h.Branch)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChainPrefix is the takeins keys of the chains of held take-ins: `chain.<branch>`, the branch escaped as a key's name is,
|
||||||
|
// holding the branch's chain while it runs (design 47 H2 H-A-497 and its addendum): written at each step, deleted at its end.
|
||||||
|
const ChainPrefix = "chain."
|
||||||
|
|
||||||
|
// ChainKey is the takeins key of branch's chain.
|
||||||
|
func ChainKey(branch string) string { return ChainPrefix + keys.EscapeName(branch) }
|
||||||
|
|
||||||
|
// HeldChain is a running chain of a branch's held take-ins (H-A-497 addendum): the source being taken in, since when, and
|
||||||
|
// how many held sources of the branch wait behind it.
|
||||||
|
type HeldChain struct {
|
||||||
|
Branch string `json:"branch"`
|
||||||
|
Source int64 `json:"source"`
|
||||||
|
Since time.Time `json:"since"`
|
||||||
|
Waiting int `json:"waiting"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// writeChain writes branch's chain at its step c into the state takeins; a failed write is said.
|
||||||
|
func (ix *Indexer) writeChain(ctx context.Context, c HeldChain) {
|
||||||
|
if ix.TakeIns == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data, err := json.Marshal(c)
|
||||||
|
if err == nil {
|
||||||
|
err = write(ctx, ix.TakeIns, ChainKey(c.Branch), func([]byte, bool) ([]byte, bool, error) { return data, false, nil })
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
ix.logf("take-in: the chain of %s at source revision %d is not written into %s: %v", c.Branch, c.Source, TakeInsState, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EndChain deletes branch's chain from the state takeins once the take-in its ask started returned, so a chain whose held
|
||||||
|
// sources another act took first is never left running.
|
||||||
|
func (ix *Indexer) EndChain(ctx context.Context, branch string) { ix.endChain(ctx, branch) }
|
||||||
|
|
||||||
|
// EndChains deletes every chain the state takeins holds, at the indexer's start (H-A-497 addendum): no chain runs before the
|
||||||
|
// start's take-in, so a key left by a stop between a chain's last take-in and its end would answer "a chain runs" for good.
|
||||||
|
func (ix *Indexer) EndChains(ctx context.Context) {
|
||||||
|
chains, err := ReadChains(ctx, ix.TakeIns)
|
||||||
|
if err != nil {
|
||||||
|
ix.logf("take-in: the chains in %s are not read, so none left by a stop is deleted: %v", TakeInsState, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, c := range chains {
|
||||||
|
ix.logf("take-in: the chain of %s at source revision %d, left by a stop, is deleted at the start", c.Branch, c.Source)
|
||||||
|
ix.endChain(ctx, c.Branch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// endChain deletes branch's chain from the state takeins.
|
||||||
|
func (ix *Indexer) endChain(ctx context.Context, branch string) {
|
||||||
|
if ix.TakeIns == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := write(ctx, ix.TakeIns, ChainKey(branch), func([]byte, bool) ([]byte, bool, error) { return nil, true, nil }); err != nil {
|
||||||
|
ix.logf("take-in: the chain of %s is not deleted from %s: %v", branch, TakeInsState, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartChain writes branch's chain at its first held source, before the chain is taken in beside the asks (H-A-497
|
||||||
|
// addendum), so an ask after it finds it running; it answers that chain.
|
||||||
|
func (ix *Indexer) StartChain(ctx context.Context, held []HeldTakeIn) HeldChain {
|
||||||
|
c := HeldChain{Branch: held[0].Branch, Source: held[0].Source, Since: ix.now().UTC(), Waiting: len(held) - 1}
|
||||||
|
ix.writeChain(ctx, c)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChainOf is branch's running chain in the state takeins, and whether one runs.
|
||||||
|
func (ix *Indexer) ChainOf(ctx context.Context, branch string) (HeldChain, bool, error) {
|
||||||
|
if ix.TakeIns == nil {
|
||||||
|
return HeldChain{}, false, nil
|
||||||
|
}
|
||||||
|
v, _, found, err := ix.TakeIns.Get(ctx, ChainKey(branch))
|
||||||
|
if err != nil || !found {
|
||||||
|
return HeldChain{}, false, err
|
||||||
|
}
|
||||||
|
var c HeldChain
|
||||||
|
if err := json.Unmarshal(v, &c); err != nil {
|
||||||
|
return HeldChain{}, false, fmt.Errorf("%s.%s: %w", TakeInsState, ChainKey(branch), err)
|
||||||
|
}
|
||||||
|
return c, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadChains are the running chains the state takeins holds (H-A-497 addendum), each branch's once.
|
||||||
|
func ReadChains(ctx context.Context, st Store) ([]HeldChain, error) {
|
||||||
|
if st == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
ks, err := st.Keys(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
slices.Sort(ks)
|
||||||
|
var out []HeldChain
|
||||||
|
for _, k := range ks {
|
||||||
|
if !strings.HasPrefix(k, ChainPrefix) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
v, _, found, err := st.Get(ctx, k)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var c HeldChain
|
||||||
|
if !found || json.Unmarshal(v, &c) != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
out = append(out, c)
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// SkipTakeIn ends a held source revision unwritten by hand (indexer_take_in_skip, §744): it says take-in.taken with no entries,
|
// SkipTakeIn ends a held source revision unwritten by hand (indexer_take_in_skip, §744): it says take-in.taken with no entries,
|
||||||
// skipped, by and why, and deletes the branch's held take-in; the caller acknowledges the source-moved.
|
// skipped, by and why, and deletes the branch's held take-in; the caller acknowledges the source-moved.
|
||||||
func (ix *Indexer) SkipTakeIn(ctx context.Context, e meshdelivery.SourceMovedEvent, by, why string) error {
|
func (ix *Indexer) SkipTakeIn(ctx context.Context, e meshdelivery.SourceMovedEvent, by, why string) error {
|
||||||
@@ -236,7 +366,7 @@ func HeldTools(held, takeIns Store, ask func(key string, value []byte) (TakeInAs
|
|||||||
{Name: PendingTool,
|
{Name: PendingTool,
|
||||||
Description: "Each watched branch's held take-in (design 47 H §744): the source revision of the gate's source-moved the indexer " +
|
Description: "Each watched branch's held take-in (design 47 H §744): the source revision of the gate's source-moved the indexer " +
|
||||||
"could not take in (the catalog store full, a read of the forge unanswered), why and since when, in order, each kept here once " +
|
"could not take in (the catalog store full, a read of the forge unanswered), why and since when, in order, each kept here once " +
|
||||||
"acknowledged and taken in again on the indexer's room and at its start; and each running take-in that waits over a minute on another part, its waiting-on (part, verb, since). indexer_take_in_pending takes it again now, indexer_take_in_skip ends it unwritten.",
|
"acknowledged and taken in again on the indexer's room and at its start; each running take-in that waits over a minute on another part, its waiting-on (part, verb, since); and each running chain of held take-ins, the source being taken in, since when and how many wait. indexer_take_in_pending takes it again now, indexer_take_in_skip ends it unwritten.",
|
||||||
Input: map[string]any{"type": "object", "properties": map[string]any{}},
|
Input: map[string]any{"type": "object", "properties": map[string]any{}},
|
||||||
Run: func(map[string]any) (any, error) {
|
Run: func(map[string]any) (any, error) {
|
||||||
h, err := ReadHeld(context.Background(), held)
|
h, err := ReadHeld(context.Background(), held)
|
||||||
@@ -244,11 +374,16 @@ func HeldTools(held, takeIns Store, ask func(key string, value []byte) (TakeInAs
|
|||||||
return PendingAnswer{Held: h}, err
|
return PendingAnswer{Held: h}, err
|
||||||
}
|
}
|
||||||
r, err := ReadRunning(context.Background(), takeIns)
|
r, err := ReadRunning(context.Background(), takeIns)
|
||||||
return PendingAnswer{Held: h, Running: r}, err
|
if err != nil {
|
||||||
|
return PendingAnswer{Held: h, Running: r}, err
|
||||||
|
}
|
||||||
|
c, err := ReadChains(context.Background(), takeIns)
|
||||||
|
return PendingAnswer{Held: h, Running: r, Chains: c}, err
|
||||||
}},
|
}},
|
||||||
{Name: TakeInPendingTool,
|
{Name: TakeInPendingTool,
|
||||||
Description: "Take a watched branch's held source-moved in again now (design 47 H §744), as the indexer's room would: " +
|
Description: "Take a watched branch's held source-moved in again now (design 47 H §744), as the indexer's room would: " +
|
||||||
"answers whether it was taken in. indexer_pending names the held branches.",
|
"the held sources are taken in in order beside the asks, and it answers at once that the chain started at a source and " +
|
||||||
|
"how many wait, or, while a chain runs, its state (design 47 H2 H-A-497). indexer_pending names the held branches and the running chains.",
|
||||||
Input: map[string]any{"type": "object", "required": []string{"branch"}, "properties": map[string]any{
|
Input: map[string]any{"type": "object", "required": []string{"branch"}, "properties": map[string]any{
|
||||||
"branch": map[string]any{"type": "string", "description": "the watched branch, as indexer_pending names it"},
|
"branch": map[string]any{"type": "string", "description": "the watched branch, as indexer_pending names it"},
|
||||||
"why": map[string]any{"type": "string", "description": "why it is taken again now"}}},
|
"why": map[string]any{"type": "string", "description": "why it is taken again now"}}},
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ func pinObject(key string) (string, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HeardPins applies one event of the seat mesh-pipeline-runner the indexer's durable consumers gave it (design 47 H §749): a
|
// HeardPins applies one event of the seat mesh-pipeline-runner the indexer's durable consumers gave it (design 47 H §749): a
|
||||||
// pipeline-started pins the revision it names under the record `pipeline.<pipeline>`, its pipeline-ended frees it and every
|
// pipeline-started pins the revision it names, and each revision its movers are kept at (design 47 H2 H-A-496), under the
|
||||||
// other revision the record pins (H-A-147). A body
|
// record `pipeline.<pipeline>`, its pipeline-ended frees it and every other revision the record pins (H-A-147). A body
|
||||||
// that is no such event, or names no revision, changes nothing; an error leaves the event unacknowledged, so the bus gives it
|
// that is no such event, or names no revision, changes nothing; an error leaves the event unacknowledged, so the bus gives it
|
||||||
// again; one applied twice changes nothing.
|
// again; one applied twice changes nothing.
|
||||||
func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarted, ended *runner.PipelineEnded) error {
|
func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarted, ended *runner.PipelineEnded) error {
|
||||||
@@ -83,7 +83,15 @@ func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarte
|
|||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case started != nil && started.Revision > 0 && started.Pipeline != "":
|
case started != nil && started.Revision > 0 && started.Pipeline != "":
|
||||||
if err := ix.pin(ctx, PinKey(started.Branch, started.Revision), PipelineRecord(started.Pipeline)); err != nil {
|
record := PipelineRecord(started.Pipeline)
|
||||||
|
if err := ix.pin(ctx, PinKey(started.Branch, started.Revision), record); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// Every revision the pipeline's movers are kept at is pinned under its record too, so no judge removes one it still
|
||||||
|
// reads (design 47 H2 H-A-496); the latest started's kept set is the pipeline's kept pins, so a kept revision the
|
||||||
|
// record pins that this started no longer names is freed (H-A-496 addendum). A kept revision is always newer than the
|
||||||
|
// pipeline's own (a re-pin of its own source, H-A-283), so its own revision and its validate base stay pinned.
|
||||||
|
if err := ix.pinKept(ctx, started.Branch, started.Revision, started.Kept, record); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// The reservations of the pipeline's revision settle at its start, if they gather (design 47 H2 §805, H-A-424 (1)).
|
// The reservations of the pipeline's revision settle at its start, if they gather (design 47 H2 §805, H-A-424 (1)).
|
||||||
@@ -105,9 +113,14 @@ func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// A pipeline that did not pass withdraws the reservations its revision holds (design 47 H2 §805, H-A-418 (1)).
|
// A pipeline that did not pass withdraws the reservations its revision holds of its own movers, never another open
|
||||||
|
// pipeline's at that revision (design 47 H2 §805, H-A-418 (1), H-A-479 second addendum).
|
||||||
if ended.Outcome != runner.PipelineEndedOutcomePassed {
|
if ended.Outcome != runner.PipelineEndedOutcomePassed {
|
||||||
if err := ix.Withdraw(ctx, ended.Branch, ended.Revision); err != nil {
|
movers := make([]string, 0, len(ended.Movers))
|
||||||
|
for _, m := range ended.Movers {
|
||||||
|
movers = append(movers, m.Module)
|
||||||
|
}
|
||||||
|
if err := ix.Withdraw(ctx, ended.Branch, ended.Revision, movers); err != nil {
|
||||||
return fmt.Errorf("the reservations of %s are not withdrawn: %w", BranchObject(ended.Branch, ended.Revision), err)
|
return fmt.Errorf("the reservations of %s are not withdrawn: %w", BranchObject(ended.Branch, ended.Revision), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,6 +237,41 @@ func (ix *Indexer) unpinElsewhere(ctx context.Context, record string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pinKept pins each of kept, the revisions a pipeline of branch at revision own keeps movers at, under record, and frees
|
||||||
|
// every revision newer than own the record pins that kept does not name (design 47 H2 H-A-496 and its addendum).
|
||||||
|
func (ix *Indexer) pinKept(ctx context.Context, branch string, own int64, kept []int64, record string) error {
|
||||||
|
for _, r := range kept {
|
||||||
|
if r <= 0 || r == own {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := ix.pin(ctx, PinKey(branch, r), record); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pinKeys, err := ix.Pins.Keys(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, k := range pinKeys {
|
||||||
|
b, r, ok := ParsePinKey(k)
|
||||||
|
if !ok || b != branch || r <= own || slices.Contains(kept, r) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
v, _, found, err := ix.Pins.Get(ctx, k)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var pv PinValue
|
||||||
|
if !found || json.Unmarshal(v, &pv) != nil || !slices.Contains(pv.Records, record) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err := ix.unpin(ctx, k, record); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// PipelineRecord is the record a pipeline pins its revision under: `pipeline.<branch>.<source>` (design 47 H §743, A-449a).
|
// PipelineRecord is the record a pipeline pins its revision under: `pipeline.<branch>.<source>` (design 47 H §743, A-449a).
|
||||||
func PipelineRecord(pipeline string) string { return "pipeline." + pipeline }
|
func PipelineRecord(pipeline string) string { return "pipeline." + pipeline }
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,47 @@ import (
|
|||||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Design 47 H2 H-A-496 and its addendum: a pipeline-started pins the pipeline's own revision and each revision its movers
|
||||||
|
// are kept at under the pipeline's record; a later started (said again at a re-pin) is the pipeline's kept set, freeing a
|
||||||
|
// kept revision it no longer names but never the pipeline's own; pipeline-ended frees them all.
|
||||||
|
func TestAPipelinesKeptRevisionsArePinnedUntilItEnds(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
pending := uint64(1) // the keeps judge nothing while the consumer is behind
|
||||||
|
ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20), Pins: newMem(), Findings: newFindings(),
|
||||||
|
Now: func() time.Time { return time.Date(2026, 11, 22, 20, 0, 0, 0, time.UTC) }, PinsPending: func(context.Context) (uint64, error) { return pending, nil }}
|
||||||
|
kept := func() []string {
|
||||||
|
n, _ := ix.Revisions.Names(ctx)
|
||||||
|
return slices.DeleteFunc(n, func(s string) bool { _, _, ok := RevisionGroup(s); return !ok })
|
||||||
|
}
|
||||||
|
reader := meshcatalog.CatalogEntry{Module: "reader", Repository: "novox/r", Manifest: map[string]any{}}
|
||||||
|
for source := int64(1); source <= 6; source++ {
|
||||||
|
e := reader
|
||||||
|
e.Commit = fmt.Sprintf("c%d", source)
|
||||||
|
if err := ix.KeepBranchEntries(ctx, "main", source, map[string]meshcatalog.CatalogEntry{"reader": e}, nil); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pending = 0
|
||||||
|
heard := func(started *runner.PipelineStarted, ended *runner.PipelineEnded, want ...string) {
|
||||||
|
t.Helper()
|
||||||
|
if err := ix.HeardPins(ctx, started, ended); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
ix.JudgePins(ctx)
|
||||||
|
if got := kept(); !slices.Equal(got, want) {
|
||||||
|
t.Errorf("kept %v, want %v", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
heard(&runner.PipelineStarted{Branch: "main", Pipeline: "main.1", Revision: 1, Kept: []int64{2, 3, 4}}, nil,
|
||||||
|
"main.1", "main.2", "main.3", "main.4", "main.6")
|
||||||
|
if v, _, _, _ := ix.Pins.Get(ctx, "main.3"); !slices.Equal(mustRecords(t, v), []string{"pipeline.main.1"}) {
|
||||||
|
t.Errorf("the pin of main.3 holds %s, want the pipeline's record", v)
|
||||||
|
}
|
||||||
|
heard(&runner.PipelineStarted{Branch: "main", Pipeline: "main.1", Revision: 1, Kept: []int64{3, 4}}, nil,
|
||||||
|
"main.1", "main.3", "main.4", "main.6")
|
||||||
|
heard(nil, &runner.PipelineEnded{Branch: "main", Pipeline: "main.1", Revision: 1, Outcome: runner.PipelineEndedOutcomeFailed}, "main.6")
|
||||||
|
}
|
||||||
|
|
||||||
// Design 47 H §749 (G §579, A-169, A-171): the indexer pins a revision on a pipeline-started that names it and frees it on its
|
// Design 47 H §749 (G §579, A-169, A-171): the indexer pins a revision on a pipeline-started that names it and frees it on its
|
||||||
// pipeline-ended, counts a record once, and removes a revision only while its consumers are caught up, judged against the pins
|
// pipeline-ended, counts a record once, and removes a revision only while its consumers are caught up, judged against the pins
|
||||||
// its own state holds, never a count of pins stated: one two pipelines pin stays until both free it, one neither pinned nor
|
// its own state holds, never a count of pins stated: one two pipelines pin stays until both free it, one neither pinned nor
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package index
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -100,9 +101,10 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
|
|||||||
t.Errorf("said %+v, want catalog-revision of each branch with the release's call", said)
|
t.Errorf("said %+v, want catalog-revision of each branch with the release's call", said)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Design 47 H2 §805, H-A-418, H-A-420, H-A-424, H-A-436: a pipeline reserving twenty packages of mesh-sdk in main's
|
// Design 47 H2 H-A-495 (ending H-A-418 (2), H-A-424 (4)), H-A-436: a pin names only a released version. A pipeline
|
||||||
// revision 2 keeps one re-pin revision of main when its gathering settles, at its first step-ended; its release then
|
// reserving twenty packages of mesh-sdk in main's revision 2 moves no pin when its gathering settles; the release of
|
||||||
// keeps none on main, and a pipeline that did not pass withdraws its reservations back to the newest released version.
|
// the reserved version re-pins g in one revision; a pipeline that did not pass withdraws its reservations and moves
|
||||||
|
// nothing; and a pin held on a version never released is moved to the newest released at the next re-pin, said.
|
||||||
ix.Files = func(_ context.Context, _, _ string, dirs []string) (map[string]map[string]string, error) {
|
ix.Files = func(_ context.Context, _, _ string, dirs []string) (map[string]map[string]string, error) {
|
||||||
out := map[string]map[string]string{}
|
out := map[string]map[string]string{}
|
||||||
for _, d := range dirs {
|
for _, d := range dirs {
|
||||||
@@ -110,6 +112,8 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
var lines []string
|
||||||
|
ix.Logf = func(format string, args ...any) { lines = append(lines, fmt.Sprintf(format, args...)) }
|
||||||
heard := newMem()
|
heard := newMem()
|
||||||
ix.Heard = heard
|
ix.Heard = heard
|
||||||
revision := BranchObject("main", 2)
|
revision := BranchObject("main", 2)
|
||||||
@@ -120,6 +124,7 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return rev.Revision
|
return rev.Revision
|
||||||
}
|
}
|
||||||
|
const sdkGo = "git.novox.be/novox/mesh-sdk/go"
|
||||||
for i := range 20 {
|
for i := range 20 {
|
||||||
e := meshbuilds.VersionReservedEvent{Module: "mesh-sdk", Artifact: fmt.Sprintf("mesh-sdk:p%d", i), Path: "mesh-sdk/go", Version: "0.1.28", Revision: revision}
|
e := meshbuilds.VersionReservedEvent{Module: "mesh-sdk", Artifact: fmt.Sprintf("mesh-sdk:p%d", i), Path: "mesh-sdk/go", Version: "0.1.28", Revision: revision}
|
||||||
if err := ix.HearVersionReserved(ctx, e); err != nil {
|
if err := ix.HearVersionReserved(ctx, e); err != nil {
|
||||||
@@ -129,35 +134,82 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
|
|||||||
if _, _, open, _ := heard.Get(ctx, SettlingKey(revision)); !open || newest() != 2 {
|
if _, _, open, _ := heard.Get(ctx, SettlingKey(revision)); !open || newest() != 2 {
|
||||||
t.Fatalf("twenty reservations: gathering open %v, main's newest %d, want open and no revision kept before it settles", open, newest())
|
t.Fatalf("twenty reservations: gathering open %v, main's newest %d, want open and no revision kept before it settles", open, newest())
|
||||||
}
|
}
|
||||||
if err := ix.Settle(ctx, revision); err != nil || newest() != 3 {
|
if err := ix.Settle(ctx, revision); err != nil || newest() != 2 {
|
||||||
t.Fatalf("the gathering settled (%v) keeping main's newest %d, want one re-pin revision, 3", err, newest())
|
t.Fatalf("the gathering settled (%v) keeping main's newest %d, want still 2: a reservation moves no pin", err, newest())
|
||||||
}
|
}
|
||||||
if now, _ := moduleOf(t, mods, "g"); now.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.28" {
|
if now, _ := moduleOf(t, mods, "g"); now.Packages[sdkGo] != "v0.1.27" {
|
||||||
t.Errorf("g after the reservations is pinned %v, want v0.1.28", now.Packages)
|
t.Errorf("g after the reservations is pinned %v, want the released v0.1.27", now.Packages)
|
||||||
}
|
}
|
||||||
if err := ix.Settle(ctx, revision); err != nil || newest() != 3 {
|
if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", GoModule: sdkGo, Version: "0.1.28", Commit: strings.Repeat("1", 40), Published: true}); err != nil {
|
||||||
t.Errorf("a second step-ended settled (%v) keeping main's newest %d, want still 3", err, newest())
|
|
||||||
}
|
|
||||||
if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", GoModule: "git.novox.be/novox/mesh-sdk/go", Version: "0.1.28", Commit: strings.Repeat("1", 40), Published: true}); err != nil {
|
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if _, err := ix.Repin(ctx, "mesh-sdk", "0.1.28"); err != nil || newest() != 3 {
|
if _, err := ix.Repin(ctx, "mesh-sdk", "0.1.28"); err != nil || newest() != 3 {
|
||||||
t.Errorf("the release of the reserved 0.1.28 re-pinned (%v) keeping main's newest %d, want no revision more", err, newest())
|
t.Errorf("the release of the reserved 0.1.28 re-pinned (%v) keeping main's newest %d, want one revision more, 3", err, newest())
|
||||||
|
}
|
||||||
|
if now, _ := moduleOf(t, mods, "g"); now.Packages[sdkGo] != "v0.1.28" {
|
||||||
|
t.Errorf("g after the release is pinned %v, want v0.1.28", now.Packages)
|
||||||
}
|
}
|
||||||
next := BranchObject("main", 3)
|
next := BranchObject("main", 3)
|
||||||
if err := ix.HearVersionReserved(ctx, meshbuilds.VersionReservedEvent{Module: "mesh-sdk", Artifact: "mesh-sdk:p0", Path: "mesh-sdk/go", Version: "0.1.29", Revision: next}); err != nil {
|
if err := ix.HearVersionReserved(ctx, meshbuilds.VersionReservedEvent{Module: "mesh-sdk", Artifact: "mesh-sdk:p0", Path: "mesh-sdk/go", Version: "0.1.29", Revision: next}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := ix.Settle(ctx, next); err != nil || newest() != 4 {
|
if err := ix.Settle(ctx, next); err != nil || newest() != 3 {
|
||||||
t.Fatalf("the reservation of 0.1.29 settled (%v) keeping main's newest %d, want 4", err, newest())
|
t.Fatalf("the reservation of 0.1.29 settled (%v) keeping main's newest %d, want still 3", err, newest())
|
||||||
}
|
}
|
||||||
if err := ix.Withdraw(ctx, "main", 3); err != nil || newest() != 5 {
|
// H-A-479 second addendum: a pipeline at the same revision whose movers are others withdraws none of mesh-sdk's.
|
||||||
t.Fatalf("the withdrawal (%v) kept main's newest %d, want 5", err, newest())
|
if err := ix.Withdraw(ctx, "main", 3, []string{"app"}); err != nil || newest() != 3 {
|
||||||
|
t.Fatalf("another pipeline's withdrawal (%v) kept main's newest %d, want 3: nothing of mesh-sdk withdrawn", err, newest())
|
||||||
}
|
}
|
||||||
if now, _ := moduleOf(t, mods, "g"); now.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.28" {
|
if _, _, kept, _ := heard.Get(ctx, ReservedKey(next, "mesh-sdk")); !kept {
|
||||||
|
t.Fatalf("another pipeline's withdrawal took mesh-sdk's reservation")
|
||||||
|
}
|
||||||
|
if err := ix.Withdraw(ctx, "main", 3, []string{"mesh-sdk"}); err != nil || newest() != 3 {
|
||||||
|
t.Fatalf("the withdrawal (%v) kept main's newest %d, want 3: the withdrawn reservation pinned nothing", err, newest())
|
||||||
|
}
|
||||||
|
if now, _ := moduleOf(t, mods, "g"); now.Packages[sdkGo] != "v0.1.28" {
|
||||||
t.Errorf("g after the withdrawal is pinned %v, want the newest released v0.1.28", now.Packages)
|
t.Errorf("g after the withdrawal is pinned %v, want the newest released v0.1.28", now.Packages)
|
||||||
}
|
}
|
||||||
if _, _, kept, _ := heard.Get(ctx, ReservedKey(next, "mesh-sdk")); kept {
|
if _, _, kept, _ := heard.Get(ctx, ReservedKey(next, "mesh-sdk")); kept {
|
||||||
t.Errorf("the withdrawn reservation is still kept")
|
t.Errorf("the withdrawn reservation is still kept")
|
||||||
}
|
}
|
||||||
|
stale, _ := moduleOf(t, mods, "g")
|
||||||
|
stale.Packages = map[string]string{sdkGo: "v0.1.29"} // pinned before H-A-495 to the withdrawn reservation
|
||||||
|
mods.put("g", mustEncode(t, stale))
|
||||||
|
lines = nil
|
||||||
|
if _, err := ix.Repin(ctx, "mesh-sdk", "0.1.28"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if now, _ := moduleOf(t, mods, "g"); now.Packages[sdkGo] != "v0.1.28" {
|
||||||
|
t.Errorf("g pinned to the never released v0.1.29 is pinned %v after a re-pin, want v0.1.28", now.Packages)
|
||||||
|
}
|
||||||
|
if said := "g: pinned to " + sdkGo + " v0.1.29, never released; moved to v0.1.28"; !slices.Contains(lines, said) {
|
||||||
|
t.Errorf("the re-pin said %q, want the line %q", lines, said)
|
||||||
|
}
|
||||||
|
// H-A-479 second addendum: two pipelines' movers reserve at one revision while its gathering is open; withdrawing one
|
||||||
|
// pipeline's mover keeps the gathering and the other's reservation, withdrawing the last removes the gathering too.
|
||||||
|
six := BranchObject("main", 6)
|
||||||
|
for _, m := range []string{"one", "two"} {
|
||||||
|
raw, _ := json.Marshal(Reserved{V: 1, Revision: six, Module: m})
|
||||||
|
if err := heard.Create(ctx, ReservedKey(six, m), raw); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := heard.Create(ctx, SettlingKey(six), []byte(`{}`)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ix.Withdraw(ctx, "main", 6, []string{"one"}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
_, _, gathering, _ := heard.Get(ctx, SettlingKey(six))
|
||||||
|
_, _, one, _ := heard.Get(ctx, ReservedKey(six, "one"))
|
||||||
|
_, _, two, _ := heard.Get(ctx, ReservedKey(six, "two"))
|
||||||
|
if !gathering || one || !two {
|
||||||
|
t.Fatalf("withdrawing one: gathering %v, one kept %v, two kept %v; want the gathering and two kept, one gone", gathering, one, two)
|
||||||
|
}
|
||||||
|
if err := ix.Withdraw(ctx, "main", 6, []string{"two"}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, _, gathering, _ := heard.Get(ctx, SettlingKey(six)); gathering {
|
||||||
|
t.Error("withdrawing the last reservation kept the revision's gathering")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,13 @@ import (
|
|||||||
|
|
||||||
// A release re-pins once, at its reservation (design 47 H2 §805; H-A-418, H-A-420, H-A-424). The builder says
|
// A release re-pins once, at its reservation (design 47 H2 §805; H-A-418, H-A-420, H-A-424). The builder says
|
||||||
// version-reserved when it reserves a package's number, naming the revision `<branch>.<n>` its pipeline runs. The indexer
|
// version-reserved when it reserves a package's number, naming the revision `<branch>.<n>` its pipeline runs. The indexer
|
||||||
// writes the series' numbered version with the contents read at the commit of the module's entry in that revision, so
|
// writes the series' numbered version with the contents read at the commit of the module's entry in that revision, and
|
||||||
// acceptedSeries and releasedPins pin it, and keeps the reservation in its state heard under
|
// keeps the reservation in its state heard under
|
||||||
// `reserved.<revision>.<module>`, each key living reserved-keep. It gathers a pipeline's reservations per revision and
|
// `reserved.<revision>.<module>`, each key living reserved-keep. It gathers a pipeline's reservations per revision and
|
||||||
// writes one re-pin revision of that revision's branch when the gathering settles: at the first pipeline-started or
|
// writes one re-pin revision of that revision's branch when the gathering settles: at the first pipeline-started or
|
||||||
// step-ended of that pipeline heard after them, or at the expiry of the key settling.<revision>, written reserved-settle
|
// step-ended of that pipeline heard after them, or at the expiry of the key settling.<revision>, written reserved-settle
|
||||||
// after the first. The release's package-published then
|
// after the first. A pin names only a released version, never a reservation (design 47 H2 H-A-495), so that re-pin
|
||||||
// moves no fingerprint. A pipeline-ended not passed whose revision holds reservations withdraws them: the series'
|
// moves no pin, and the release's re-pin (H-A-165) moves the importers. A pipeline-ended not passed whose revision holds reservations withdraws them: the series'
|
||||||
// numbered goes back to its newest released version and the importers are re-pinned to it.
|
// numbered goes back to its newest released version and the importers are re-pinned to it.
|
||||||
|
|
||||||
// ReservedPrefix begins every key of the state heard holding a revision's reservations of one module.
|
// ReservedPrefix begins every key of the state heard holding a revision's reservations of one module.
|
||||||
@@ -350,20 +350,35 @@ func (ix *Indexer) settleNow(ctx context.Context, revision string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Withdraw takes a pipeline-ended not passed of branch's revision in: each reservation the revision holds is withdrawn, its
|
// Withdraw takes a pipeline-ended not passed of branch's revision in: each reservation the revision holds of one of the
|
||||||
// series' numbered set back to the newest released version, its importers re-pinned to that, and its key deleted.
|
// ended pipeline's own movers is withdrawn, its series' numbered set back to the newest released version, its importers
|
||||||
func (ix *Indexer) Withdraw(ctx context.Context, branch string, revision int64) error {
|
// re-pinned to that, and its key deleted. Another open pipeline's reservations at the same revision are kept, and the
|
||||||
|
// revision's gathering is withdrawn only when none of them is left (design 47 H2 H-A-479 second addendum).
|
||||||
|
func (ix *Indexer) Withdraw(ctx context.Context, branch string, revision int64, movers []string) error {
|
||||||
if ix.Heard == nil {
|
if ix.Heard == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
name := BranchObject(branch, revision)
|
name := BranchObject(branch, revision)
|
||||||
if _, rev, found, err := ix.Heard.Get(ctx, SettlingKey(name)); err == nil && found {
|
all, revs, err := ix.reservedOf(ctx, name)
|
||||||
_ = ix.Heard.Delete(ctx, SettlingKey(name), rev) // the gathering is withdrawn with it
|
if err != nil {
|
||||||
}
|
|
||||||
held, revs, err := ix.reservedOf(ctx, name)
|
|
||||||
if err != nil || len(held) == 0 {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
held := map[string]Reserved{}
|
||||||
|
for key, r := range all {
|
||||||
|
if slices.Contains(movers, r.Module) {
|
||||||
|
held[key] = r
|
||||||
|
} else {
|
||||||
|
delete(revs, key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(held) == len(all) {
|
||||||
|
if _, rev, found, err := ix.Heard.Get(ctx, SettlingKey(name)); err == nil && found {
|
||||||
|
_ = ix.Heard.Delete(ctx, SettlingKey(name), rev) // the gathering is withdrawn with it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(held) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
for _, r := range held {
|
for _, r := range held {
|
||||||
for _, one := range r.Reservations {
|
for _, one := range r.Reservations {
|
||||||
if err := ix.withdrawNumbered(ctx, one); err != nil {
|
if err := ix.withdrawNumbered(ctx, one); err != nil {
|
||||||
|
|||||||
@@ -198,14 +198,10 @@ func acceptedSeries(series map[string]SeriesPackage, m catalogue.Manifest, repos
|
|||||||
return out, pins
|
return out, pins
|
||||||
}
|
}
|
||||||
|
|
||||||
// pinnedVersion is the version of a series its users are pinned to: its numbered one when a reservation wrote it with its
|
// pinnedVersion is the version of a series its users are pinned to: its newest released one, never a reservation's
|
||||||
// contents and it is newer than the newest released (design 47 H2 §805, H-A-418 (2), H-A-424 (4)), else the newest; nil
|
// numbered one, which a pipeline that does not pass withdraws unpublished (design 47 H2 H-A-495, which ends H-A-418 (2)
|
||||||
// for none.
|
// and H-A-424 (4)); nil for none.
|
||||||
func pinnedVersion(s SeriesPackage) *SeriesVersion {
|
func pinnedVersion(s SeriesPackage) *SeriesVersion {
|
||||||
if n := s.Numbered; n != nil && n.Contents != nil && (s.Newest == nil || CompareVersions("v"+s.Newest.Version, "v"+n.Version) < 0) {
|
|
||||||
p := publishedOfNumbered(*n.Contents)
|
|
||||||
return &SeriesVersion{Version: n.Version, Commit: n.Commit, Digest: n.Digest, Fingerprint: n.Fingerprint, Contents: contentsOfPublished(p)}
|
|
||||||
}
|
|
||||||
return s.Newest
|
return s.Newest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -371,11 +371,35 @@ func TestATakeInOnAFullStoreIsHeldAndSaidOnce(t *testing.T) {
|
|||||||
len(held[0].Heads) != 1 || held[0].Heads[0] != moved.Heads[0] || !reflect.DeepEqual(held[0].Event(), moved) {
|
len(held[0].Heads) != 1 || held[0].Heads[0] != moved.Heads[0] || !reflect.DeepEqual(held[0].Event(), moved) {
|
||||||
t.Fatalf("held = %+v, want 3 then 4, each with its event whole", held)
|
t.Fatalf("held = %+v, want 3 then 4, each with its event whole", held)
|
||||||
}
|
}
|
||||||
|
// H-A-497: behind them a source whose head the forge does not answer, and one more behind it.
|
||||||
|
for _, n := range []struct {
|
||||||
|
source int64
|
||||||
|
commit string
|
||||||
|
}{{5, "c-unread"}, {6, f.Merge}} {
|
||||||
|
e := moved
|
||||||
|
e.Source, e.Call, e.Heads = n.source, fmt.Sprintf("%d123456789abcdef", n.source), []meshdelivery.SourceMovedEventHeadsItem{{Repository: f.Repository, Commit: n.commit}}
|
||||||
|
if behind, err := ix.HoldBehind(ctx, e); err != nil || !behind {
|
||||||
|
t.Fatalf("source %d held behind: %v (%v)", n.source, behind, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var lines []string
|
||||||
|
ix.Logf = func(format string, args ...any) { lines = append(lines, fmt.Sprintf(format, args...)) }
|
||||||
|
ix.TakeIns = newMem()
|
||||||
|
// H-A-497 addendum: while the chain runs, its key names the source being taken in and how many wait behind it.
|
||||||
|
var steps []string
|
||||||
|
read := ix.Read
|
||||||
|
ix.Read = func(ctx context.Context, repository, sha, dir string) (RepoRead, error) {
|
||||||
|
if c, ok, _ := ix.ChainOf(ctx, "main"); ok {
|
||||||
|
steps = append(steps, fmt.Sprintf("%d/%d", c.Source, c.Waiting))
|
||||||
|
}
|
||||||
|
return read(ctx, repository, sha, dir)
|
||||||
|
}
|
||||||
objects.capacity = 1 << 22
|
objects.capacity = 1 << 22
|
||||||
if ok, err := ix.RoomAgain(ctx); err != nil || !ok || rooms != 1 {
|
if ok, err := ix.RoomAgain(ctx); err != nil || !ok || rooms != 1 {
|
||||||
t.Fatalf("room said %v %d times (%v), want once the store has room", ok, rooms, err)
|
t.Fatalf("room said %v %d times (%v), want once the store has room", ok, rooms, err)
|
||||||
}
|
}
|
||||||
// H-A-114: on room (and at start) the held ones are taken in again from the state held alone, in their order.
|
// H-A-114, H-A-497: on room (and at start, and by hand) the held ones are taken in again from the state held alone, in
|
||||||
|
// their order, each next one at once and said in the journal, until one is held again: those behind it stay held.
|
||||||
ix.TakeHeldIn(ctx)
|
ix.TakeHeldIn(ctx)
|
||||||
var taken []int64
|
var taken []int64
|
||||||
for _, e := range *said {
|
for _, e := range *said {
|
||||||
@@ -386,8 +410,38 @@ func TestATakeInOnAFullStoreIsHeldAndSaidOnce(t *testing.T) {
|
|||||||
if !reflect.DeepEqual(taken, []int64{3, 4}) {
|
if !reflect.DeepEqual(taken, []int64{3, 4}) {
|
||||||
t.Errorf("taken again on room: %v of %+v, want 3 then 4", taken, *said)
|
t.Errorf("taken again on room: %v of %+v, want 3 then 4", taken, *said)
|
||||||
}
|
}
|
||||||
if held, _ := ReadHeld(ctx, ix.Held); len(held) != 0 {
|
if held, _ := ReadHeld(ctx, ix.Held); len(held) != 2 || held[0].Source != 5 || held[1].Source != 6 {
|
||||||
t.Errorf("held = %+v after the take-in, want none", held)
|
t.Errorf("held = %+v after the take-in, want 5 held again and 6 behind it", held)
|
||||||
|
}
|
||||||
|
for _, want := range []string{
|
||||||
|
"take-in: held source 4 of main taken in next, after 3 (H-A-497)",
|
||||||
|
"take-in: held source 5 of main taken in next, after 4 (H-A-497)",
|
||||||
|
} {
|
||||||
|
if !slices.Contains(lines, want) {
|
||||||
|
t.Errorf("the journal holds no line %q: %q", want, lines)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, l := range lines {
|
||||||
|
if strings.Contains(l, "held source 6 of main taken in") {
|
||||||
|
t.Errorf("source 6 was taken in behind a held one: %q", l)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !slices.Contains(steps, "4/2") || !slices.Contains(steps, "5/1") {
|
||||||
|
t.Errorf("the chain's key read at each take-in %v, want main at 4 with 2 waiting and at 5 with 1", steps)
|
||||||
|
}
|
||||||
|
// H-A-497 addendum: the chain's key in the state takeins goes at its end, here its first held again, and one a stop
|
||||||
|
// left is deleted at the start.
|
||||||
|
if chains, err := ReadChains(ctx, ix.TakeIns); err != nil || len(chains) != 0 {
|
||||||
|
t.Errorf("chains %+v (%v) after the chain stopped, want none", chains, err)
|
||||||
|
}
|
||||||
|
ix.writeChain(ctx, HeldChain{Branch: "main", Source: 9, Waiting: 1})
|
||||||
|
if ix.EndChains(ctx); func() bool { c, _ := ReadChains(ctx, ix.TakeIns); return len(c) != 0 }() {
|
||||||
|
t.Error("a chain's key left by a stop stays after the start")
|
||||||
|
}
|
||||||
|
ix.Read = read
|
||||||
|
ix.Logf, ix.TakeIns = nil, nil
|
||||||
|
for _, src := range []int64{5, 6} {
|
||||||
|
ix.unhold(ctx, "main", src)
|
||||||
}
|
}
|
||||||
// A skip ends a held source revision unwritten: take-in.taken with no entries, skipped, by and why; held is deleted.
|
// A skip ends a held source revision unwritten: take-in.taken with no entries, skipped, by and why; held is deleted.
|
||||||
ix.hold(ctx, meshdelivery.SourceMovedEvent{Branch: "nox-mesh", Source: 9, Call: "fedcba9876543210"}, "the catalog store is full")
|
ix.hold(ctx, meshdelivery.SourceMovedEvent{Branch: "nox-mesh", Source: 9, Call: "fedcba9876543210"}, "the catalog store is full")
|
||||||
|
|||||||
@@ -236,6 +236,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc
|
|||||||
fp, none string
|
fp, none string
|
||||||
tcs map[string]meshcatalog.ToolchainUsed // by language, when there is a fingerprint
|
tcs map[string]meshcatalog.ToolchainUsed // by language, when there is a fingerprint
|
||||||
pkgs sdkstep.PackageVersions // the package versions, when there is a fingerprint
|
pkgs sdkstep.PackageVersions // the package versions, when there is a fingerprint
|
||||||
|
moved []string // the pins moved off a version never released, said (H-A-495)
|
||||||
}
|
}
|
||||||
done := map[string]result{}
|
done := map[string]result{}
|
||||||
visiting := map[string]bool{}
|
visiting := map[string]bool{}
|
||||||
@@ -313,6 +314,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc
|
|||||||
// a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167)
|
// a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167)
|
||||||
r.fp, r.pkgs = pinnedOf(f, series, k.manifest, k.cur.Repository, kept.Packages)
|
r.fp, r.pkgs = pinnedOf(f, series, k.manifest, k.cur.Repository, kept.Packages)
|
||||||
r.tcs = toolchainsUsed(toolchains)
|
r.tcs = toolchainsUsed(toolchains)
|
||||||
|
r.moved = neverReleased(module, k.held.Packages, r.pkgs, series, k.manifest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, merged := overlay[module]; !merged && (repository != "" && !trunk.SameRepository(k.cur.Repository, repository) &&
|
if _, merged := overlay[module]; !merged && (repository != "" && !trunk.SameRepository(k.cur.Repository, repository) &&
|
||||||
@@ -325,6 +327,9 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc
|
|||||||
}
|
}
|
||||||
done[module] = r
|
done[module] = r
|
||||||
k.cur.Inputs2 = &kept
|
k.cur.Inputs2 = &kept
|
||||||
|
for _, line := range r.moved {
|
||||||
|
ix.logf("%s", line)
|
||||||
|
}
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
finals := map[string]meshcatalog.ModulesByModuleValue{}
|
finals := map[string]meshcatalog.ModulesByModuleValue{}
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ func (ix *Indexer) HearPackagePublished(ctx context.Context, p meshbuilds.Packag
|
|||||||
}
|
}
|
||||||
var want []string
|
var want []string
|
||||||
for _, a := range entry.Artifacts {
|
for _, a := range entry.Artifacts {
|
||||||
want = append(want, a.Ref)
|
if a.Kind != catalogue.ArtifactUpstream { // an upstream copy is released by its pinned digest, never published (H-A-486)
|
||||||
|
want = append(want, a.Ref)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
key := PendingPrefix + keys.EscapeName(p.Module) + "." + keys.EscapeName(p.Version)
|
key := PendingPrefix + keys.EscapeName(p.Module) + "." + keys.EscapeName(p.Version)
|
||||||
var have published
|
var have published
|
||||||
@@ -211,7 +213,15 @@ func (ix *Indexer) releaseVersion(ctx context.Context, p meshbuilds.PackagePubli
|
|||||||
late := len(kept) > 0 && compareVersions(kept[0].Version, p.Version) > 0
|
late := len(kept) > 0 && compareVersions(kept[0].Version, p.Version) > 0
|
||||||
at := ix.now().UTC()
|
at := ix.now().UTC()
|
||||||
v := meshcatalog.VersionEntry{V: int64(keys.Version), Module: p.Module, Version: p.Version, Source: have.Source, At: &at, Late: late}
|
v := meshcatalog.VersionEntry{V: int64(keys.Version), Module: p.Module, Version: p.Version, Source: have.Source, At: &at, Late: late}
|
||||||
|
pins, err := upstreamPins(entry)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
for _, a := range entry.Artifacts {
|
for _, a := range entry.Artifacts {
|
||||||
|
if a.Kind == catalogue.ArtifactUpstream {
|
||||||
|
v.Artifacts = append(v.Artifacts, meshcatalog.VersionArtifact{Artifact: a.Ref, Digest: pins[a.Ref]})
|
||||||
|
continue
|
||||||
|
}
|
||||||
v.Artifacts = append(v.Artifacts, have.Artifacts[a.Ref])
|
v.Artifacts = append(v.Artifacts, have.Artifacts[a.Ref])
|
||||||
}
|
}
|
||||||
slices.SortFunc(v.Artifacts, func(a, b meshcatalog.VersionArtifact) int { return strings.Compare(a.Artifact, b.Artifact) })
|
slices.SortFunc(v.Artifacts, func(a, b meshcatalog.VersionArtifact) int { return strings.Compare(a.Artifact, b.Artifact) })
|
||||||
@@ -255,6 +265,46 @@ func (ix *Indexer) releaseVersion(ctx context.Context, p meshbuilds.PackagePubli
|
|||||||
return ix.forgetPublished(ctx, pendingKey)
|
return ix.forgetPublished(ctx, pendingKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// upstreamPins are the pinned digests of the entry's upstream artifacts, by reference, read from its manifest's from
|
||||||
|
// (`<image>@sha256:<digest>`): design 51 copies an upstream image by that digest, so a release names it (H-A-486). An upstream
|
||||||
|
// artifact whose manifest names no pin refuses the release, naming it.
|
||||||
|
func upstreamPins(entry meshcatalog.CatalogEntry) (map[string]string, error) {
|
||||||
|
out := map[string]string{}
|
||||||
|
if !slices.ContainsFunc(entry.Artifacts, func(a meshcatalog.Artifact) bool { return a.Kind == catalogue.ArtifactUpstream }) {
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
raw, err := json.Marshal(entry.Manifest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var m struct {
|
||||||
|
Build struct {
|
||||||
|
Artifacts []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
From string `json:"from"`
|
||||||
|
} `json:"artifacts"`
|
||||||
|
} `json:"build"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(raw, &m); err != nil {
|
||||||
|
return nil, fmt.Errorf("the manifest of %s's entry does not read, so its upstream artifacts' pins are not known: %w", entry.Module, err)
|
||||||
|
}
|
||||||
|
for _, a := range m.Build.Artifacts {
|
||||||
|
if a.Kind != catalogue.ArtifactUpstream {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, d, ok := strings.Cut(a.From, "@"); ok && strings.HasPrefix(d, "sha256:") {
|
||||||
|
out[ArtifactRefOf(entry.Module, a.Name)] = d
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, a := range entry.Artifacts {
|
||||||
|
if _, ok := out[a.Ref]; a.Kind == catalogue.ArtifactUpstream && !ok {
|
||||||
|
return nil, fmt.Errorf("%s is an upstream artifact whose manifest names no pinned digest (from <image>@sha256:<digest>), so %s releases no version", a.Ref, entry.Module)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// trimVersions deletes the module's oldest versions beyond the kept 100, never its highest of any MAJOR.MINOR.
|
// trimVersions deletes the module's oldest versions beyond the kept 100, never its highest of any MAJOR.MINOR.
|
||||||
func (ix *Indexer) trimVersions(ctx context.Context, module string) error {
|
func (ix *Indexer) trimVersions(ctx context.Context, module string) error {
|
||||||
kept, err := ModuleVersions(ctx, ix.Versions, module) // newest first
|
kept, err := ModuleVersions(ctx, ix.Versions, module) // newest first
|
||||||
@@ -423,6 +473,29 @@ func pinnedOf(f form, series map[string]SeriesPackage, m catalogue.Manifest, rep
|
|||||||
return fingerprint.WithPins(f.fp, pins), pins
|
return fingerprint.WithPins(f.fp, pins), pins
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// neverReleased are the lines said of a module whose held pins (was) name a version above its series' newest released one,
|
||||||
|
// a reservation withdrawn unpublished, and whose new pins move it (design 47 H2 H-A-495): "<module>: pinned to <package>
|
||||||
|
// <version>, never released; moved to <version>". nil for none.
|
||||||
|
func neverReleased(module string, was map[string]string, pins sdkstep.PackageVersions, series map[string]SeriesPackage, m catalogue.Manifest) []string {
|
||||||
|
var out []string
|
||||||
|
for _, p := range slices.Sorted(maps.Keys(was)) {
|
||||||
|
old, now := strings.TrimPrefix(was[p], "v"), pins[p]
|
||||||
|
if _, ok := versionParts(old); !ok || was[p] == now {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, s := range series {
|
||||||
|
if s.GoModule != p || s.Newest == nil || s.Series != m.AcceptedSeries(s.Name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if in, _ := SeriesOf(old); in == s.Series && compareVersions(old, strings.TrimPrefix(s.Newest.Version, "v")) > 0 {
|
||||||
|
out = append(out, fmt.Sprintf("%s: pinned to %s %s, never released; moved to %s", module, p, was[p], cmp.Or(now, "no version")))
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// moduleOfKey is the module a modules key names; "" for none.
|
// moduleOfKey is the module a modules key names; "" for none.
|
||||||
func moduleOfKey(key string) string {
|
func moduleOfKey(key string) string {
|
||||||
if key == "" {
|
if key == "" {
|
||||||
|
|||||||
@@ -83,6 +83,36 @@ func TestAVersionIsReleasedOnceEveryArtifactIsPublished(t *testing.T) {
|
|||||||
if compareVersions(oldest, "0.1.5") < 0 {
|
if compareVersions(oldest, "0.1.5") < 0 {
|
||||||
t.Errorf("the oldest kept is %s: the oldest were not the ones deleted", oldest)
|
t.Errorf("the oldest kept is %s: the oldest were not the ones deleted", oldest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// H-A-486: an upstream artifact is copied by its pinned digest and never published, so the version is released once every
|
||||||
|
// other artifact is, the upstream one named with the pin its manifest gives; one whose manifest names no pin releases none.
|
||||||
|
pin := "sha256:" + strings.Repeat("ab", 32)
|
||||||
|
nats := func(from string) map[string]meshcatalog.CatalogEntry {
|
||||||
|
return map[string]meshcatalog.CatalogEntry{"nats": {Module: "nats", Manifest: map[string]any{"build": map[string]any{"artifacts": []any{
|
||||||
|
map[string]any{"name": "server", "kind": "upstream", "from": from},
|
||||||
|
map[string]any{"name": "tools", "kind": "bundle", "from": "."}}}},
|
||||||
|
Artifacts: []meshcatalog.Artifact{{Ref: "nats:server", Kind: "upstream"}, {Ref: "nats:tools", Kind: "bundle", Language: "go"}}}}
|
||||||
|
}
|
||||||
|
for i, c := range []struct {
|
||||||
|
from, version string
|
||||||
|
released bool
|
||||||
|
}{{"nats:2.12-alpine@" + pin, "0.1.1", true}, {"nats:2.12-alpine", "0.1.2", false}} {
|
||||||
|
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: int64(4 + i), Kind: "trunk"}, nats(c.from))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := KeepRevision(ctx, ix.Revisions, rev, objects); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = ix.HearPackagePublished(ctx, meshbuilds.PackagePublished{Module: "nats", Artifact: "nats:tools", Digest: "sha256:tools", Version: c.version, Source: 9, Branch: "main"})
|
||||||
|
got, _ := ModuleVersions(ctx, ix.Versions, "nats")
|
||||||
|
switch {
|
||||||
|
case c.released && (err != nil || len(got) != 1 || len(got[0].Artifacts) != 2 || got[0].Artifacts[0] != (meshcatalog.VersionArtifact{Artifact: "nats:server", Digest: pin})):
|
||||||
|
t.Fatalf("pinned %q: released %+v (%v); want the server named with its pin", c.from, got, err)
|
||||||
|
case !c.released && (err == nil || !strings.Contains(err.Error(), "no pinned digest") || len(got) != 1):
|
||||||
|
t.Fatalf("unpinned %q: released %+v (%v); want a refusal naming the pin", c.from, got, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Design 47 G §372, A-350: the first fill records, once, each module's highest version the builder gave a number, numbered or
|
// Design 47 G §372, A-350: the first fill records, once, each module's highest version the builder gave a number, numbered or
|
||||||
|
|||||||
@@ -27,9 +27,10 @@ func TestTheJudge(t *testing.T) {
|
|||||||
want: map[string]string{"a": `secret-`}},
|
want: map[string]string{"a": `secret-`}},
|
||||||
{name: "an unknown field", raws: map[string]string{"a": `{"module":"a","version":"1.0","a-field-from-later":1}`},
|
{name: "an unknown field", raws: map[string]string{"a": `{"module":"a","version":"1.0","a-field-from-later":1}`},
|
||||||
want: map[string]string{"a": `"a-field-from-later"`}},
|
want: map[string]string{"a": `"a-field-from-later"`}},
|
||||||
// H-A-465: the take-in sets a top-level word it does not know aside (ForInputs); the judgement still refuses it.
|
// H-A-465: the take-in sets a top-level word it does not know aside (ForInputs); the judgement still refuses it. The
|
||||||
{name: "a word a newer SDK adds", raws: map[string]string{"a": `{"module":"a","version":"1.0","class":"core"}`},
|
// word is one no SDK knows: class, the word of H-A-465's night, is known since H2.
|
||||||
want: map[string]string{"a": `"class"`}},
|
{name: "a word a newer SDK adds", raws: map[string]string{"a": `{"module":"a","version":"1.0","zzz-unknown-word":"core"}`},
|
||||||
|
want: map[string]string{"a": `"zzz-unknown-word"`}},
|
||||||
// Design 47 G §23, §28: a step's status is kept in the registration and never in a manifest.
|
// Design 47 G §23, §28: a step's status is kept in the registration and never in a manifest.
|
||||||
{name: "a manifest naming a step's status", raws: map[string]string{"a": `{"module":"a","version":"1.0","policy":{"lint":"bypass"}}`},
|
{name: "a manifest naming a step's status", raws: map[string]string{"a": `{"module":"a","version":"1.0","policy":{"lint":"bypass"}}`},
|
||||||
want: map[string]string{"a": `"policy"`}},
|
want: map[string]string{"a": `"policy"`}},
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TestRunsTools are runner_test_runs and runner_test_runs_drop (design 47 G §728; A-469f, A-469u): each calls its seat verb
|
// TestRunsTools are runner_test_runs and runner_test_runs_drop (design 47 G §728; A-469f, A-469u): each calls its seat verb
|
||||||
// over the bus, both answered by the runner's process, which holds test-runs-cap-mib (A-469g, A-470i).
|
// over the bus, both answered by the runner's process, which reads test-runs' fill against its bucket's max bytes (A-469g, A-470i, H-A-510).
|
||||||
func TestRunsTools(ask func(key string, body any) (json.RawMessage, error)) []stdio.Tool {
|
func TestRunsTools(ask func(key string, body any) (json.RawMessage, error)) []stdio.Tool {
|
||||||
return []stdio.Tool{
|
return []stdio.Tool{
|
||||||
{Name: Prefix + "_test_runs",
|
{Name: Prefix + "_test_runs",
|
||||||
Description: "The pipeline runner's test runs, one per candidate, level and tested packages (the state test-runs): each with its packages read from its output object, its ask, node, readers, outcome and counts, and the state's fill against its cap setting test-runs-cap-mib; filtered by a candidate, a level, a digest or a module, or none.",
|
Description: "The pipeline runner's test runs, one per candidate, level and tested packages (the state test-runs): each with its packages read from its output object, its ask, node, readers, outcome and counts, and the state's fill against its cap, the bucket's max bytes (the manifest's max-mib); filtered by a candidate, a level, a digest or a module, or none.",
|
||||||
Input: map[string]any{"type": "object", "properties": map[string]any{
|
Input: map[string]any{"type": "object", "properties": map[string]any{
|
||||||
"candidate": map[string]any{"type": "string"}, "level": map[string]any{"type": "string"},
|
"candidate": map[string]any{"type": "string"}, "level": map[string]any{"type": "string"},
|
||||||
"digest": map[string]any{"type": "string"}, "module": map[string]any{"type": "string"}}},
|
"digest": map[string]any{"type": "string"}, "module": map[string]any{"type": "string"}}},
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ func VerbTools(ask func(key string, body any) (json.RawMessage, error)) []stdio.
|
|||||||
}
|
}
|
||||||
return []stdio.Tool{
|
return []stdio.Tool{
|
||||||
verbTool[seat.StartInput](ask, "start", seat.VerbStart,
|
verbTool[seat.StartInput](ask, "start", seat.VerbStart,
|
||||||
"Start by hand the delivering pipeline of the head of a watched branch for a module, by the seat verb start: the branch, the module and why. A head whose pipeline is written already is refused by the verb, naming it.",
|
"Start by hand the delivering pipeline of the head of a watched branch for a module, by the seat verb start: the branch, the module and why. A head whose pipeline is written already is refused by the verb, naming it. With modules instead of module, the named modules whose newest entry has no passed pipeline (a failed, cut or superseded one) are started again at the head, keyed <branch>.<revision>.again.<n>; a module whose newest entry passed is refused by name (design 47 H2 H-A-479).",
|
||||||
obj([]string{"branch", "module", "why"}, map[string]any{"branch": str, "module": str, "why": str}),
|
obj([]string{"branch", "why"}, map[string]any{"branch": str, "module": str, "modules": map[string]any{"type": "array", "items": str}, "why": str}),
|
||||||
func(in seat.StartInput) string {
|
func(in seat.StartInput) string {
|
||||||
if in.Branch == "" || in.Module == "" {
|
if in.Branch == "" || (in.Module == "") == (len(in.Modules) == 0) {
|
||||||
return "start names the watched branch and the module"
|
return "start names the watched branch and exactly one of the module or the modules"
|
||||||
}
|
}
|
||||||
return whyOf(in.Why)
|
return whyOf(in.Why)
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ func TestVerbTools(t *testing.T) {
|
|||||||
{"start", "runner_start", "seat:mesh-pipeline-runner.start", "", map[string]any{"branch": "main", "module": "i3", "why": "cancelled"},
|
{"start", "runner_start", "seat:mesh-pipeline-runner.start", "", map[string]any{"branch": "main", "module": "i3", "why": "cancelled"},
|
||||||
seat.StartInput{Branch: "main", Module: "i3", Why: "cancelled"}},
|
seat.StartInput{Branch: "main", Module: "i3", Why: "cancelled"}},
|
||||||
{"start no why", "runner_start", "", "names why", map[string]any{"branch": "main", "module": "i3"}, nil},
|
{"start no why", "runner_start", "", "names why", map[string]any{"branch": "main", "module": "i3"}, nil},
|
||||||
{"start no module", "runner_start", "", "branch and the module", map[string]any{"branch": "main", "why": "x"}, nil},
|
{"start no module", "runner_start", "", "exactly one of the module or the modules", map[string]any{"branch": "main", "why": "x"}, nil},
|
||||||
|
// H-A-479: modules start the named modules again at the head; both together are refused.
|
||||||
|
{"start modules", "runner_start", "seat:mesh-pipeline-runner.start", "", map[string]any{"branch": "main", "modules": []any{"i3", "lib"}, "why": "failed"},
|
||||||
|
seat.StartInput{Branch: "main", Modules: []string{"i3", "lib"}, Why: "failed"}},
|
||||||
|
{"start module and modules", "runner_start", "", "exactly one of the module or the modules", map[string]any{"branch": "main", "module": "i3", "modules": []any{"lib"}, "why": "x"}, nil},
|
||||||
{"run", "runner_run", "seat:mesh-pipeline-runner.run", "", map[string]any{"members": []any{map[string]any{}}, "why": "x"},
|
{"run", "runner_run", "seat:mesh-pipeline-runner.run", "", map[string]any{"members": []any{map[string]any{}}, "why": "x"},
|
||||||
seat.RunInput{Members: []seat.Member{{}}, Why: "x"}},
|
seat.RunInput{Members: []seat.Member{{}}, Why: "x"}},
|
||||||
{"run no members", "runner_run", "", "members", map[string]any{}, nil},
|
{"run no members", "runner_run", "", "members", map[string]any{}, nil},
|
||||||
|
|||||||
@@ -96,3 +96,34 @@ func TestARevisionHeardIsHandedToItsStart(t *testing.T) {
|
|||||||
t.Errorf("a body that is no event = %v, want it ended", err)
|
t.Errorf("a body that is no event = %v, want it ended", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// H-A-479 addendum (2): a revision is held when the catalog seat's revision verb answers that revision, read fresh; none-yet,
|
||||||
|
// another revision or a refusal saying "no such object" is gone; another failure is said as it is.
|
||||||
|
func TestRevisionHeldReadsTheCatalogsRevisionFresh(t *testing.T) {
|
||||||
|
for _, c := range []struct {
|
||||||
|
name string
|
||||||
|
answer catalog.RevisionAnswer
|
||||||
|
err error
|
||||||
|
gone bool
|
||||||
|
fails bool
|
||||||
|
}{
|
||||||
|
{name: "held", answer: catalog.RevisionAnswer{Revision: &catalog.CatalogRevision{Revision: 258}}},
|
||||||
|
{name: "another revision", answer: catalog.RevisionAnswer{Revision: &catalog.CatalogRevision{Revision: 259}}, gone: true, fails: true},
|
||||||
|
{name: "none yet", answer: catalog.RevisionAnswer{NoneYet: true}, gone: true, fails: true},
|
||||||
|
{name: "removed", err: errors.New("revision main.258: no such object"), gone: true, fails: true},
|
||||||
|
{name: "unreachable", err: errors.New("no responders"), fails: true},
|
||||||
|
} {
|
||||||
|
var asked catalog.RevisionInput
|
||||||
|
call := func(_ string, body any) (json.RawMessage, error) {
|
||||||
|
asked = body.(catalog.RevisionInput)
|
||||||
|
if c.err != nil {
|
||||||
|
return nil, c.err
|
||||||
|
}
|
||||||
|
return json.Marshal(c.answer)
|
||||||
|
}
|
||||||
|
err := revisionHeld(call)("main", 258)
|
||||||
|
if (err != nil) != c.fails || errors.Is(err, pipeline.ErrRevisionGone) != c.gone || asked.Revision != 258 || asked.Branch != "main" {
|
||||||
|
t.Errorf("%s: %v (asked %+v)", c.name, err, asked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -60,3 +60,37 @@ func TestAgedHub(t *testing.T) {
|
|||||||
t.Errorf("a message asked again is noted applied: %+v", last)
|
t.Errorf("a message asked again is noted applied: %+v", last)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestTheTakeInsSwitch: until the takeins durable is bound, the main durable works every take-in; from the bind, it works
|
||||||
|
// only those said at or before the sequence the durable delivers after, and acknowledges the rest with no work
|
||||||
|
// (design 47 H2 H-A-500 fourth addendum).
|
||||||
|
func TestTheTakeInsSwitch(t *testing.T) {
|
||||||
|
for _, row := range []struct {
|
||||||
|
name string
|
||||||
|
boundFrom uint64
|
||||||
|
bound bool
|
||||||
|
seq uint64
|
||||||
|
delivers bool
|
||||||
|
}{
|
||||||
|
{"not bound, any sequence is worked", 0, false, 7, false},
|
||||||
|
{"bound after 5, the take-in at 5 is worked", 5, true, 5, false},
|
||||||
|
{"bound after 5, the take-in at 6 is the durable's", 5, true, 6, true},
|
||||||
|
{"bound on an empty stream, the first take-in is the durable's", 0, true, 1, true},
|
||||||
|
} {
|
||||||
|
t.Run(row.name, func(t *testing.T) {
|
||||||
|
sw := &takeInsSwitch{}
|
||||||
|
if row.bound {
|
||||||
|
sw.boundFrom(row.boundFrom)
|
||||||
|
}
|
||||||
|
hub := &oneHub{}
|
||||||
|
worked := false
|
||||||
|
if err := dropTakenIn(hub, sw, func(jetstream.Msg) { worked = true }); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
hub.handle(ackedMsg{seq: row.seq})
|
||||||
|
if worked == row.delivers {
|
||||||
|
t.Errorf("worked by the main durable: %v, want %v", worked, !row.delivers)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -188,8 +188,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
clock := askClock(ctx, bounds, askBound, rv.Findings, cred.Module, time.Now)
|
clock := askClock(ctx, bounds, askBound, rv.Findings, cred.Module, time.Now)
|
||||||
starter.Asks, hearer.Asks = clock, clock
|
starter.Asks, hearer.Asks = clock, clock
|
||||||
starter.Supersede = func(newer seat.Pipeline) { hearer.SupersedeRunning(newer) }
|
starter.Supersede = func(newer seat.Pipeline) { hearer.SupersedeRunning(newer) }
|
||||||
starter.Left = hearer.LeftInPlace // a same-source re-pin's superseded steps leave their runs (H-A-284)
|
starter.Drop = hearer.DropOpen // a placing's end drops the asks still open (H-A-506)
|
||||||
starter.Revision = widener.Revision // a kept mover is placed from its kept revision (H-A-286)
|
hearer.Aside = func(do func()) { go do() } // each drop of an ended pipeline's asks beside its end (H-A-506)
|
||||||
|
starter.Left = hearer.LeftInPlace // a same-source re-pin's superseded steps leave their runs (H-A-284)
|
||||||
|
starter.Revision = widener.Revision // a kept mover is placed from its kept revision (H-A-286)
|
||||||
// A mover's wait on a package is read first: a package published before the wait places it at once (H-A-326, H-A-328).
|
// A mover's wait on a package is read first: a package published before the wait places it at once (H-A-326, H-A-328).
|
||||||
// It is a kept call within ask-unanswered-bound (design 47 H2 §775).
|
// It is a kept call within ask-unanswered-bound (design 47 H2 §775).
|
||||||
starter.AskPublished = publishedOf(func(key string, body any) (json.RawMessage, error) {
|
starter.AskPublished = publishedOf(func(key string, body any) (json.RawMessage, error) {
|
||||||
@@ -237,8 +239,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
advancer.Store(&advance)
|
advancer.Store(&advance)
|
||||||
// A registration-changed places the steps of its module's pipelines started before it, from it (A-327).
|
// A registration-changed places the steps of its module's pipelines started before it, from it (A-327), and binds the
|
||||||
|
// takeins durable when its bind failed at the start (H-A-500 fifth addendum).
|
||||||
|
var bindTakeInsAgain atomic.Pointer[func()]
|
||||||
register := func(reg catalog.Registration) {
|
register := func(reg catalog.Registration) {
|
||||||
|
if f := bindTakeInsAgain.Load(); f != nil {
|
||||||
|
(*f)()
|
||||||
|
}
|
||||||
if n, err := starter.Registered(store, reg, rv.Catalog.View); err != nil || n > 0 {
|
if n, err := starter.Registered(store, reg, rv.Catalog.View); err != nil || n > 0 {
|
||||||
logger.Printf("the pipelines of %s started before its registration: %d placed (%v)", reg.Module, n, err)
|
logger.Printf("the pipelines of %s started before its registration: %d placed (%v)", reg.Module, n, err)
|
||||||
}
|
}
|
||||||
@@ -321,6 +328,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := hearStepProgress(heard, func(onSeat, ask string) error {
|
if err := hearStepProgress(heard, func(onSeat, ask string) error {
|
||||||
|
if hearer.LateRunAsk("step-progress", ask) {
|
||||||
|
return nil // an ended run's ask: acknowledged at once, nothing read but its ask key and run (H-A-500 (a))
|
||||||
|
}
|
||||||
progressed(clock, onSeat, ask, logger.Printf) // the ask's bound is armed again from now (H-A-395)
|
progressed(clock, onSeat, ask, logger.Printf) // the ask's bound is armed again from now (H-A-395)
|
||||||
return hearer.RunProgress(ask)
|
return hearer.RunProgress(ask)
|
||||||
}, logger.Printf); err != nil {
|
}, logger.Printf); err != nil {
|
||||||
@@ -333,6 +343,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
taken := func(ask, node string, at time.Time) (*time.Time, error) {
|
taken := func(ask, node string, at time.Time) (*time.Time, error) {
|
||||||
|
if hearer.LateRunAsk("ask-taken", ask) {
|
||||||
|
return nil, nil // an ended run's ask: acknowledged at once, nothing read but its ask key and run (H-A-500 (a))
|
||||||
|
}
|
||||||
takenAt, err := hearer.Taken(ask, node, at)
|
takenAt, err := hearer.Taken(ask, node, at)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -370,7 +383,17 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
if err := hearRecovery(heard, kvRecoveries{ctx, recovered}, logger.Printf); err != nil {
|
if err := hearRecovery(heard, kvRecoveries{ctx, recovered}, logger.Printf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := hearTakenIn(heard, starter, rv.Catalog, logger.Printf); err != nil {
|
// take-in.taken is acted on on the runner's own takeins durable once that is bound, so no step traffic holds a take-in;
|
||||||
|
// until then the main durable works it, and from the bind acknowledges it at once (design 47 H2 H-A-500 (b) and its
|
||||||
|
// addenda, the fourth: no take-in said while the runner was down is lost).
|
||||||
|
takeInsBound := &takeInsSwitch{}
|
||||||
|
if err := dropTakenIn(heard, takeInsBound, takenIn(starter, rv.Catalog, logger.Printf)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
takeIns := &oneHandler{}
|
||||||
|
takeInsName := cred.EventConsumerName() + "_" + takeInsSuffix
|
||||||
|
takeInsHeard := agedHub{hub: takeIns, ledger: process.NewConsumerLedger(process.EventsStream, takeInsName, consumersSink(consumers), nil, logger.Printf)}
|
||||||
|
if err := hearTakenIn(takeInsHeard, starter, rv.Catalog, logger.Printf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := hearReleased(heard, hearer, starter.Registration, logger.Printf); err != nil {
|
if err := hearReleased(heard, hearer, starter.Registration, logger.Printf); err != nil {
|
||||||
@@ -387,6 +410,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
|||||||
// their callers against (A-186): registered before the hub starts, read again once its events are live.
|
// their callers against (A-186): registered before the hub starts, read again once its events are live.
|
||||||
seats := seatlist.NewPart("runner")
|
seats := seatlist.NewPart("runner")
|
||||||
seats.Follow(seatlist.ProcessBus(calls.Call, hub), nil, logger.Printf)
|
seats.Follow(seatlist.ProcessBus(calls.Call, hub), nil, logger.Printf)
|
||||||
|
again := bindTakeIns(ctx, js, cred, takeIns.handle, takeInsBound, logger.Printf)
|
||||||
|
bindTakeInsAgain.Store(&again)
|
||||||
if err := hub.StartUntilBound(ctx, js, cred, nil, seats.EventsLive); err != nil {
|
if err := hub.StartUntilBound(ctx, js, cred, nil, seats.EventsLive); err != nil {
|
||||||
logger.Printf("the consumer %s is not bound yet (%v): bound once the bus makes it", cred.EventConsumerName(), err)
|
logger.Printf("the consumer %s is not bound yet (%v): bound once the bus makes it", cred.EventConsumerName(), err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ func testTheQueueRunsPipelinesInTurn(t *testing.T) {
|
|||||||
return ""
|
return ""
|
||||||
}, logs)
|
}, logs)
|
||||||
}()
|
}()
|
||||||
|
takeInsHeard(t, ctx, logs)
|
||||||
return func() { stop(); <-done }
|
return func() { stop(); <-done }
|
||||||
}
|
}
|
||||||
stopRunner := start()
|
stopRunner := start()
|
||||||
@@ -267,13 +268,16 @@ func testTheQueueRunsPipelinesInTurn(t *testing.T) {
|
|||||||
waitFor(t, ctx, logs, func() bool { return get(key).Outcome == want })
|
waitFor(t, ctx, logs, func() bool { return get(key).Outcome == want })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Two take-ins in a row: the first runs, its build asked; the second is written waiting under sequence 1 with no step,
|
// Two take-ins in a row: the first runs at sequence 1 (every pipeline has one, H-A-504 addendum), its build asked; the
|
||||||
// says pipeline-started and wait-held.
|
// second is written waiting under sequence 2 with no step, says pipeline-started and wait-held.
|
||||||
take(3, "app")
|
take(3, "app")
|
||||||
outcome("main.3", seat.PipelineOutcomeRunning)
|
outcome("main.3", seat.PipelineOutcomeRunning)
|
||||||
|
if p := get("main.3"); p.Seq != 1 {
|
||||||
|
t.Fatalf("main.3 placed at once has seq %d, want 1", p.Seq)
|
||||||
|
}
|
||||||
take(4, "lib")
|
take(4, "lib")
|
||||||
if p := get("main.4"); p.Outcome != seat.PipelineOutcomeWaiting || p.Seq != 1 || len(p.Steps) != 0 {
|
if p := get("main.4"); p.Outcome != seat.PipelineOutcomeWaiting || p.Seq != 2 || len(p.Steps) != 0 {
|
||||||
t.Fatalf("main.4 = %s seq %d with %d steps, want waiting at 1 with none", p.Outcome, p.Seq, len(p.Steps))
|
t.Fatalf("main.4 = %s seq %d with %d steps, want waiting at 2 with none", p.Outcome, p.Seq, len(p.Steps))
|
||||||
}
|
}
|
||||||
waitFor(t, ctx, logs, func() bool { return wasSaid("wait-held.main.4") && wasSaid("pipeline-started.main.4") })
|
waitFor(t, ctx, logs, func() bool { return wasSaid("wait-held.main.4") && wasSaid("pipeline-started.main.4") })
|
||||||
if r := running(); !slices.Equal(r, []string{"main.3"}) {
|
if r := running(); !slices.Equal(r, []string{"main.3"}) {
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ func (s *syncBuffer) String() string { s.mu.Lock(); defer s.mu.Unlock(); return
|
|||||||
// bus proved; the pipeline then ends passed.
|
// bus proved; the pipeline then ends passed.
|
||||||
func TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview(t *testing.T) {
|
func TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview(t *testing.T) {
|
||||||
t.Run("the queue runs pipelines in turn", testTheQueueRunsPipelinesInTurn)
|
t.Run("the queue runs pipelines in turn", testTheQueueRunsPipelinesInTurn)
|
||||||
|
t.Run("a take-in is heard while late events queue on the main durable", testATakeInIsHeardWhileLateEventsQueue)
|
||||||
|
t.Run("a take-in said before the bind is still worked", testATakeInSaidBeforeTheBindIsStillWorked)
|
||||||
|
t.Run("a takeins bind that failed is bound again on registration-changed", testATakeInsBindThatFailedIsBoundAgainOnRegistrationChanged)
|
||||||
t.Run("step log read does not wait for a batch it cannot fill", testStepLogReadDoesNotWaitForABatchItCannotFill)
|
t.Run("step log read does not wait for a batch it cannot fill", testStepLogReadDoesNotWaitForABatchItCannotFill)
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@@ -384,6 +387,7 @@ func startWhole(t *testing.T, ctx context.Context, regs []catalog.Registration,
|
|||||||
}, logs)
|
}, logs)
|
||||||
}()
|
}()
|
||||||
t.Cleanup(func() { stop(); <-done })
|
t.Cleanup(func() { stop(); <-done })
|
||||||
|
takeInsHeard(t, ctx, logs)
|
||||||
pipelines, err := js.KeyValue(ctx, module+"_pipelines")
|
pipelines, err := js.KeyValue(ctx, module+"_pipelines")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -500,6 +504,14 @@ func findingsStream(t *testing.T, ctx context.Context, js jetstream.JetStream, m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// takeInsHeard waits until the runner's takeins durable is bound, which the runner makes at its first start from the
|
||||||
|
// moment it is made (H-A-500 (b)); a take-in said before is worked by the main durable (the fourth addendum), but the tests
|
||||||
|
// publish after the bind so that each take-in is heard where the running runner hears it.
|
||||||
|
func takeInsHeard(t *testing.T, ctx context.Context, logs *syncBuffer) {
|
||||||
|
t.Helper()
|
||||||
|
waitFor(t, ctx, logs, func() bool { return strings.Contains(logs.String(), "take-ins: heard on the consumer") })
|
||||||
|
}
|
||||||
|
|
||||||
func waitFor(t *testing.T, ctx context.Context, logs *syncBuffer, cond func() bool) {
|
func waitFor(t *testing.T, ctx context.Context, logs *syncBuffer, cond func() bool) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
for ctx.Err() == nil {
|
for ctx.Err() == nil {
|
||||||
|
|||||||
@@ -3,12 +3,19 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/nats-io/nats.go/jetstream"
|
"github.com/nats-io/nats.go/jetstream"
|
||||||
|
|
||||||
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
|
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/process"
|
||||||
|
|
||||||
"mesh-delivery-pipeline/internal/pipeline"
|
"mesh-delivery-pipeline/internal/pipeline"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -57,10 +64,140 @@ func revisedHear(revised func(ev catalog.CatalogRevisionEvent) (int, error), log
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// takeInsSuffix names the runner's own second durable on the shared events stream, `<node>_<module>_takeins`, on which alone
|
||||||
|
// take-in.taken is acted on, so a pipeline starts within seconds of its take-in whatever the step traffic on the runner's
|
||||||
|
// main durable (design 47 H2 H-A-500 (b) and its addenda).
|
||||||
|
const takeInsSuffix = "takeins"
|
||||||
|
|
||||||
|
// The ack wait and the deliveries of the takeins durable, as the grants part gives a module's consumers (H-A-500 (b)).
|
||||||
|
const (
|
||||||
|
takeInsAckWait = 30 * time.Second
|
||||||
|
takeInsMaxDeliver = 5
|
||||||
|
)
|
||||||
|
|
||||||
|
// takeInsConsumerConfig is the takeins durable as the runner makes it: take-in.taken alone, acknowledged one by one, from
|
||||||
|
// the moment it is made (H-A-500 (b)).
|
||||||
|
func takeInsConsumerConfig(cred process.Account) jetstream.ConsumerConfig {
|
||||||
|
cfg := cred.SeatEventConsumerConfig([]string{pipeline.TakenInSubject}, false)
|
||||||
|
cfg.Durable = cred.EventConsumerName() + "_" + takeInsSuffix
|
||||||
|
cfg.AckWait, cfg.MaxDeliver = takeInsAckWait, takeInsMaxDeliver
|
||||||
|
cfg.DeliverPolicy = jetstream.DeliverNewPolicy
|
||||||
|
return cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
// oneHandler is the handlers of one durable that hears one pattern: the takeins durable's (H-A-500 (b)).
|
||||||
|
type oneHandler struct {
|
||||||
|
pattern string
|
||||||
|
handle func(jetstream.Msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *oneHandler) Handle(pattern string, handle func(jetstream.Msg)) error {
|
||||||
|
if o.handle != nil {
|
||||||
|
return fmt.Errorf("the durable hears %q already, so %q has no taker", o.pattern, pattern)
|
||||||
|
}
|
||||||
|
o.pattern, o.handle = pattern, handle
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// takeInsSwitch says which durable a take-in.taken is worked on (H-A-500 fourth addendum): until the runner's takeins
|
||||||
|
// durable is bound, the main durable does the work, so a take-in said while the runner was down is lost to no one; from
|
||||||
|
// the bind, the takeins durable alone works the take-ins said after it was made, and the main durable acknowledges those
|
||||||
|
// at once with no work. The boundary is the stream sequence the takeins durable delivers from, so a take-in said before
|
||||||
|
// the durable was made and still waiting on the main durable is worked there whatever the moment it is heard.
|
||||||
|
type takeInsSwitch struct {
|
||||||
|
// from holds 1 + the stream sequence the takeins durable delivers after; 0 while it is not bound.
|
||||||
|
from atomic.Uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
// boundFrom says the takeins durable is bound and delivers every take-in said after stream sequence seq.
|
||||||
|
func (s *takeInsSwitch) boundFrom(seq uint64) { s.from.Store(seq + 1) }
|
||||||
|
|
||||||
|
// delivers says whether the takeins durable delivers m, so the main durable has no work on it.
|
||||||
|
func (s *takeInsSwitch) delivers(m jetstream.Msg) bool {
|
||||||
|
from := s.from.Load()
|
||||||
|
if from == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
meta, err := m.Metadata()
|
||||||
|
if err != nil {
|
||||||
|
// A message whose sequence is unknown is worked rather than dropped: the work is done once per key, never twice.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return meta.Sequence.Stream >= from
|
||||||
|
}
|
||||||
|
|
||||||
|
// dropTakenIn has the main durable work each take-in.taken the takeins durable does not deliver, and acknowledge the rest at
|
||||||
|
// once with no work, so the finding event-unhandled stays clear (H-A-500 third and fourth addenda).
|
||||||
|
func dropTakenIn(hub handlers, sw *takeInsSwitch, work func(jetstream.Msg)) error {
|
||||||
|
return hub.Handle(pipeline.TakenInSubject, func(m jetstream.Msg) {
|
||||||
|
if sw.delivers(m) {
|
||||||
|
_ = m.Ack()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
work(m)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// bindTakeIns binds the runner's takeins durable and hears it with handle, the durable made when the bus does not hold it
|
||||||
|
// (H-A-500 (b)): bound at once when it can be, so no take-in said after the runner's start is missed. A bind that fails
|
||||||
|
// (the bus has not made the runner's grant yet) is said, and the answered func binds again, called on each
|
||||||
|
// registration-changed as the indexer binds a branch's consumer on each (H-A-500 fifth addendum: nothing waits on a timer
|
||||||
|
// for another part); once bound it does nothing. Once bound, sw says so with the stream sequence the durable delivers
|
||||||
|
// after, and the main durable stops working the take-ins it delivers (the fourth addendum).
|
||||||
|
func bindTakeIns(ctx context.Context, js jetstream.JetStream, cred process.Account, handle func(jetstream.Msg), sw *takeInsSwitch,
|
||||||
|
logf func(string, ...any)) (again func()) {
|
||||||
|
bind := func() error {
|
||||||
|
cons, err := cred.NamedEventConsumer(ctx, js, process.EventsStream, takeInsSuffix)
|
||||||
|
if errors.Is(err, jetstream.ErrConsumerNotFound) {
|
||||||
|
cfg := takeInsConsumerConfig(cred)
|
||||||
|
if cons, err = js.CreateConsumer(ctx, process.EventsStream, cfg); err != nil {
|
||||||
|
return fmt.Errorf("the consumer %s on %s is not there and is not made: %w", cfg.Durable, process.EventsStream, err)
|
||||||
|
}
|
||||||
|
logf("take-ins: the consumer %s on %s was not there: the runner made it (H-A-500 (b))", cfg.Durable, process.EventsStream)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// A durable just made delivers after the stream's last sequence; one found, after what it delivered already.
|
||||||
|
info, err := cons.Info(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("the consumer %s_%s is not read: %w", cred.EventConsumerName(), takeInsSuffix, err)
|
||||||
|
}
|
||||||
|
if _, err = process.HearEvents(cons, handle, logf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sw.boundFrom(info.Delivered.Stream)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var mu sync.Mutex
|
||||||
|
bound := false
|
||||||
|
try := func() {
|
||||||
|
mu.Lock()
|
||||||
|
defer mu.Unlock()
|
||||||
|
if bound || ctx.Err() != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := bind(); err != nil {
|
||||||
|
logf("take-ins: the consumer %s_%s is not bound, so the main durable works each take-in; bound again at the next registration-changed: %v",
|
||||||
|
cred.EventConsumerName(), takeInsSuffix, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
bound = true
|
||||||
|
logf("take-ins: heard on the consumer %s_%s (H-A-500 (b))", cred.EventConsumerName(), takeInsSuffix)
|
||||||
|
}
|
||||||
|
try()
|
||||||
|
return try
|
||||||
|
}
|
||||||
|
|
||||||
// hearTakenIn starts the pipeline of each take-in.taken heard (design 47 H §746): one per take-in, the message acknowledged
|
// hearTakenIn starts the pipeline of each take-in.taken heard (design 47 H §746): one per take-in, the message acknowledged
|
||||||
// once it is written, and heard again when a write failed, so the key already written starts nothing twice.
|
// once it is written, and heard again when a write failed, so the key already written starts nothing twice.
|
||||||
func hearTakenIn(hub handlers, starter *pipeline.Starter, v *pipeline.Views, logf func(string, ...any)) error {
|
func hearTakenIn(hub handlers, starter *pipeline.Starter, v *pipeline.Views, logf func(string, ...any)) error {
|
||||||
return hub.Handle(pipeline.TakenInSubject, func(m jetstream.Msg) {
|
return hub.Handle(pipeline.TakenInSubject, takenIn(starter, v, logf))
|
||||||
|
}
|
||||||
|
|
||||||
|
// takenIn is the work of one take-in.taken, on whichever durable delivers it (H-A-500 fourth addendum).
|
||||||
|
func takenIn(starter *pipeline.Starter, v *pipeline.Views, logf func(string, ...any)) func(jetstream.Msg) {
|
||||||
|
return func(m jetstream.Msg) {
|
||||||
// An event of the old form is refused by the contract's strict decode, said in one journal line and ended (§765, H-A-98).
|
// An event of the old form is refused by the contract's strict decode, said in one journal line and ended (§765, H-A-98).
|
||||||
ev, err := pipeline.DecodeTakenIn(m.Data())
|
ev, err := pipeline.DecodeTakenIn(m.Data())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -76,7 +213,7 @@ func hearTakenIn(hub handlers, starter *pipeline.Starter, v *pipeline.Views, log
|
|||||||
}
|
}
|
||||||
logf("the take-in of %s source %d started %d pipelines", ev.Branch, ev.Source, n)
|
logf("the take-in of %s source %d started %d pipelines", ev.Branch, ev.Source, n)
|
||||||
_ = m.Ack()
|
_ = m.Ack()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hearReleased writes each version-released's version into its mover (design 47 H §746, H-A-52), so the pipeline's end names
|
// hearReleased writes each version-released's version into its mover (design 47 H §746, H-A-52), so the pipeline's end names
|
||||||
|
|||||||
+221
@@ -0,0 +1,221 @@
|
|||||||
|
//go:build integration
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/nats-io/nats.go"
|
||||||
|
"github.com/nats-io/nats.go/jetstream"
|
||||||
|
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/process"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/testbus"
|
||||||
|
|
||||||
|
"mesh-delivery-pipeline/internal/pipeline"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Design 47 H2 H-A-500 (b) and its addenda: a take-in.taken said while 500 late step-progress events wait on the runner's
|
||||||
|
// main durable, its handler held, is heard at once on the runner's own takeins durable, which the runner makes itself; the
|
||||||
|
// main durable acknowledges the take-in with no work. testATakeInIsHeardWhileLateEventsQueue is a row of
|
||||||
|
// TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview (the module's tests are folded under its budget).
|
||||||
|
func testATakeInIsHeardWhileLateEventsQueue(t *testing.T) {
|
||||||
|
url := testbus.URL(t)
|
||||||
|
nc, err := nats.Connect(url)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer nc.Close()
|
||||||
|
js, err := jetstream.New(nc)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
cred := process.Account{URL: url, Node: "n1", Module: "mesh-delivery-pipeline"}
|
||||||
|
events, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: process.EventsStream, Subjects: []string{"mesh.mod.*.event.>", "mesh.seat.*.event.>"}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := events.CreateOrUpdateConsumer(ctx, jetstream.ConsumerConfig{Durable: cred.EventConsumerName(), AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
const progress = "mesh.seat.node-build-go.event.step-progress.n1"
|
||||||
|
for i := 0; i < 500; i++ {
|
||||||
|
if _, err := js.Publish(ctx, progress, []byte(`{"ask":"late","phase":"run"}`)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The main durable's step-progress handler is held until the test ends: every late event waits behind the first.
|
||||||
|
held := make(chan struct{})
|
||||||
|
defer close(held)
|
||||||
|
hub := process.NewEventHub(t.Logf)
|
||||||
|
if err := hub.Handle(progress, func(m jetstream.Msg) { <-held; _ = m.Ack() }); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
sw := &takeInsSwitch{}
|
||||||
|
if err := dropTakenIn(hub, sw, func(m jetstream.Msg) { t.Errorf("the main durable worked %s after the bind", m.Subject()); _ = m.Ack() }); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := hub.Start(ctx, js, cred); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer hub.Stop()
|
||||||
|
heard := make(chan string, 1)
|
||||||
|
takeIns := &oneHandler{}
|
||||||
|
if err := takeIns.Handle(pipeline.TakenInSubject, func(m jetstream.Msg) { heard <- m.Subject(); _ = m.Ack() }); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
bindTakeIns(ctx, js, cred, takeIns.handle, sw, t.Logf)
|
||||||
|
if _, err := js.Publish(ctx, "mesh.mod.mesh-delivery-indexer.event.take-in.taken", []byte(`{}`)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case s := <-heard:
|
||||||
|
if s != "mesh.mod.mesh-delivery-indexer.event.take-in.taken" {
|
||||||
|
t.Errorf("the takeins durable heard %s", s)
|
||||||
|
}
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal("the take-in is not heard while late events wait on the main durable")
|
||||||
|
}
|
||||||
|
info, err := events.Consumer(ctx, cred.EventConsumerName()+"_"+takeInsSuffix)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("the takeins durable is not made: %v", err)
|
||||||
|
}
|
||||||
|
if f := info.CachedInfo().Config.FilterSubjects; len(f) != 1 || f[0] != pipeline.TakenInSubject {
|
||||||
|
t.Errorf("the takeins durable filters %v, want take-in.taken alone", f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Design 47 H2 H-A-500 fourth addendum: a take-in.taken said before the runner's takeins durable is bound (the runner was
|
||||||
|
// down, or the bind failed) is worked by the main durable, so it starts its pipeline; one said after the bind is worked by
|
||||||
|
// the takeins durable alone and the main durable acknowledges it with no work. A row of
|
||||||
|
// TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview.
|
||||||
|
func testATakeInSaidBeforeTheBindIsStillWorked(t *testing.T) {
|
||||||
|
url := testbus.URL(t)
|
||||||
|
nc, err := nats.Connect(url)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer nc.Close()
|
||||||
|
js, err := jetstream.New(nc)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
cred := process.Account{URL: url, Node: "n1", Module: "mesh-delivery-pipeline"}
|
||||||
|
events, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: process.EventsStream, Subjects: []string{"mesh.mod.*.event.>", "mesh.seat.*.event.>"}})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := events.CreateOrUpdateConsumer(ctx, jetstream.ConsumerConfig{Durable: cred.EventConsumerName(), AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
const subject = "mesh.mod.mesh-delivery-indexer.event.take-in.taken"
|
||||||
|
// Said while the runner was down: the main durable holds it, the takeins durable does not exist yet.
|
||||||
|
if _, err := js.Publish(ctx, subject, []byte(`{"before":true}`)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// The main durable's take-in handler is held until the takeins durable is bound, as a main durable busy with step
|
||||||
|
// events would be: the take-in said before the bind is still worked, by its sequence, not by the moment it is heard.
|
||||||
|
held := make(chan struct{})
|
||||||
|
worked, heard := make(chan string, 2), make(chan string, 2)
|
||||||
|
hub := process.NewEventHub(t.Logf)
|
||||||
|
sw := &takeInsSwitch{}
|
||||||
|
if err := dropTakenIn(hub, sw, func(m jetstream.Msg) { <-held; worked <- string(m.Data()); _ = m.Ack() }); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := hub.Start(ctx, js, cred); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer hub.Stop()
|
||||||
|
takeIns := &oneHandler{}
|
||||||
|
if err := takeIns.Handle(pipeline.TakenInSubject, func(m jetstream.Msg) { heard <- string(m.Data()); _ = m.Ack() }); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
bindTakeIns(ctx, js, cred, takeIns.handle, sw, t.Logf)
|
||||||
|
if sw.from.Load() == 0 {
|
||||||
|
t.Fatal("the takeins durable is not bound")
|
||||||
|
}
|
||||||
|
// Said after the bind: the takeins durable's alone.
|
||||||
|
if _, err := js.Publish(ctx, subject, []byte(`{"after":true}`)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
close(held)
|
||||||
|
select {
|
||||||
|
case d := <-worked:
|
||||||
|
if d != `{"before":true}` {
|
||||||
|
t.Errorf("the main durable worked %s, want the take-in said before the bind", d)
|
||||||
|
}
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal("the take-in said before the bind is worked by no durable")
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case d := <-heard:
|
||||||
|
if d != `{"after":true}` {
|
||||||
|
t.Errorf("the takeins durable heard %s, want the take-in said after the bind", d)
|
||||||
|
}
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal("the take-in said after the bind is not heard on the takeins durable")
|
||||||
|
}
|
||||||
|
// The main durable acknowledged the second with no work: nothing more is worked once its queue is drained.
|
||||||
|
select {
|
||||||
|
case d := <-worked:
|
||||||
|
t.Errorf("the main durable worked %s after the bind", d)
|
||||||
|
case <-time.After(2 * time.Second):
|
||||||
|
}
|
||||||
|
info, err := events.Consumer(ctx, cred.EventConsumerName())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
ci, err := info.Info(ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if ci.NumAckPending != 0 || ci.NumPending != 0 {
|
||||||
|
t.Errorf("the main durable holds %d pending and %d unacknowledged, want none", ci.NumPending, ci.NumAckPending)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Design 47 H2 H-A-500 fifth addendum: a takeins bind that failed at the start (here the events stream is not there yet, as
|
||||||
|
// the runner's grant is not there before the bus composes its account) is said and bound again on the next
|
||||||
|
// registration-changed, never on a timer. A row of TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview.
|
||||||
|
func testATakeInsBindThatFailedIsBoundAgainOnRegistrationChanged(t *testing.T) {
|
||||||
|
url := testbus.URL(t)
|
||||||
|
nc, err := nats.Connect(url)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer nc.Close()
|
||||||
|
js, err := jetstream.New(nc)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
cred := process.Account{URL: url, Node: "n1", Module: "mesh-delivery-pipeline"}
|
||||||
|
sw := &takeInsSwitch{}
|
||||||
|
heard := make(chan string, 1)
|
||||||
|
again := bindTakeIns(ctx, js, cred, func(m jetstream.Msg) { heard <- m.Subject(); _ = m.Ack() }, sw, t.Logf)
|
||||||
|
if sw.from.Load() != 0 {
|
||||||
|
t.Fatal("the takeins durable is bound with no events stream")
|
||||||
|
}
|
||||||
|
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: process.EventsStream, Subjects: []string{"mesh.mod.*.event.>", "mesh.seat.*.event.>"}}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
again() // the registration-changed heard once the bus holds the stream and the grant
|
||||||
|
if sw.from.Load() == 0 {
|
||||||
|
t.Fatal("the takeins durable is not bound again on registration-changed")
|
||||||
|
}
|
||||||
|
if _, err := js.Publish(ctx, "mesh.mod.mesh-delivery-indexer.event.take-in.taken", []byte(`{}`)); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-heard:
|
||||||
|
case <-ctx.Done():
|
||||||
|
t.Fatal("the take-in is not heard on the durable bound again")
|
||||||
|
}
|
||||||
|
again() // bound already: nothing is bound twice
|
||||||
|
}
|
||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -166,6 +165,34 @@ func (t testRunsKV) Has(key string) (bool, error) {
|
|||||||
return err == nil, err
|
return err == nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarkAsk creates the ask key of ask holding mark (H-A-506 addendum); one written already is kept.
|
||||||
|
func (t testRunsKV) MarkAsk(ask string, mark pipeline.AskMark) error {
|
||||||
|
raw, err := json.Marshal(mark)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := t.kv.Create(t.ctx, pipeline.AskKey(ask), raw); err != nil && !errors.Is(err, jetstream.ErrKeyExists) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AskOf reads the ask key of ask: the mark it holds, a key written before the H-A-506 addendum naming its run alone.
|
||||||
|
func (t testRunsKV) AskOf(ask string) (pipeline.AskMark, bool, error) {
|
||||||
|
e, err := t.kv.Get(t.ctx, pipeline.AskKey(ask))
|
||||||
|
if errors.Is(err, jetstream.ErrKeyNotFound) {
|
||||||
|
return pipeline.AskMark{}, false, nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return pipeline.AskMark{}, false, err
|
||||||
|
}
|
||||||
|
var m pipeline.AskMark
|
||||||
|
if err := json.Unmarshal(e.Value(), &m); err != nil || (m.Run == "" && m.Pipeline == "") {
|
||||||
|
return pipeline.AskMark{}, false, fmt.Errorf("the ask key of ask %s names no pipeline and no run: %v", ask, err)
|
||||||
|
}
|
||||||
|
return m, true, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (t testRunsKV) Keys() ([]string, error) {
|
func (t testRunsKV) Keys() ([]string, error) {
|
||||||
all, err := t.kv.Keys(t.ctx)
|
all, err := t.kv.Keys(t.ctx)
|
||||||
if errors.Is(err, jetstream.ErrNoKeysFound) {
|
if errors.Is(err, jetstream.ErrNoKeysFound) {
|
||||||
@@ -255,7 +282,8 @@ func (o *runObjects) Delete(name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// runsFill reads test-runs' fill, its key-value stream's bytes (A-469d): judged by the process against its cap setting.
|
// runsFill reads test-runs' fill, its key-value stream's bytes, against its cap, the stream's max bytes (A-469d, H-A-510
|
||||||
|
// addendum): the bucket on the bus is the one truth of the manifest's max-mib, so the runner keeps no second number.
|
||||||
func runsFill(ctx context.Context, js jetstream.JetStream, module string, now func() time.Time) func() (seat.Fill, error) {
|
func runsFill(ctx context.Context, js jetstream.JetStream, module string, now func() time.Time) func() (seat.Fill, error) {
|
||||||
return func() (seat.Fill, error) {
|
return func() (seat.Fill, error) {
|
||||||
st, err := js.Stream(ctx, "KV_"+ownBucket(module, TestRunsState))
|
st, err := js.Stream(ctx, "KV_"+ownBucket(module, TestRunsState))
|
||||||
@@ -273,7 +301,6 @@ func runsFill(ctx context.Context, js jetstream.JetStream, module string, now fu
|
|||||||
|
|
||||||
// The files the manifest writes each setting of the test runs into, `${config:<key>}`, named by the environment (A-469x).
|
// The files the manifest writes each setting of the test runs into, `${config:<key>}`, named by the environment (A-469x).
|
||||||
const (
|
const (
|
||||||
envRunsCap = "MESH_RUNNER_TEST_RUNS_CAP_FILE"
|
|
||||||
envRunsKept = "MESH_RUNNER_TEST_RUNS_KEPT_FILE"
|
envRunsKept = "MESH_RUNNER_TEST_RUNS_KEPT_FILE"
|
||||||
envStepBound = "MESH_RUNNER_TEST_STEP_BOUND_FILE"
|
envStepBound = "MESH_RUNNER_TEST_STEP_BOUND_FILE"
|
||||||
envUntakenBound = "MESH_RUNNER_RUN_UNTAKEN_BOUND_FILE"
|
envUntakenBound = "MESH_RUNNER_RUN_UNTAKEN_BOUND_FILE"
|
||||||
@@ -282,20 +309,11 @@ const (
|
|||||||
// maxRunsKept is test-runs-kept's maximum (A-470a): the pipeline naming a run's key is kept at least that long.
|
// maxRunsKept is test-runs-kept's maximum (A-470a): the pipeline naming a run's key is kept at least that long.
|
||||||
const maxRunsKept = 168 * time.Hour
|
const maxRunsKept = 168 * time.Hour
|
||||||
|
|
||||||
// runSettings reads the settings of the test runs at the start (§725; A-469x): test-runs-cap-mib a whole number of MiB,
|
// runSettings reads the settings of the test runs at the start (§725; A-469x): test-runs-kept, test-step-bound and
|
||||||
// test-runs-kept, test-step-bound and run-untaken-bound Go durations. A setting whose file is missing or empty is its
|
// run-untaken-bound Go durations. A setting whose file is missing or empty is its
|
||||||
// default; a content that is neither is an error naming the file.
|
// default; a content that is neither is an error naming the file.
|
||||||
func runSettings(getenv func(string) string) (pipeline.RunSettings, error) {
|
func runSettings(getenv func(string) string) (pipeline.RunSettings, error) {
|
||||||
s := pipeline.DefaultRunSettings
|
s := pipeline.DefaultRunSettings
|
||||||
if v, err := settingText(getenv(envRunsCap)); err != nil {
|
|
||||||
return s, err
|
|
||||||
} else if v != "" {
|
|
||||||
n, err := strconv.Atoi(v)
|
|
||||||
if err != nil || n < 1 {
|
|
||||||
return s, fmt.Errorf("%s holds %q, which is not a positive whole number", getenv(envRunsCap), v)
|
|
||||||
}
|
|
||||||
s.CapBytes = int64(n) << 20
|
|
||||||
}
|
|
||||||
for _, d := range []struct {
|
for _, d := range []struct {
|
||||||
env string
|
env string
|
||||||
to *time.Duration
|
to *time.Duration
|
||||||
@@ -416,8 +434,9 @@ func openTestRuns(ctx context.Context, js jetstream.JetStream, cred process.Acco
|
|||||||
hearer.TestRuns, hearer.Clock, hearer.Runs, hearer.DropRun = runs, runs, settings, drop
|
hearer.TestRuns, hearer.Clock, hearer.Runs, hearer.DropRun = runs, runs, settings, drop
|
||||||
hearer.RunOutputs = objects
|
hearer.RunOutputs = objects
|
||||||
if hearer.Ager != nil {
|
if hearer.Ager != nil {
|
||||||
hearer.Ager.Runs, hearer.Ager.RunOutputs, hearer.Ager.RunsKept = runs, objects.Delete, settings.Kept
|
hearer.Ager.Runs, hearer.Ager.RunOutputs, hearer.Ager.RunsKept, hearer.Ager.Clock = runs, objects.Delete, settings.Kept, runs
|
||||||
|
hearer.Ager.RunsFill = starter.TestRunsFill
|
||||||
}
|
}
|
||||||
logf("test runs: cap %d bytes, kept %s, step bound %s, untaken bound %s", settings.CapBytes, settings.Kept, settings.StepBound, settings.Untaken)
|
logf("test runs: the cap is the bucket's max bytes, kept %s, step bound %s, untaken bound %s", settings.Kept, settings.StepBound, settings.Untaken)
|
||||||
return kv, objects, nil
|
return kv, objects, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-14
@@ -40,8 +40,9 @@ import (
|
|||||||
// a run that keeps saying its progress past its bound is not ended,
|
// a run that keeps saying its progress past its bound is not ended,
|
||||||
// and a taken ask silent for its bound ends could not run with its readers, its ask dropped; a second revision with the
|
// and a taken ask silent for its bound ends could not run with its readers, its ask dropped; a second revision with the
|
||||||
// same digests asks its own runs; a seat the seat-holders view names no holder for ends its pipeline failed at once, its
|
// same digests asks its own runs; a seat the seat-holders view names no holder for ends its pipeline failed at once, its
|
||||||
// other steps not asked (A-470g, A-470h); the process answers test-runs with its fill against test-runs-cap-mib and
|
// other steps not asked (A-470g, A-470h); the process answers test-runs with its fill against the bucket's max bytes and
|
||||||
// test-runs-drop deletes the key and its output object (A-470i); at the cap a step ends could not run, naming the fill.
|
// test-runs-drop deletes the key and its output object (A-470i); at nine tenths of the bucket a step's end ages the oldest
|
||||||
|
// ended runs, said in one journal line (H-A-510).
|
||||||
// The step bound is two seconds here, as the setting test-step-bound names it, where the mesh's is 30 minutes.
|
// The step bound is two seconds here, as the setting test-step-bound names it, where the mesh's is 30 minutes.
|
||||||
func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
||||||
url := testbus.URL(t)
|
url := testbus.URL(t)
|
||||||
@@ -63,8 +64,9 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, state := range []string{"bounds", TestRunsState} {
|
// test-runs is 1 MiB here, as the manifest's max-mib makes its bucket: its cap (H-A-510 addendum).
|
||||||
if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: module + "_" + state, History: 1, LimitMarkerTTL: time.Minute}); err != nil {
|
for state, max := range map[string]int64{"bounds": 0, TestRunsState: 1 << 20} {
|
||||||
|
if _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: module + "_" + state, History: 1, LimitMarkerTTL: time.Minute, MaxBytes: max}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +77,10 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
|||||||
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buscompose.LogStreamName(module, seat.StateStepLog), Subjects: []string{buscompose.LogSubject(module, seat.StateStepLog) + ".>"}}); err != nil {
|
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buscompose.LogStreamName(module, seat.StateStepLog), Subjects: []string{buscompose.LogSubject(module, seat.StateStepLog) + ".>"}}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
events, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: process.EventsStream, Subjects: []string{"mesh.mod.*.event.>", "mesh.seat.*.event.>", "mesh.stream.*.event.>"}})
|
// The runner's findings ride its own stream, as its manifest declares, never EVENTS: on EVENTS each one would reach its
|
||||||
|
// main durable unhandled and write event-unhandled again, a flood a take-in on its own durable overtakes (H-A-500 (b)).
|
||||||
|
findingsStream(t, ctx, js, module)
|
||||||
|
events, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: process.EventsStream, Subjects: []string{"mesh.mod.*.event.>", "mesh.seat.*.event.>"}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -201,10 +206,10 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
// The settings, as the manifest's resources write them (A-469x): a cap of 1 MiB, a step bound of two seconds; the
|
// The settings, as the manifest's resources write them (A-469x): a step bound of two seconds; the
|
||||||
// candidates' pipelines run side by side, so pipelines-at-once is its most, 8 (§748).
|
// candidates' pipelines run side by side, so pipelines-at-once is its most, 8 (§748).
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
files := map[string]string{envRunsCap: "1", envStepBound: "2s", envPipelinesAtOnce: "8"}
|
files := map[string]string{envStepBound: "2s", envPipelinesAtOnce: "8"}
|
||||||
env := map[string]string{}
|
env := map[string]string{}
|
||||||
for name, content := range files {
|
for name, content := range files {
|
||||||
path := filepath.Join(dir, name)
|
path := filepath.Join(dir, name)
|
||||||
@@ -224,6 +229,7 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
|||||||
runCtx, stop := context.WithCancel(ctx)
|
runCtx, stop := context.WithCancel(ctx)
|
||||||
done := make(chan error, 1)
|
done := make(chan error, 1)
|
||||||
go func() { done <- run(runCtx, func(k string) string { return env[k] }, logs) }()
|
go func() { done <- run(runCtx, func(k string) string { return env[k] }, logs) }()
|
||||||
|
takeInsHeard(t, ctx, logs)
|
||||||
return func() { stop(); <-done }
|
return func() { stop(); <-done }
|
||||||
}
|
}
|
||||||
stop := start()
|
stop := start()
|
||||||
@@ -548,7 +554,7 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// test-runs is answered by the process, its fill against test-runs-cap-mib (A-470i), each run's packages from its output
|
// test-runs is answered by the process, its fill against the bucket's max bytes (A-470i, H-A-510), each run's packages from its output
|
||||||
// object; test-runs-drop deletes the key and its object (§728).
|
// object; test-runs-drop deletes the key and its object (§728).
|
||||||
var runs seat.TestRunsAnswer
|
var runs seat.TestRunsAnswer
|
||||||
if e := call(seat.VerbTestRuns, seat.TestRunsInput{Candidate: "main.1"}, &runs); e != "" || len(runs.Runs) != 2 || runs.Fill.Cap != 1<<20 || runs.Fill.Store != TestRunsState {
|
if e := call(seat.VerbTestRuns, seat.TestRunsInput{Candidate: "main.1"}, &runs); e != "" || len(runs.Runs) != 2 || runs.Fill.Cap != 1<<20 || runs.Fill.Store != TestRunsState {
|
||||||
@@ -572,8 +578,8 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
|||||||
t.Error("the dropped run's output object is kept")
|
t.Error("the dropped run's output object is kept")
|
||||||
}
|
}
|
||||||
|
|
||||||
// At the cap a step ends could not run, naming the fill (§725, A-469d).
|
// At nine tenths of the bucket a step's end ages the oldest ended runs, said in one journal line (H-A-510).
|
||||||
pad := make([]byte, 600<<10)
|
pad := make([]byte, 470<<10)
|
||||||
for _, k := range []string{"pad.a", "pad.b"} {
|
for _, k := range []string{"pad.a", "pad.b"} {
|
||||||
if _, err := runsKV.Put(ctx, k, pad); err != nil {
|
if _, err := runsKV.Put(ctx, k, pad); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -583,10 +589,9 @@ func TestTestRunsAreAskedOncePerLevelAndMoveEveryReader(t *testing.T) {
|
|||||||
publish(catalog.SubjectCatalogRevision("main"), catalog.CatalogRevisionEvent{V: 1, Revision: 4, Kind: "trunk", Branch: "main", Source: 6})
|
publish(catalog.SubjectCatalogRevision("main"), catalog.CatalogRevisionEvent{V: 1, Revision: 4, Kind: "trunk", Branch: "main", Source: 6})
|
||||||
const p6 = "main.4"
|
const p6 = "main.4"
|
||||||
takeIn("app", "c1", "src2:aa", 6, 4)
|
takeIn("app", "c1", "src2:aa", 6, 4)
|
||||||
waitFor(t, ctx, logs, func() bool {
|
placed(p6)
|
||||||
s := step(read(p6), "app:program", "unit")
|
passBuild(p6, "app", "c1", "src2:aa")
|
||||||
return s.Outcome == seat.StepResultOutcomeCouldNotRun && strings.Contains(s.Why, "test-runs-cap-mib")
|
waitFor(t, ctx, logs, func() bool { return strings.Contains(logs.String(), "of its 1048576 bytes, nine tenths or more") })
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustJSON(v any) []byte {
|
func mustJSON(v any) []byte {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// The test runs' settings reach the process through the files the manifest writes (design 47 G §725; A-469x, A-470a): the
|
// The test runs' settings reach the process through the files the manifest writes (design 47 G §725; A-469x, A-470a): the
|
||||||
// cap a whole number of MiB, the times Go durations, a missing file its default, a content that is neither, or a kept time
|
// times Go durations, test-runs-kept 48h by default (H-A-510), a missing file its default, a content that is no duration,
|
||||||
// past 168h, an error naming the file.
|
// or a kept time past 168h, an error naming the file. The cap is no setting: a cap file is not read (H-A-510 addendum).
|
||||||
func TestTheTestRunsSettingsAreReadFromTheirFiles(t *testing.T) {
|
func TestTheTestRunsSettingsAreReadFromTheirFiles(t *testing.T) {
|
||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
write := func(name, content string) string {
|
write := func(name, content string) string {
|
||||||
@@ -23,20 +23,20 @@ func TestTheTestRunsSettingsAreReadFromTheirFiles(t *testing.T) {
|
|||||||
name string
|
name string
|
||||||
files map[string]string
|
files map[string]string
|
||||||
ok bool
|
ok bool
|
||||||
check func(t *testing.T, cap int64, kept, step, untaken time.Duration)
|
check func(t *testing.T, kept, step, untaken time.Duration)
|
||||||
}{
|
}{
|
||||||
{"defaults", nil, true, func(t *testing.T, cap int64, kept, step, untaken time.Duration) {
|
{"defaults", nil, true, func(t *testing.T, kept, step, untaken time.Duration) {
|
||||||
if cap != 16<<20 || kept != 168*time.Hour || step != 30*time.Minute || untaken != 24*time.Hour {
|
if kept != 48*time.Hour || step != 30*time.Minute || untaken != 24*time.Hour {
|
||||||
t.Errorf("defaults = %d %s %s %s", cap, kept, step, untaken)
|
t.Errorf("defaults = %s %s %s", kept, step, untaken)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
{"set", map[string]string{envRunsCap: "8\n", envRunsKept: "48h", envStepBound: "2s", envUntakenBound: "1m"}, true,
|
{"set", map[string]string{envRunsKept: "72h\n", envStepBound: "2s", envUntakenBound: "1m"}, true,
|
||||||
func(t *testing.T, cap int64, kept, step, untaken time.Duration) {
|
func(t *testing.T, kept, step, untaken time.Duration) {
|
||||||
if cap != 8<<20 || kept != 48*time.Hour || step != 2*time.Second || untaken != time.Minute {
|
if kept != 72*time.Hour || step != 2*time.Second || untaken != time.Minute {
|
||||||
t.Errorf("settings = %d %s %s %s", cap, kept, step, untaken)
|
t.Errorf("settings = %s %s %s", kept, step, untaken)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
{"a cap that is no whole number", map[string]string{envRunsCap: "8.5"}, false, nil},
|
{"a cap file is not read", map[string]string{"MESH_RUNNER_TEST_RUNS_CAP_FILE": "8.5"}, true, nil},
|
||||||
{"a time that is no duration", map[string]string{envStepBound: "30"}, false, nil},
|
{"a time that is no duration", map[string]string{envStepBound: "30"}, false, nil},
|
||||||
{"kept past its maximum", map[string]string{envRunsKept: "169h"}, false, nil},
|
{"kept past its maximum", map[string]string{envRunsKept: "169h"}, false, nil},
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ func TestTheTestRunsSettingsAreReadFromTheirFiles(t *testing.T) {
|
|||||||
t.Fatalf("runSettings = %+v, %v", s, err)
|
t.Fatalf("runSettings = %+v, %v", s, err)
|
||||||
}
|
}
|
||||||
if r.check != nil {
|
if r.check != nil {
|
||||||
r.check(t, s.CapBytes, s.Kept, s.StepBound, s.Untaken)
|
r.check(t, s.Kept, s.StepBound, s.Untaken)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||||
"git.novox.be/novox/mesh-sdk/go/process"
|
"git.novox.be/novox/mesh-sdk/go/process"
|
||||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||||
|
|
||||||
@@ -55,7 +59,7 @@ func writeHandlers(v pipeline.Verbs) map[string]process.SeatHandler {
|
|||||||
seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }),
|
seat.VerbAskAgain: verbOf(func(c string, in seat.AskAgainInput) (any, error) { return v.AskAgain(c, in) }),
|
||||||
// §728, A-469g: a test run's drop is answered by the process, the only writer of pipelines and test-runs.
|
// §728, A-469g: a test run's drop is answered by the process, the only writer of pipelines and test-runs.
|
||||||
seat.VerbTestRunsDrop: verbOf(func(c string, in seat.TestRunsDropInput) (any, error) { return v.TestRunsDrop(c, in) }),
|
seat.VerbTestRunsDrop: verbOf(func(c string, in seat.TestRunsDropInput) (any, error) { return v.TestRunsDrop(c, in) }),
|
||||||
// A-470i: test-runs too, since the process holds test-runs-cap-mib, the cap its fill is said against.
|
// A-470i: test-runs too, since the process reads its fill against the bucket's max bytes (H-A-510).
|
||||||
seat.VerbTestRuns: verbOf(func(_ string, in seat.TestRunsInput) (any, error) { return v.Runs.TestRuns(in) }),
|
seat.VerbTestRuns: verbOf(func(_ string, in seat.TestRunsInput) (any, error) { return v.Runs.TestRuns(in) }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,5 +69,37 @@ func writeVerbs(h *pipeline.Hearer, s *pipeline.Starter, view func(string) (pipe
|
|||||||
candidate := func(group, branch string, revision int64) (pipeline.Half, error) {
|
candidate := func(group, branch string, revision int64) (pipeline.Half, error) {
|
||||||
return readCandidate(calls.CallKept, catalog.CatalogRevisionEvent{Kind: "candidate", Group: group, Branch: branch, Revision: revision})
|
return readCandidate(calls.CallKept, catalog.CatalogRevisionEvent{Kind: "candidate", Group: group, Branch: branch, Revision: revision})
|
||||||
}
|
}
|
||||||
return pipeline.Verbs{Hearer: h, Starter: s, View: view, Candidate: candidate, Acts: meshhandactsclient.Recorder{Ask: calls.Call}}
|
return pipeline.Verbs{Hearer: h, Starter: s, View: view, Candidate: candidate, Acts: meshhandactsclient.Recorder{Ask: calls.Call},
|
||||||
|
RevisionHeld: revisionHeld(calls.CallKept)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// revisionHeld reads the first page of a branch's catalog revision through the catalog seat's verb revision, never a kept
|
||||||
|
// copy, so a rerun reopening an ended pipeline knows whether the catalog still keeps its revision (design 47 H2 H-A-479
|
||||||
|
// addendum (2)): an answer of that revision is kept; none-yet, another revision, or a refusal saying the catalog's
|
||||||
|
// "no such object" is gone (pipeline.ErrRevisionGone); any other failure is said as it is.
|
||||||
|
func revisionHeld(call func(key string, body any) (json.RawMessage, error)) func(string, int64) error {
|
||||||
|
return func(branch string, revision int64) error {
|
||||||
|
raw, err := call(meshcatalogclient.RevisionVerb, catalog.RevisionInput{Branch: keys.EscapeName(branch), Revision: revision})
|
||||||
|
if err != nil {
|
||||||
|
if strings.Contains(err.Error(), "no such object") {
|
||||||
|
return fmt.Errorf("%w: %v", pipeline.ErrRevisionGone, err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
answer, said, ok := buscalls.Unwrap(raw)
|
||||||
|
if !ok {
|
||||||
|
if strings.Contains(said, "no such object") {
|
||||||
|
return fmt.Errorf("%w: %s", pipeline.ErrRevisionGone, said)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("%s answered: %s", meshcatalogclient.RevisionVerb, said)
|
||||||
|
}
|
||||||
|
var a catalog.RevisionAnswer
|
||||||
|
if err := json.Unmarshal(answer, &a); err != nil {
|
||||||
|
return fmt.Errorf("%s answered no revision: %w", meshcatalogclient.RevisionVerb, err)
|
||||||
|
}
|
||||||
|
if a.NoneYet || a.Revision == nil || a.Revision.Revision != revision {
|
||||||
|
return fmt.Errorf("%w: %s answered no revision %d of %s", pipeline.ErrRevisionGone, meshcatalogclient.RevisionVerb, revision, branch)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -38,8 +39,9 @@ func widenerOf(call func(key string, body any) (json.RawMessage, error), bound t
|
|||||||
const (
|
const (
|
||||||
envWidensReadBound = "MESH_RUNNER_WIDENS_READ_BOUND_FILE"
|
envWidensReadBound = "MESH_RUNNER_WIDENS_READ_BOUND_FILE"
|
||||||
envRevisionsKept = "MESH_RUNNER_REVISIONS_KEPT_FILE"
|
envRevisionsKept = "MESH_RUNNER_REVISIONS_KEPT_FILE"
|
||||||
// defaultReadBound is how long one read of widens waits for its answer: a few seconds, never the call's 30.
|
// defaultReadBound is how long one read of widens waits for its answer: 30 s, so a cold grants-for (one that composes a
|
||||||
defaultReadBound = 5 * time.Second
|
// revision's grants the grants part did not keep yet) is not cut (design 47 H2 H-A-478).
|
||||||
|
defaultReadBound = 30 * time.Second
|
||||||
// defaultRevisionsKept is how many catalog revisions the runner keeps once read; a revision of the catalog graph is some 1.4 MB.
|
// defaultRevisionsKept is how many catalog revisions the runner keeps once read; a revision of the catalog graph is some 1.4 MB.
|
||||||
defaultRevisionsKept = 6
|
defaultRevisionsKept = 6
|
||||||
)
|
)
|
||||||
@@ -149,10 +151,17 @@ func catalogRevision(call func(string, any) (json.RawMessage, error), kept *revi
|
|||||||
for {
|
for {
|
||||||
raw, err := call("seat:"+catalog.Seat+"."+catalog.VerbRevision, in)
|
raw, err := call("seat:"+catalog.Seat+"."+catalog.VerbRevision, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// A revision the catalog answers "no such object" for is gone (design 47 H2 H-A-496): a kept mover's wait on it ends.
|
||||||
|
if strings.Contains(err.Error(), "no such object") {
|
||||||
|
return pipeline.Half{}, fmt.Errorf("%w: %v", pipeline.ErrRevisionGone, err)
|
||||||
|
}
|
||||||
return pipeline.Half{}, err
|
return pipeline.Half{}, err
|
||||||
}
|
}
|
||||||
answer, said, ok := buscalls.Unwrap(raw)
|
answer, said, ok := buscalls.Unwrap(raw)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if strings.Contains(said, "no such object") {
|
||||||
|
return pipeline.Half{}, fmt.Errorf("%w: %s answered: %s", pipeline.ErrRevisionGone, catalog.VerbRevision, said)
|
||||||
|
}
|
||||||
return pipeline.Half{}, fmt.Errorf("%s answered: %s", catalog.VerbRevision, said)
|
return pipeline.Half{}, fmt.Errorf("%s answered: %s", catalog.VerbRevision, said)
|
||||||
}
|
}
|
||||||
var a catalog.RevisionAnswer
|
var a catalog.RevisionAnswer
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -63,6 +64,19 @@ func TestCatalogRevisionIsKeptOnceRead(t *testing.T) {
|
|||||||
if h, err := read("main", 0); err != nil || calls != 3 || len(h.Entries) != 2 {
|
if h, err := read("main", 0); err != nil || calls != 3 || len(h.Entries) != 2 {
|
||||||
t.Fatalf("the newest made calls %d, %+v, %v; want its first page only", calls, h, err)
|
t.Fatalf("the newest made calls %d, %+v, %v; want its first page only", calls, h, err)
|
||||||
}
|
}
|
||||||
|
// A revision the catalog answers "no such object" for is gone, whether refused or answered so (design 47 H2 H-A-496).
|
||||||
|
for _, gone := range []func(string, any) (json.RawMessage, error){
|
||||||
|
func(string, any) (json.RawMessage, error) {
|
||||||
|
return nil, fmt.Errorf("revision main.292: no such object")
|
||||||
|
},
|
||||||
|
func(string, any) (json.RawMessage, error) {
|
||||||
|
return json.RawMessage(`{"content":[{"text":"revision main.292: no such object"}],"isError":true}`), nil
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
if _, err := catalogRevision(gone, newRevisionCache(1))("main", 292); !errors.Is(err, pipeline.ErrRevisionGone) {
|
||||||
|
t.Errorf("a revision the catalog has no object of reads %v, want it gone", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
c := newRevisionCache(1)
|
c := newRevisionCache(1)
|
||||||
c.put("main", pipeline.Half{Revision: 1})
|
c.put("main", pipeline.Half{Revision: 1})
|
||||||
c.put("main", pipeline.Half{Revision: 2})
|
c.put("main", pipeline.Half{Revision: 2})
|
||||||
@@ -115,7 +129,7 @@ func TestWidensSettings(t *testing.T) {
|
|||||||
kept int
|
kept int
|
||||||
ok bool
|
ok bool
|
||||||
}{
|
}{
|
||||||
{"defaults", nil, 5 * time.Second, 6, true},
|
{"defaults", nil, 30 * time.Second, 6, true},
|
||||||
{"set", map[string]string{envWidensReadBound: "2s\n", envRevisionsKept: "3\n"}, 2 * time.Second, 3, true},
|
{"set", map[string]string{envWidensReadBound: "2s\n", envRevisionsKept: "3\n"}, 2 * time.Second, 3, true},
|
||||||
{"no duration", map[string]string{envWidensReadBound: "5"}, 0, 0, false},
|
{"no duration", map[string]string{envWidensReadBound: "5"}, 0, 0, false},
|
||||||
{"no number", map[string]string{envRevisionsKept: "0"}, 0, 0, false},
|
{"no number", map[string]string{envRevisionsKept: "0"}, 0, 0, false},
|
||||||
|
|||||||
@@ -57,7 +57,12 @@ type Ager struct {
|
|||||||
Runs TestRuns
|
Runs TestRuns
|
||||||
RunOutputs func(name string) error
|
RunOutputs func(name string) error
|
||||||
RunsKept time.Duration
|
RunsKept time.Duration
|
||||||
Now func() time.Time
|
// RunsFill is test-runs' fill against its bucket's max bytes (Starter.TestRunsFill): at nine tenths of it the oldest
|
||||||
|
// ended runs are deleted, their outputs with them, until it is under eight tenths (H-A-510); nil ages by time only.
|
||||||
|
RunsFill func() (seat.Fill, error)
|
||||||
|
// Clock is test-runs' bound and ask keys: a run's ask keys are deleted with the run (H-A-500 addendum (1)); nil keeps them.
|
||||||
|
Clock RunClock
|
||||||
|
Now func() time.Time
|
||||||
// Logf is the runner's journal: each delete writes a line naming the key or object and its retention.
|
// Logf is the runner's journal: each delete writes a line naming the key or object and its retention.
|
||||||
Logf func(string, ...any)
|
Logf func(string, ...any)
|
||||||
}
|
}
|
||||||
@@ -82,13 +87,97 @@ func (a *Ager) Age() {
|
|||||||
}
|
}
|
||||||
retentions = append([]Retention{{RetentionTestRuns, kept}}, retentions...)
|
retentions = append([]Retention{{RetentionTestRuns, kept}}, retentions...)
|
||||||
}
|
}
|
||||||
for _, r := range retentions {
|
for i, r := range retentions {
|
||||||
if err := a.ageAt(r); err != nil {
|
if err := a.ageAt(r); err != nil {
|
||||||
a.logf("aged: the data past %s are not aged: %v", r.Name, err)
|
a.logf("aged: the data past %s are not aged: %v", r.Name, err)
|
||||||
}
|
}
|
||||||
|
// By fill after by time, before the pipelines age, so the pipeline that names a run's key is still kept.
|
||||||
|
if i == 0 && a.Runs != nil {
|
||||||
|
if err := a.ageByFill(); err != nil {
|
||||||
|
a.logf("aged: the test runs are not aged by their fill: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The fill of test-runs, in tenths of its cap, at which the Ager deletes its oldest ended runs and under which it stops
|
||||||
|
// (H-A-510).
|
||||||
|
const (
|
||||||
|
runsFillAgeTenths = 9
|
||||||
|
runsFillUnderTenths = 8
|
||||||
|
)
|
||||||
|
|
||||||
|
// ageByFill deletes the oldest ended test runs, with their output objects, once test-runs holds nine tenths of its cap,
|
||||||
|
// until it holds under eight tenths (H-A-510): in the step log's order onward from the test runs' retention, as the Ager
|
||||||
|
// ages by time (§330), so nothing is scanned whole; a run not ended is never deleted. It says how many and how old in one
|
||||||
|
// journal line.
|
||||||
|
func (a *Ager) ageByFill() error {
|
||||||
|
if a.RunsFill == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
f, err := a.RunsFill()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if f.Cap <= 0 || f.Bytes*10 < f.Cap*runsFillAgeTenths {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
now := time.Now().UTC()
|
||||||
|
if a.Now != nil {
|
||||||
|
now = a.Now().UTC()
|
||||||
|
}
|
||||||
|
held := f.Bytes
|
||||||
|
last, err := a.Aged.Get(RetentionTestRuns)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
moved, deleted := last, 0
|
||||||
|
var oldest, newest time.Time
|
||||||
|
defer func() {
|
||||||
|
if moved != last {
|
||||||
|
if err := a.Aged.Put(RetentionTestRuns, moved); err != nil {
|
||||||
|
a.logf("aged: the test runs' retention is not moved to %d: %v", moved, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
for f.Bytes*10 >= f.Cap*runsFillUnderTenths {
|
||||||
|
entries, err := a.Log(moved+1, AgedPerStep)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(entries) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for _, e := range entries {
|
||||||
|
moved = e.Sequence
|
||||||
|
_, ended, ok := a.deleteRun(e.Entry)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
deleted++
|
||||||
|
if oldest.IsZero() || ended.Before(oldest) {
|
||||||
|
oldest = ended
|
||||||
|
}
|
||||||
|
if ended.After(newest) {
|
||||||
|
newest = ended
|
||||||
|
}
|
||||||
|
if f, err = a.RunsFill(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if f.Bytes*10 < f.Cap*runsFillUnderTenths {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if deleted == 0 {
|
||||||
|
a.logf("aged: the state test-runs holds %d of its %d bytes, nine tenths or more, and no ended test run is left to delete in the step log", held, f.Cap)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
a.logf("aged: the state test-runs held %d of its %d bytes, nine tenths or more, so %d ended test runs and their outputs were deleted, ended %s to %s ago; it holds %d bytes now",
|
||||||
|
held, f.Cap, deleted, now.Sub(oldest).Round(time.Second), now.Sub(newest).Round(time.Second), f.Bytes)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Ager) ageAt(r Retention) error {
|
func (a *Ager) ageAt(r Retention) error {
|
||||||
now := time.Now().UTC()
|
now := time.Now().UTC()
|
||||||
if a.Now != nil {
|
if a.Now != nil {
|
||||||
@@ -120,14 +209,21 @@ func (a *Ager) ageAt(r Retention) error {
|
|||||||
const RetentionTestRuns = "test-runs"
|
const RetentionTestRuns = "test-runs"
|
||||||
|
|
||||||
// ageRun deletes the test run the ended step of e read, and its output object, once its kept time has passed since the
|
// ageRun deletes the test run the ended step of e read, and its output object, once its kept time has passed since the
|
||||||
// step's end, in the step log's order (§725, A-470a): the run's key is read from e's pipeline, its step's Shared run.
|
// step's end, in the step log's order (§725, A-470a), said in a line.
|
||||||
func (a *Ager) ageRun(r Retention, e seat.LogEntry) {
|
func (a *Ager) ageRun(r Retention, e seat.LogEntry) {
|
||||||
if e.What != seat.LogEntryWhatEnded {
|
if run, _, ok := a.deleteRun(e); ok {
|
||||||
return
|
a.logf("aged: deleted the test run %s and its output (%s after its end)", run, r.Age)
|
||||||
}
|
}
|
||||||
p, _, err := a.Pipelines.Get(e.Pipeline)
|
}
|
||||||
|
|
||||||
|
// runOfEntry is the run the ended step of e read: its step's Shared run in e's pipeline, empty when it reads none.
|
||||||
|
func runOfEntry(pipelines Updater, e seat.LogEntry) string {
|
||||||
|
if e.What != seat.LogEntryWhatEnded {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
p, _, err := pipelines.Get(e.Pipeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return ""
|
||||||
}
|
}
|
||||||
run := ""
|
run := ""
|
||||||
for _, s := range p.Steps {
|
for _, s := range p.Steps {
|
||||||
@@ -135,20 +231,27 @@ func (a *Ager) ageRun(r Retention, e seat.LogEntry) {
|
|||||||
run = sharedRun(s)
|
run = sharedRun(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return run
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteRun deletes the ended test run the ended step of e read, and its output object, and answers its end: the run's key
|
||||||
|
// is read from e's pipeline, its step's Shared run. A run not ended is kept, and so is one whose output is not deleted.
|
||||||
|
func (a *Ager) deleteRun(e seat.LogEntry) (string, time.Time, bool) {
|
||||||
|
run := runOfEntry(a.Pipelines, e)
|
||||||
if run == "" {
|
if run == "" {
|
||||||
return
|
return run, time.Time{}, false
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
t, rev, err := a.Runs.Get(run)
|
t, rev, err := a.Runs.Get(run)
|
||||||
// The entry is past the retention (ageAt), and a run ends no later than the reader's end it was read at: a run not
|
// The entry is past the retention (ageAt), and a run ends no later than the reader's end it was read at: a run not
|
||||||
// ended yet is aged at a later reader's end.
|
// ended yet is aged at a later reader's end.
|
||||||
if err != nil || t.Ended == nil {
|
if err != nil || t.Ended == nil {
|
||||||
return
|
return run, time.Time{}, false
|
||||||
}
|
}
|
||||||
if t.Output != "" && a.RunOutputs != nil {
|
if t.Output != "" && a.RunOutputs != nil {
|
||||||
if err := a.RunOutputs(t.Output); err != nil {
|
if err := a.RunOutputs(t.Output); err != nil {
|
||||||
a.logf("aged: the output %s of the test run %s is not deleted, so the run is kept: %v", t.Output, run, err)
|
a.logf("aged: the output %s of the test run %s is not deleted, so the run is kept: %v", t.Output, run, err)
|
||||||
return
|
return run, time.Time{}, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Deleted at the revision read: a rerun that wrote the key again since is read again, and a run it started is kept.
|
// Deleted at the revision read: a rerun that wrote the key again since is read again, and a run it started is kept.
|
||||||
@@ -156,10 +259,10 @@ func (a *Ager) ageRun(r Retention, e seat.LogEntry) {
|
|||||||
continue
|
continue
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
a.logf("aged: the test run %s is not deleted: %v", run, err)
|
a.logf("aged: the test run %s is not deleted: %v", run, err)
|
||||||
return
|
return run, time.Time{}, false
|
||||||
}
|
}
|
||||||
a.logf("aged: deleted the test run %s and its output (%s after its end)", run, r.Age)
|
unmarkAsks(a.Clock, run, a.logf)
|
||||||
return
|
return run, *t.Ended, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,10 +53,19 @@ func TestAnAsksBoundCountsFromThePullAndEndsItsStep(t *testing.T) {
|
|||||||
}
|
}
|
||||||
p.Steps[stepIndex(p, "lint", "app:program")].Outcome = seat.StepResultOutcomeFailed
|
p.Steps[stepIndex(p, "lint", "app:program")].Outcome = seat.StepResultOutcomeFailed
|
||||||
store.Update(pkey, p, rev)
|
store.Update(pkey, p, rev)
|
||||||
|
old := p.Steps[stepIndex(p, "lint", "app:program")].Ask
|
||||||
|
_ = v.Hearer.Clock.MarkAsk(old, AskMark{Pipeline: pkey, Module: "app", Step: "lint"})
|
||||||
r, err := v.Rerun("operator", seat.RerunInput{Pipeline: pkey, Step: "lint", Artifact: "app:program", Why: "retry"})
|
r, err := v.Rerun("operator", seat.RerunInput{Pipeline: pkey, Step: "lint", Artifact: "app:program", Why: "retry"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
// The step asked again keeps one ask key, its new ask's: the earlier one is deleted (H-A-506 addendum).
|
||||||
|
if _, had, _ := v.Hearer.Clock.AskOf(old); had {
|
||||||
|
t.Errorf("the ask key of the earlier ask %s outlives the rerun", old)
|
||||||
|
}
|
||||||
|
if m, ok, _ := v.Hearer.Clock.AskOf(r.Result.Ask); !ok || m.Pipeline != pkey || m.Step != "lint" {
|
||||||
|
t.Errorf("the rerun's ask key = %+v, %v; want it naming %s's lint step", m, ok, pkey)
|
||||||
|
}
|
||||||
ask, key := r.Result.Ask, AskBoundKey(nodebuildgo.Seat, r.Result.Ask)
|
ask, key := r.Result.Ask, AskBoundKey(nodebuildgo.Seat, r.Result.Ask)
|
||||||
if want := []string{key + " 10m0s"}; !slices.Equal(armed, want) || len(asks.ids) != 1 {
|
if want := []string{key + " 10m0s"}; !slices.Equal(armed, want) || len(asks.ids) != 1 {
|
||||||
t.Fatalf("armed %v asking %v, want %v before one ask", armed, asks.ids, want)
|
t.Fatalf("armed %v asking %v, want %v before one ask", armed, asks.ids, want)
|
||||||
@@ -110,15 +119,17 @@ func TestAnAsksBoundCountsFromThePullAndEndsItsStep(t *testing.T) {
|
|||||||
if !slices.Equal(raised, []string{nodebuildgo.Seat + " " + ask}) || !slices.Contains(*said, "pipeline-ended.main.5") {
|
if !slices.Equal(raised, []string{nodebuildgo.Seat + " " + ask}) || !slices.Contains(*said, "pipeline-ended.main.5") {
|
||||||
t.Errorf("raised %v, said %v", raised, *said)
|
t.Errorf("raised %v, said %v", raised, *said)
|
||||||
}
|
}
|
||||||
// A bound whose step ended asks nothing; the step's end deletes the bound; a late ask-taken clears the finding.
|
// A bound whose step ended asks nothing; the step's end deletes the bound; a late ask-taken after the pipeline's
|
||||||
|
// end clears nothing: the end deleted the ask's key, so the finding stands as what happened (H-A-506 second
|
||||||
|
// addendum; H-A-238 (2) holds while the pipeline runs).
|
||||||
if err := v.AskUnanswered(nodebuildgo.Seat, ask); err != nil || len(asks.ids) != 1 || len(dropped) != 1 {
|
if err := v.AskUnanswered(nodebuildgo.Seat, ask); err != nil || len(asks.ids) != 1 || len(dropped) != 1 {
|
||||||
t.Errorf("a bound of an ended step asked %v, dropped %v (%v)", asks.ids, dropped, err)
|
t.Errorf("a bound of an ended step asked %v, dropped %v (%v)", asks.ids, dropped, err)
|
||||||
}
|
}
|
||||||
if err := c.Ended(nodebuildgo.Seat, ask); err != nil || !slices.Equal(unbound, []string{key}) {
|
if err := c.Ended(nodebuildgo.Seat, ask); err != nil || !slices.Equal(unbound, []string{key}) {
|
||||||
t.Errorf("the step's end deleted %v (%v)", unbound, err)
|
t.Errorf("the step's end deleted %v (%v)", unbound, err)
|
||||||
}
|
}
|
||||||
if _, err := v.Hearer.Taken(ask, "n2", now); err != nil || !slices.Equal(cleared, []string{nodebuildgo.Seat + " " + ask}) {
|
if _, err := v.Hearer.Taken(ask, "n2", now); err != nil || len(cleared) != 0 {
|
||||||
t.Errorf("a late ask-taken cleared %v (%v)", cleared, err)
|
t.Errorf("a late ask-taken after the pipeline's end cleared %v (%v), want nothing", cleared, err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ func (h *Hearer) putDeclined(key, old string, s seat.StepResult, a Asked, ev Ste
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unmarkAsk(h.Clock, old, h.logf) // one key per ask, gone once the ask is no longer open (H-A-506 addendum, corrected)
|
||||||
h.logf("%s: the %s step of %s was declined on %s (%s): asked again as %s, not on %s (H-A-445)", key, s.Step,
|
h.logf("%s: the %s step of %s was declined on %s (%s): asked again as %s, not on %s (H-A-445)", key, s.Step,
|
||||||
strings.TrimSpace(s.Module+" "+s.Artifact), ev.Node, ev.Said, a.ID, strings.Join(s.NotOn, ", "))
|
strings.TrimSpace(s.Module+" "+s.Artifact), ev.Node, ev.Said, a.ID, strings.Join(s.NotOn, ", "))
|
||||||
return h.PutAgain(key, a)
|
return h.PutAgain(key, a)
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
package pipeline
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
|
||||||
|
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||||
|
wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||||
|
)
|
||||||
|
|
||||||
|
// dropSeat says whether the holder of a seat serves the seat's drop of an ask the runner put on it: every seat whose
|
||||||
|
// holder says ask-taken, the three build seats, mesh-builds and mesh-wants (AskTakenSeats).
|
||||||
|
func dropSeat(name string) bool {
|
||||||
|
for _, s := range AskTakenSeats {
|
||||||
|
if s.Seat == name {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// openAtEnd are copies of the steps of steps that an end of their pipeline takes while still asked (design 47 H2
|
||||||
|
// H-A-506): an open step with an ask of its own, and a step reading a test run, open or waiting, which leaves it. Read
|
||||||
|
// before the end is written, since the end rewrites the steps.
|
||||||
|
func openAtEnd(steps []seat.StepResult) []seat.StepResult {
|
||||||
|
var out []seat.StepResult
|
||||||
|
for _, s := range steps {
|
||||||
|
asked := open(s) && s.Ask != ""
|
||||||
|
reads := sharedRun(s) != "" && s.Seat != wants.Seat && (open(s) || s.Outcome == seat.StepResultOutcomeWaiting)
|
||||||
|
if asked || reads {
|
||||||
|
out = append(out, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DropOpen takes the steps of pipeline key that its end took while asked (openAtEnd) off the seats (design 47 H2
|
||||||
|
// H-A-506 as corrected): a step reading a test run leaves it (leaveRun), the run's ask dropped only by its last reader's
|
||||||
|
// leave; every other own ask still open, a mesh-wants step's included, is dropped through its seat's drop, so its holder
|
||||||
|
// refuses it unrun and no build capacity goes to an ended pipeline. Each drop and each refusal is said in one journal line
|
||||||
|
// per ask; a drop that is not answered fails nothing. The leaves are written before it answers; the drops are asked beside
|
||||||
|
// the path that ended the pipeline (Aside), since a seat with no holder answers a kept call only at its bound, so a cancel
|
||||||
|
// is answered at once whatever its seats.
|
||||||
|
func (h *Hearer) DropOpen(key string, steps []seat.StepResult, why string) {
|
||||||
|
done := map[string]bool{}
|
||||||
|
var drops []seat.StepResult
|
||||||
|
for _, st := range steps {
|
||||||
|
if sharedRun(st) != "" && st.Seat != wants.Seat {
|
||||||
|
// A shared test run's ask is dropped only by its last reader's leave, never while another pipeline reads it
|
||||||
|
// (H-A-506 corrected).
|
||||||
|
h.leaveRun(key, st, why)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !open(st) || st.Ask == "" || done[st.Ask] || !dropSeat(st.Seat) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
done[st.Ask] = true
|
||||||
|
if h.DropRun == nil {
|
||||||
|
h.logf("%s: the ask %s of %s's %s on %s is not dropped: the runner has no drop (H-A-506)", key, st.Ask, st.Module, st.Step, st.Seat)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
drops = append(drops, st)
|
||||||
|
}
|
||||||
|
for _, st := range drops {
|
||||||
|
h.aside(func() {
|
||||||
|
if err := h.DropRun(st.Seat, st.Node, st.Ask, why); err != nil {
|
||||||
|
h.logf("%s: the drop of the ask %s of %s's %s is refused or not answered by %s: %v (H-A-506)", key, st.Ask, st.Module, st.Step, st.Seat, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.logf("%s: the ask %s of %s's %s on %s is dropped (H-A-506)", key, st.Ask, st.Module, st.Step, st.Seat)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// aside runs do through Aside, in place when there is none.
|
||||||
|
func (h *Hearer) aside(do func()) {
|
||||||
|
if h.Aside == nil {
|
||||||
|
do()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.Aside(do)
|
||||||
|
}
|
||||||
|
|
||||||
|
// endedOpen are the steps of prior, a pipeline's steps read before a placing that ended it, which the end took while asked
|
||||||
|
// (openAtEnd): those no longer open in steps, the steps as written, the same index naming the same step since a placing only
|
||||||
|
// appends. An ask in unput, placed but never put, is no ask of a seat and is left out.
|
||||||
|
func endedOpen(prior, steps []seat.StepResult, unput []Asked) []seat.StepResult {
|
||||||
|
var out []seat.StepResult
|
||||||
|
for i, s := range prior {
|
||||||
|
if i >= len(steps) || open(steps[i]) || len(openAtEnd([]seat.StepResult{s})) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if s.Ask != "" && slices.ContainsFunc(unput, func(a Asked) bool { return a.ID == s.Ask }) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
out = append(out, s)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// dropEnded drops, through Drop, the asks the placing end of pipeline p took while open (H-A-506); a pipeline not ended
|
||||||
|
// drops nothing.
|
||||||
|
func (s *Starter) dropEnded(p seat.Pipeline, prior []seat.StepResult, unput []Asked) {
|
||||||
|
if p.Ended == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
steps := endedOpen(prior, p.Steps, unput)
|
||||||
|
if s.Drop != nil && len(steps) > 0 {
|
||||||
|
s.Drop(p.Pipeline, steps, "the pipeline "+p.Pipeline+" ended "+p.Outcome+": "+p.Why)
|
||||||
|
}
|
||||||
|
// The end cleared these steps' asks, so their ask keys go here, not with the end's own (H-A-506 addendum); a shared
|
||||||
|
// test run's key goes with the run's end (H-A-506 corrected).
|
||||||
|
for _, st := range steps {
|
||||||
|
if sharedRun(st) == "" || st.Seat == wants.Seat { // only a test run's key waits for the run's end
|
||||||
|
unmarkAsk(s.Clock, st.Ask, s.logf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user