One machine's unanswerable requirement does not remove it from the mesh
The pass that answers *what does this node offer* takes a failed resolution to mean it learned nothing about that node. So refusing an unanswerable requirement there made the machine disappear — and every other machine was then told, wrongly, that the two of them shared no private network. A wrong answer about a machine nobody asked about, caused by a fault on a third. The lab found it: one module needing a licence that had not been added yet made two unrelated machines look disconnected. The second pass still refuses it, where the question is actually being asked.
This commit is contained in:
@@ -148,3 +148,40 @@ func TestALicenceDeliversWhatIsPublicAndWhatIsSealed(t *testing.T) {
|
||||
t.Fatal("the key was written into the public file as well")
|
||||
}
|
||||
}
|
||||
|
||||
// One machine's unresolvable module must not remove it from the private network.
|
||||
//
|
||||
// The pass that answers *what does this node offer* takes a failed resolution to mean it learned
|
||||
// nothing — so refusing an unanswerable requirement there makes the machine disappear, and every
|
||||
// other machine is then told, wrongly, that the two of them share no network. A wrong answer about
|
||||
// a machine nobody asked about, caused by a fault on a third.
|
||||
func TestAnUnanswerableRequirementDoesNotRemoveAMachineFromTheMesh(t *testing.T) {
|
||||
shelf := map[string]Manifest{
|
||||
"assistant": aModelUser(),
|
||||
"networking": {Module: "networking",
|
||||
Provides: []Offer{{Name: "mesh-network", Scope: ScopeNode}}},
|
||||
}
|
||||
// The first pass: what does this machine offer? It is assigned something nothing answers.
|
||||
got, err := Resolve(shelf, []string{"assistant", "networking"},
|
||||
Node{Name: "laptop"}, World{Unchecked: true})
|
||||
if err != nil {
|
||||
t.Fatalf("a machine with one unanswerable requirement was lost entirely: %v", err)
|
||||
}
|
||||
var offers bool
|
||||
for _, m := range got.Modules {
|
||||
for _, o := range m.Offers() {
|
||||
if o == "mesh-network" {
|
||||
offers = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !offers {
|
||||
t.Fatal("the machine's own network module was not seen, so it looks off the network")
|
||||
}
|
||||
|
||||
// And the second pass, where the question is actually being asked, still refuses it.
|
||||
if _, err := Resolve(shelf, []string{"assistant", "networking"},
|
||||
Node{Name: "laptop"}, World{}); err == nil {
|
||||
t.Fatal("the requirement nothing answers was accepted when it was actually asked")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user