diff --git a/cmd/mesh-controller/sendable.go b/cmd/mesh-controller/sendable.go index fcf182c..8c282ac 100644 --- a/cmd/mesh-controller/sendable.go +++ b/cmd/mesh-controller/sendable.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "sort" + "strings" "github.com/novox/mesh-controller/internal/catalogue" "github.com/novox/mesh-controller/internal/inventory" @@ -23,8 +24,8 @@ type sendable struct { } // adoptionEnvelope is what an adopted node is told about its mode. Taken is every module taken on -// it that it runs; Untaken is, for every module it runs that is not taken, the ids of that module's -// files and containers — the resources the host keeps as found until the module is taken. Ids +// it that it runs; Untaken is, for every module it runs that is not taken, the ids of every one of +// that module's resources — what the host keeps as found until the module is taken (ADR 0103). Ids // rather than a rule to split them by, because a module's name may contain a dot. type adoptionEnvelope struct { Taken []string `json:"taken"` @@ -75,12 +76,11 @@ func adoptionFor(plan catalogue.Resolution, taken []string, for _, r := range composed.Resources { id, _ := r["id"].(string) module, owned := composed.Owner[id] - if !owned || !runs[module] || isTaken[module] { - continue - } - switch r["type"] { - case "file", "container": - default: + // Every kind, not only files and containers (novox/hq ADR 0103): a directory, a service, a + // container mounting what was found and an action run in a held container all reach what + // the machine already has. What the mesh declares of its own is never held. + if !owned || !runs[module] || isTaken[module] || + strings.HasPrefix(id, catalogue.AdoptionPrefix) { continue } if out.Untaken == nil { diff --git a/cmd/mesh-controller/sendable_test.go b/cmd/mesh-controller/sendable_test.go index 72d9ffb..cecfbe0 100644 --- a/cmd/mesh-controller/sendable_test.go +++ b/cmd/mesh-controller/sendable_test.go @@ -84,8 +84,10 @@ func TestAnAdoptedDeclarationCarriesItsModeAndWhatWasTaken(t *testing.T) { t.Fatal("an adopted node's declaration does not say it is adopted") } untaken := declared.Adoption.Untaken["hello-web"] - if !reflect.DeepEqual(untaken, []string{"hello-web.page", "hello-web.server"}) { - t.Fatalf("hello-web's files and containers are not named untaken: %v", declared.Adoption) + // Every kind — its directory too (novox/hq ADR 0103). + if !reflect.DeepEqual(untaken, []string{"hello-web.page", "hello-web.server", + "hello-web.served"}) { + t.Fatalf("hello-web's resources are not all named untaken: %v", declared.Adoption) } if len(declared.Adoption.Taken) != 0 { t.Fatalf("nothing was taken, and the declaration says %v", declared.Adoption.Taken)