Tell mesh-config what a head declares at every head, so a head that reverts a key drops its held value (issue 1826)
mesh/repo-check head 4357b3688f58 merged into trunk 3d4ad6fefb7c — pass: its merge-check.sh passed
mesh/merge-gate head 4357b3688f58 merged into trunk 3d4ad6fefb7c — pass: group fix/1826-held-config composed: every machine composes with the change as it …
mesh/delivery delivered
mesh/delivery-group group fix/1826-held-config merged: every member is merged
mesh/check failed: integration: github.com/novox/mesh-controller/internal/identity.TestACertificateChainsToTheMeshsOwnAuthority: authority_test.go:45:…
mesh/repo-check head 4357b3688f58 merged into trunk 3d4ad6fefb7c — pass: its merge-check.sh passed
mesh/merge-gate head 4357b3688f58 merged into trunk 3d4ad6fefb7c — pass: group fix/1826-held-config composed: every machine composes with the change as it …
mesh/delivery delivered
mesh/delivery-group group fix/1826-held-config merged: every member is merged
mesh/check failed: integration: github.com/novox/mesh-controller/internal/identity.TestACertificateChainsToTheMeshsOwnAuthority: authority_test.go:45:…
This commit is contained in:
@@ -68,12 +68,11 @@ func pullKey(owner, repo string, number int) string {
|
||||
func (p pullAt) key() string { return pullKey(p.Owner, p.Repo, p.Number) }
|
||||
|
||||
// pullDeclarations are the config declarations a pull request's head adds or changes over what it merges into, by
|
||||
// module, in the shape of the declared-config mirror. The bool says the pull request changes a module.json that exists
|
||||
// at its head: mesh-config is told then, even of no declaration, so what it kept for an earlier head is replaced. A
|
||||
// pull request whose paths are truncated is read through the manifests of the modules it moves (the caller's paths).
|
||||
// module, in the shape of the declared-config mirror. The bool says the head could be read: false for a pull request whose
|
||||
// paths are cut (the caller cuts them to the manifests of the modules it moves) or whose base is unknown, which is then
|
||||
// told nothing, never an empty set.
|
||||
func pullDeclarations(ctx context.Context, p pullAt) ([]inventory.DeclaredConfigMirrored, bool, error) {
|
||||
var out []inventory.DeclaredConfigMirrored
|
||||
touched := false
|
||||
if p.Truncated || p.Old == "" {
|
||||
return nil, false, nil
|
||||
}
|
||||
@@ -88,7 +87,6 @@ func pullDeclarations(ctx context.Context, p pullAt) ([]inventory.DeclaredConfig
|
||||
if !exists || now.Module == "" {
|
||||
continue
|
||||
}
|
||||
touched = true
|
||||
was, _, err := manifestCached(ctx, p.Owner, p.Repo, file, p.Old)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -111,19 +109,21 @@ func pullDeclarations(ctx context.Context, p pullAt) ([]inventory.DeclaredConfig
|
||||
out = append(out, inventory.DeclaredConfigMirrored{Module: now.Module, Settings: changed})
|
||||
}
|
||||
}
|
||||
return out, touched, nil
|
||||
return out, true, nil
|
||||
}
|
||||
|
||||
// tellPullDeclares tells mesh-config, for each pull request that changes a module.json, what its head declares. A
|
||||
// tellPullDeclares tells mesh-config, for each pull request at every announced head, what the head declares, an empty set
|
||||
// when it declares nothing new: mesh-config re-judges the values held at every head, so a head that reverts the change
|
||||
// drops them (ADR 0502 clause 6). A
|
||||
// failure is said to w and the check goes on: the held values are then none (ADR 0502 clause 2).
|
||||
func tellPullDeclares(ctx context.Context, w io.Writer, pulls []pullAt) {
|
||||
for _, p := range pulls {
|
||||
mods, touched, err := pullDeclarations(ctx, p)
|
||||
mods, readable, err := pullDeclarations(ctx, p)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "%s: what its head declares cannot be read, so mesh-config is told nothing: %v\n", p.key(), err)
|
||||
continue
|
||||
}
|
||||
if !touched {
|
||||
if !readable {
|
||||
continue
|
||||
}
|
||||
declares := map[string]map[string]inventory.DeclaredMirrored{}
|
||||
@@ -191,7 +191,21 @@ func heldFor(ctx context.Context, w io.Writer, pulls []pullAt) []link.HeldConfig
|
||||
// declarations are told.
|
||||
func withHeldConfig(ctx context.Context, w io.Writer, request *link.BuildRequest, pulls []pullAt, carry bool) {
|
||||
tellPullDeclares(ctx, w, pulls)
|
||||
if carry && request.Check != nil {
|
||||
if carry {
|
||||
carryHeld(ctx, w, request, pulls)
|
||||
}
|
||||
}
|
||||
|
||||
// carryHeld puts the approved held values of these pull requests on the check request.
|
||||
func carryHeld(ctx context.Context, w io.Writer, request *link.BuildRequest, pulls []pullAt) {
|
||||
if request.Check != nil {
|
||||
request.Check.HeldConfig = heldFor(ctx, w, pulls)
|
||||
}
|
||||
}
|
||||
|
||||
// holdsModules is whether a module of the mesh is built from this repository.
|
||||
func holdsModules(entries []inventory.Entry, owner, repo string) bool {
|
||||
return slices.ContainsFunc(entries, func(e inventory.Entry) bool {
|
||||
return sameRepository(e.Source.Repository, link.SourceMoved{Owner: owner, Repo: repo})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user