Issue 339 follow-up to #64: ask the running runtimes where they keep their data, and read every form a unit says it in #65

Merged
mesh-admin merged 2 commits from fix/339-runtime-roots-asked into main 2026-10-09 00:15:25 +00:00
3 changed files with 37 additions and 7 deletions
Showing only changes of commit 7c046a8a1d - Show all commits
+8 -7
View File
@@ -152,14 +152,15 @@ func readRuntimeRoots(ctx context.Context, run Runner) []string {
}
}
if run != nil {
ask, cancel := context.WithTimeout(ctx, 10*time.Second)
if root, err := run(ask, "docker", "info", "--format", "{{.DockerRootDir}}"); err == nil {
add(root)
// Each runtime has its own ten seconds: one that hangs costs the other nothing.
for _, q := range [][]string{{"docker", "info", "--format", "{{.DockerRootDir}}"},
{"podman", "info", "--format", "{{.Store.GraphRoot}}"}} {
ask, cancel := context.WithTimeout(ctx, 10*time.Second)
if root, err := run(ask, q[0], q[1:]...); err == nil {
add(root)
}
cancel()
}
if root, err := run(ask, "podman", "info", "--format", "{{.Store.GraphRoot}}"); err == nil {
add(root)
}
cancel()
}
daemonJSON := func(path string) {
raw, err := os.ReadFile(path)
+6
View File
@@ -198,6 +198,12 @@ type File struct {
// by looking rather than by knowing which field won.
Sealed string `json:"sealed,omitempty"`
// Trusted is the catalogue's word on whether the settings this file's content took are trusted (novox/hq
// issue 339). It is the controller's to act on, and a controller takes it out before it sends a declaration.
// Accepted here, and nothing is done with it, so that a controller that passes it on — an older one, or one
// rolled back to — never costs a node its whole declaration. Not part of the file's digest.
Trusted *bool `json:"trusted,omitempty"`
// Secrets are sealed values put into Content where it says `${secret:name}`.
//
// **The one place a secret and a configuration meet, and it happens on the machine.** A
+23
View File
@@ -0,0 +1,23 @@
package declaration
import "testing"
// `trusted` is the catalogue's word on a file (novox/hq issue 339): a controller takes it out before it sends a
// declaration, and one that does not — an older one, or one rolled back to — must not cost the node its whole
// declaration. So a file accepts it and the engine does nothing with it; any other resource still refuses it.
func TestAFileAcceptsAndIgnoresTrusted(t *testing.T) {
for _, v := range []string{"true", "false"} {
d, err := Parse([]byte(`{"declaration":1,"resources":[{"id":"m.f","type":"file","path":"/etc/m.conf",` +
`"content":"x","trusted":` + v + `}]}`))
if err != nil {
t.Fatalf("trusted %s: %v", v, err)
}
if f, ok := d.Resources[0].(*File); !ok || f.Content != "x" {
t.Fatalf("trusted %s: %+v", v, d.Resources[0])
}
}
if _, err := Parse([]byte(`{"declaration":1,"resources":[{"id":"m.d","type":"directory","path":"/srv/m",` +
`"trusted":true}]}`)); err == nil {
t.Fatal("a directory took trusted")
}
}