Merge fix/1121-holds-released: delivery 2 on the builds' new layout (issue 1121)
Delivery 2 deleted the move and chain_moved, so the layout of the builds under their modules is made by the controller's start (LayBuildsOut), recorded by the key layout.done in the builds bucket, retried every half minute with an urgent condition while it fails; the chain on the bus is refused until it exists. Its source readers use the module and pointer reads.
This commit is contained in:
@@ -2,7 +2,8 @@ package inventory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/novox/mesh-controller/internal/chain"
|
||||
)
|
||||
|
||||
// A build whose source is unchanged is never a move (novox/hq issue 280).
|
||||
@@ -26,6 +27,7 @@ type sourceRow struct {
|
||||
id, commit, fingerprint string
|
||||
made []byte
|
||||
manifest []byte
|
||||
manifestDigest string
|
||||
failedGate bool
|
||||
}
|
||||
|
||||
@@ -69,6 +71,15 @@ func (i *Inventory) StandingBuild(ctx context.Context, module, build string) (st
|
||||
for k, b := range builds {
|
||||
if b.id == build {
|
||||
s := builds[standing(builds, k)]
|
||||
if len(s.manifest) == 0 && s.manifestDigest != "" {
|
||||
// The manifest is kept apart from the record (issue 1121): one Get.
|
||||
c, err := i.theChain(ctx)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
raw, err := manifestOfRecord(ctx, c, chain.Build{ID: s.id, ManifestDigest: s.manifestDigest})
|
||||
return s.id, raw, err
|
||||
}
|
||||
return s.id, s.manifest, nil
|
||||
}
|
||||
}
|
||||
@@ -78,59 +89,32 @@ func (i *Inventory) StandingBuild(ctx context.Context, module, build string) (st
|
||||
// SourceFingerprints is, per module, per commit, the source fingerprint of the newest successful build
|
||||
// from it that has one: module → commit → fingerprint. A commit whose builds carry none is absent.
|
||||
func (i *Inventory) SourceFingerprints(ctx context.Context) (map[string]map[string]string, error) {
|
||||
all, _, err := i.sourceRows(ctx, "")
|
||||
c, err := i.theChain(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := map[string]map[string]string{}
|
||||
for m, builds := range all {
|
||||
for _, b := range builds {
|
||||
if b.fingerprint == "" || b.commit == "" {
|
||||
continue
|
||||
}
|
||||
if out[m] == nil {
|
||||
out[m] = map[string]string{}
|
||||
}
|
||||
if _, seen := out[m][b.commit]; !seen {
|
||||
out[m][b.commit] = b.fingerprint
|
||||
}
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
// Read from the commit pointers, which carry each commit's source fingerprint: no record is read (issue 1121).
|
||||
return i.chainSourceFingerprints(ctx, c)
|
||||
}
|
||||
|
||||
// BuildSourceFingerprints is SourceFingerprints for one module: commit → fingerprint.
|
||||
func (i *Inventory) BuildSourceFingerprints(ctx context.Context, module string) (map[string]string, error) {
|
||||
all, err := i.SourceFingerprints(ctx)
|
||||
c, err := i.theChain(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if all[module] == nil {
|
||||
return map[string]string{}, nil
|
||||
}
|
||||
return all[module], nil
|
||||
// This module's commit pointers only (issue 1121).
|
||||
return i.chainBuildSourceFingerprints(ctx, c, module)
|
||||
}
|
||||
|
||||
// heldMade is, per module, what the build standing for its newest successful build made — what Held
|
||||
// answers (novox/hq issue 280).
|
||||
func (i *Inventory) heldMade(ctx context.Context) (map[string][]Artifact, error) {
|
||||
all, _, err := i.sourceRows(ctx, "")
|
||||
c, err := i.theChain(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := map[string][]Artifact{}
|
||||
for m, builds := range all {
|
||||
if len(builds) == 0 {
|
||||
continue
|
||||
}
|
||||
var made []Artifact
|
||||
if err := json.Unmarshal(builds[standing(builds, 0)].made, &made); err != nil {
|
||||
// Skipped rather than fatal, as Held always did: the build that needs it says it is missing.
|
||||
continue
|
||||
}
|
||||
out[m] = made
|
||||
}
|
||||
return out, nil
|
||||
return i.chainHeldMade(ctx, c)
|
||||
}
|
||||
|
||||
// SameSourceCommits is the commits of the builds in a build's run (novox/hq issue 280): the build and
|
||||
|
||||
Reference in New Issue
Block a user