AS23: build.ended says a failed end too; a hold under rule 1 says how the build stands
The builder's build.ended is said for a failed build as well (outcome, error whole); the assigner's rule-1 hold reads "the build of M at F failed: <error>" from it and "is being built" while none is heard. The assigner's reads of the builder's builds bucket stay (see the report: a restarted assigner holds no ends heard). Builds: design 47 G §575, §568, A-162 (survey AS23) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -17,11 +17,19 @@ const (
|
||||
// BuildEnded is the body of the event build.ended: the module, the fingerprint, each artifact made with its digest, the build
|
||||
// node that keeps a kept build (none for one not kept) and the watched branch a build of a candidate is for (none for the trunk).
|
||||
type BuildEnded struct {
|
||||
Module string `json:"module"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
Made map[string]string `json:"made,omitempty"`
|
||||
KeptOn string `json:"kept-on,omitempty"`
|
||||
Branch string `json:"branch,omitempty"`
|
||||
Module string `json:"module"`
|
||||
Fingerprint string `json:"fingerprint"`
|
||||
// Outcome is done or failed (design 47 G §575, A-162): the event is said for every end that is one of these; Error is why a
|
||||
// failed build failed, as its key holds it (`transport fault:` included, §568), none for a done one.
|
||||
Outcome string `json:"outcome"`
|
||||
Error string `json:"error,omitempty"`
|
||||
// Manifest is the digest of the manifest built and Needs the reader capabilities its reference forms need (ADR 0618 §1), of a
|
||||
// done build: what a reader of the end asks of the builder's key otherwise.
|
||||
Manifest string `json:"manifest,omitempty"`
|
||||
Needs []string `json:"needs,omitempty"`
|
||||
Made map[string]string `json:"made,omitempty"`
|
||||
KeptOn string `json:"kept-on,omitempty"`
|
||||
Branch string `json:"branch,omitempty"`
|
||||
}
|
||||
|
||||
// BuildEndedEventName is the event's name for a module and fingerprint: `build.ended.<module>.<fingerprint>`, each escaped.
|
||||
@@ -29,15 +37,15 @@ func BuildEndedEventName(module, fp string) string {
|
||||
return BuildEndedEvent + "." + keys.EscapeName(module) + "." + keys.EscapeName(fp)
|
||||
}
|
||||
|
||||
// BuildEndedOf is the event of a log entry of a build's end: false for any entry but the end of a done build, which says no
|
||||
// BuildEndedOf is the event of a log entry of a build's end: false for any entry but the end of a done or a failed build. A done end says no
|
||||
// digest of any part.
|
||||
func BuildEndedOf(e BuildLogEntry) (BuildEnded, bool) {
|
||||
if e.Event != BuildEndedEvent || e.Outcome != BuildDone || e.Module == "" || e.FP == "" {
|
||||
if e.Event != BuildEndedEvent || (e.Outcome != BuildDone && e.Outcome != BuildFailed) || e.Module == "" || e.FP == "" {
|
||||
return BuildEnded{}, false
|
||||
}
|
||||
made := map[string]string{}
|
||||
for _, a := range e.Made {
|
||||
made[a.Name] = a.Digest
|
||||
}
|
||||
return BuildEnded{Module: e.Module, Fingerprint: e.FP, Made: made, KeptOn: e.KeptOn, Branch: e.Ref}, true
|
||||
return BuildEnded{Module: e.Module, Fingerprint: e.FP, Outcome: e.Outcome, Error: e.Error, Manifest: e.Manifest, Needs: e.Needs, Made: made, KeptOn: e.KeptOn, Branch: e.Ref}, true
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestADoneBuildsEndIsTheEventBuildEnded(t *testing.T) {
|
||||
made := []BuiltArtifact{{Name: "program", Kind: "program", Digest: "sha256:1"}}
|
||||
e := BuildLogEntry{Event: BuildEndedEvent, Outcome: BuildDone, Module: "node-engine", FP: "src2:a", Ref: "cand", KeptOn: "ace", Made: made}
|
||||
got, ok := BuildEndedOf(e)
|
||||
want := BuildEnded{Module: "node-engine", Fingerprint: "src2:a", Made: map[string]string{"program": "sha256:1"}, KeptOn: "ace", Branch: "cand"}
|
||||
want := BuildEnded{Module: "node-engine", Fingerprint: "src2:a", Outcome: BuildDone, Made: map[string]string{"program": "sha256:1"}, KeptOn: "ace", Branch: "cand"}
|
||||
if !ok || !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("event = %+v, %v", got, ok)
|
||||
}
|
||||
@@ -20,7 +20,7 @@ func TestADoneBuildsEndIsTheEventBuildEnded(t *testing.T) {
|
||||
}
|
||||
for name, mut := range map[string]func(*BuildLogEntry){
|
||||
"started": func(e *BuildLogEntry) { e.Event = BuildStartedEvent },
|
||||
"failed": func(e *BuildLogEntry) { e.Outcome = BuildFailed },
|
||||
"queued": func(e *BuildLogEntry) { e.Outcome = BuildQueued },
|
||||
"no fp": func(e *BuildLogEntry) { e.FP = "" },
|
||||
} {
|
||||
c := e
|
||||
@@ -30,3 +30,13 @@ func TestADoneBuildsEndIsTheEventBuildEnded(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 G §575, A-162: a failed build's end is said too, with its outcome and its error whole.
|
||||
func TestAFailedBuildsEndIsSaidWithItsError(t *testing.T) {
|
||||
e := BuildLogEntry{Event: BuildEndedEvent, Outcome: BuildFailed, Module: "web", FP: "src2:b", Error: "transport fault: no responders at mesh-build-go"}
|
||||
got, ok := BuildEndedOf(e)
|
||||
want := BuildEnded{Module: "web", Fingerprint: "src2:b", Outcome: BuildFailed, Error: e.Error, Made: map[string]string{}}
|
||||
if !ok || !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("event = %+v, %v", got, ok)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,9 @@ type BuildLogEntry struct {
|
||||
// narration names neither.
|
||||
Error string `json:"error,omitempty"`
|
||||
Step string `json:"step,omitempty"`
|
||||
// Needs are, at a done build's end, the reader capabilities its reference forms need (BuilderBuild.Needs, ADR 0618 §1): the end
|
||||
// event carries them (design 47 G §575, A-162).
|
||||
Needs []string `json:"needs,omitempty"`
|
||||
// Line is a narration's words, Why what it narrates (asked, waiting, stored, refused): a build.said entry's alone.
|
||||
Line string `json:"line,omitempty"`
|
||||
Why string `json:"why,omitempty"`
|
||||
|
||||
@@ -594,7 +594,7 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
t.Errorf("no build.ended of netcheck's build: %v", err)
|
||||
} else {
|
||||
var ev builds.BuildEnded
|
||||
if err := json.Unmarshal(raw.Data, &ev); err != nil || ev.Module != "netcheck" || ev.Fingerprint != fp || len(ev.Made) != 2 {
|
||||
if err := json.Unmarshal(raw.Data, &ev); err != nil || ev.Module != "netcheck" || ev.Fingerprint != fp || ev.Outcome != builds.BuildDone || len(ev.Made) != 2 {
|
||||
t.Errorf("build.ended = %s (%v), want netcheck at its fingerprint with two artifacts' digests", raw.Data, err)
|
||||
}
|
||||
}
|
||||
@@ -656,9 +656,18 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
b.fake.hang.Store(&release)
|
||||
third := "src2:" + strings.Repeat("4", 64)
|
||||
b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, commit, third, 3)
|
||||
if f := b.awaitFP(t, "netcheck", third, isState(builds.BuildFailed)); !strings.Contains(f.Error, "did not end within") {
|
||||
f := b.awaitFP(t, "netcheck", third, isState(builds.BuildFailed))
|
||||
if !strings.Contains(f.Error, "did not end within") {
|
||||
t.Errorf("the failed build = %+v, want its bound run out", f)
|
||||
}
|
||||
// A-162: the failed end is said as build.ended too, with its error whole.
|
||||
if st, err := b.js.Stream(b.ctx, "BUILDER_BUILDS"); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if raw, err := st.GetLastMsgForSubject(b.ctx, "mesh.stream.mesh-delivery-builder.event."+builds.BuildEndedEventName("netcheck", third)); err != nil {
|
||||
t.Errorf("no build.ended of netcheck's failed build: %v", err)
|
||||
} else if ev := (builds.BuildEnded{}); json.Unmarshal(raw.Data, &ev) != nil || ev.Outcome != builds.BuildFailed || ev.Error != f.Error {
|
||||
t.Errorf("build.ended = %s, want the failed outcome with the error %q", raw.Data, f.Error)
|
||||
}
|
||||
failed := meshconditionsclient.Key(meshconditionsclient.ScopeModule, "netcheck", BuildFailed)
|
||||
reg.awaitFinding(t, failed, true)
|
||||
b.fake.hang.Store(nil)
|
||||
|
||||
@@ -161,9 +161,9 @@ func appendLog(ctx context.Context, js jetstream.JetStream, cred process.Account
|
||||
return nil
|
||||
}
|
||||
|
||||
// emitBuildEnded says the builder's event build.ended of a done build, on the builder's own stream (design 47 G §379, A-96):
|
||||
// emitBuildEnded says the builder's event build.ended of a done or failed build (A-162), on the builder's own stream (design 47 G §379, A-96):
|
||||
// mesh.stream.<module>.event.build.ended.<module>.<fingerprint>, published where the log entry of the end is written. An
|
||||
// entry that is not a done build's end says none. The id makes a repeated end one event.
|
||||
// entry that is not a done or failed build's end says none. The id makes a repeated end one event.
|
||||
func emitBuildEnded(ctx context.Context, js jetstream.JetStream, cred process.Account, e builds.BuildLogEntry) error {
|
||||
body, ok := builds.BuildEndedOf(e)
|
||||
if !ok {
|
||||
|
||||
@@ -1208,6 +1208,7 @@ func LogEnded(module string, m meshcatalog.ModulesByModuleValue, ref, by string,
|
||||
e.KeptOn = result.KeptOn
|
||||
e.Imports = append([]string(nil), result.Imports...) // the indexer keeps them on the module (novox/hq ADR 0593 §2)
|
||||
e.Error, e.Step = result.Error, result.Step // a failed build's reason, not only its outcome
|
||||
e.Needs = append([]string(nil), result.Needs...)
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user