Delivery SDK: the agreement over toolchain entries uses the neutral Toolchain value of the build seats' state (B2g's), not a second type (ADR 0634 §1, §2; issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
@@ -13,15 +13,7 @@ import (
|
||||
// ToolchainNoReport is the reason AgreedToolchain gives when no node has reported a language's toolchain.
|
||||
const ToolchainNoReport = "toolchain not yet reported"
|
||||
|
||||
// Toolchain is what a toolchain is identified by: the language, the installed version and the build module's recipe
|
||||
// version. It has the fields of the mesh-catalog client's Toolchain2, which a caller converts it to.
|
||||
type Toolchain struct {
|
||||
Language string
|
||||
Version string
|
||||
Recipe string
|
||||
}
|
||||
|
||||
// NodeToolchain is one node's entry of a language, as read from a build seat's state toolchains.
|
||||
// NodeToolchain is one node's entry of a language, as read from a build seat's state toolchains (the entry is Toolchain).
|
||||
type NodeToolchain struct {
|
||||
Node string
|
||||
Toolchain
|
||||
@@ -35,7 +27,8 @@ type SittingOut struct {
|
||||
Recipe string
|
||||
}
|
||||
|
||||
// Agreement is what the nodes' entries of one language come to. Toolchain is the agreed one, set when Wait is empty.
|
||||
// Agreement is what the nodes' entries of one language come to. Toolchain is the agreed one (its language, version and
|
||||
// recipe), set when Wait is empty.
|
||||
// Wait is why nothing is agreed: "toolchain not yet reported" with no entries, or "builders disagree" naming each version
|
||||
// and recipe with the nodes reporting it, when no version has a strict majority. SittingOut lists, sorted by node, the
|
||||
// nodes that report another version than the agreed one.
|
||||
@@ -52,14 +45,15 @@ func ToolchainAgreement(entries []NodeToolchain) Agreement {
|
||||
if len(entries) == 0 {
|
||||
return Agreement{Wait: ToolchainNoReport}
|
||||
}
|
||||
groups := map[Toolchain][]string{}
|
||||
type identity struct{ Language, Version, Recipe string }
|
||||
groups := map[identity][]string{}
|
||||
for _, e := range entries {
|
||||
k := Toolchain{Language: e.Language, Version: e.Version, Recipe: e.Recipe}
|
||||
k := identity{e.Language, e.Version, e.Recipe}
|
||||
groups[k] = append(groups[k], e.Node)
|
||||
}
|
||||
for k, nodes := range groups {
|
||||
if 2*len(nodes) > len(entries) {
|
||||
a := Agreement{Toolchain: k}
|
||||
a := Agreement{Toolchain: Toolchain{Language: k.Language, Version: k.Version, Recipe: k.Recipe}}
|
||||
for _, e := range entries {
|
||||
if e.Version != k.Version || e.Recipe != k.Recipe {
|
||||
a.SittingOut = append(a.SittingOut, SittingOut{Node: e.Node, Version: e.Version, Recipe: e.Recipe})
|
||||
|
||||
Reference in New Issue
Block a user