Read the seat mesh-placement's state through the sdk's PlacementKeys in mesh-conditions, mesh-config, mesh-provisioner, mesh-vault and mesh-self-check, so they read its keys per module and node and the form before alike while it is delivered (issue 774, research 072 row 37)
This commit is contained in:
@@ -903,9 +903,9 @@ func (h *Holder) put(key string, p provisions.Provision) {
|
||||
|
||||
// ---- what a change touches --------------------------------------------------------------------------------------
|
||||
|
||||
// NodesOfPlacement is the node a placement key names.
|
||||
// NodesOfPlacement is the node a placement key names, in either form (research 072 row 37).
|
||||
func NodesOfPlacement(key string) []string {
|
||||
if n, err := delivery.ParsePlacementKey(key); err == nil {
|
||||
if n, _, _, err := delivery.ParsePlacementKey(key); err == nil {
|
||||
return []string{n}
|
||||
}
|
||||
return nil
|
||||
@@ -938,25 +938,23 @@ func (h *Holder) NodesOfModule(module string) []string {
|
||||
return sortedKeys(nodes)
|
||||
}
|
||||
|
||||
// placedOn is every node a module is placed on, sorted.
|
||||
// placedOn is every node a module is placed on, sorted, from the placement's keys in either form
|
||||
// (delivery.PlacementsOf; research 072 row 37). A node whose keys do not read whole is read as they stand.
|
||||
func (h *Holder) placedOn(module string) []string {
|
||||
nodes := map[string]bool{}
|
||||
raw := map[string][]byte{}
|
||||
if keys, err := h.Store.Keys(PlacementRead); err == nil {
|
||||
for _, k := range keys {
|
||||
n, err := delivery.ParsePlacementKey(k)
|
||||
if err != nil {
|
||||
continue
|
||||
if e, err := h.Store.Get(PlacementRead, k); err == nil && e != nil {
|
||||
raw[k] = e.Value
|
||||
}
|
||||
e, err := h.Store.Get(PlacementRead, k)
|
||||
if err != nil || e == nil {
|
||||
continue
|
||||
}
|
||||
if p, err := delivery.DecodePlacement(e.Value); err == nil {
|
||||
for _, m := range p.Modules {
|
||||
if m.Module == module {
|
||||
nodes[n] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
placements, _ := delivery.PlacementsOf(raw)
|
||||
for n, p := range placements {
|
||||
for _, m := range p.Modules {
|
||||
if m.Module == module {
|
||||
nodes[n] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,17 @@ func TestAKeysStateFollowsItsProvidersOutcome(t *testing.T) {
|
||||
// A provision's credential is the vault's own provision, on the consumer's node for a login of its own, and the
|
||||
// provision depends on it (clauses 3, 6).
|
||||
c := newMesh()
|
||||
c.s.write(t, PlacementRead, "placement.novox", `{"v":1,"node":"novox","decided":{},"modules":[{"module":"mesh-vault"}]}`)
|
||||
// The placement in its keys per module and node (research 072 row 37).
|
||||
novox, err := delivery.PlacementValues(delivery.Placement{Node: "novox", Modules: []delivery.PlacedModule{{Module: "mesh-vault"}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for k, v := range novox {
|
||||
c.s.write(t, PlacementRead, k, string(v))
|
||||
if n := NodesOfPlacement(k); !slices.Equal(n, []string{"novox"}) {
|
||||
t.Errorf("NodesOfPlacement(%q) = %v", k, n)
|
||||
}
|
||||
}
|
||||
pair := pgDB
|
||||
pair.CredentialForm = "pair"
|
||||
c.atWant["g14"] = map[string]catalogue.Plan{"gitea": planOf(pair)}
|
||||
|
||||
Reference in New Issue
Block a user