feat(spawn): share host spawn-pi mesh + models.json with spawned containers
- bind $LVMH_HOST_PI_RUNTIME_DIR/spawn-pi -> /root/.pi/spawn-pi (rw) so container pi's join the host pi's node mesh (spawn_pi/list_pi_nodes/ send_pi_message now reach across the host/container boundary) - bind host models.json (when present) over the stale image-baked fallback so newly added catalog models resolve in spawns
This commit is contained in:
@@ -519,6 +519,64 @@ func TestSpawnerSecretsBinds(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerBindsHostModelsJSON(t *testing.T) {
|
||||
useFakeGit(t, fakeGitModeOK)
|
||||
f := newFakeDocker()
|
||||
sp, _ := newTestSpawner(t, f)
|
||||
agent := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(agent, "models.json"), []byte(`{}`), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv(envHostPiAgentDir, agent)
|
||||
|
||||
res, err := sp.Start(context.Background(), "group/project", "", "", false)
|
||||
if err != nil {
|
||||
t.Fatalf("Start: %v", err)
|
||||
}
|
||||
waitJobState(t, sp, res.SessionID, stateRunning)
|
||||
creates := f.createsByName("lvmh-agent-")
|
||||
binds := creates[0].HostConfig.Binds
|
||||
want := agent + "/models.json:/root/.pi/agent/models.json:ro"
|
||||
ok := false
|
||||
for _, b := range binds {
|
||||
if b == want {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
t.Fatalf("models.json bind missing from %v", binds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerBindsSpawnPiMesh(t *testing.T) {
|
||||
useFakeGit(t, fakeGitModeOK)
|
||||
f := newFakeDocker()
|
||||
sp, _ := newTestSpawner(t, f)
|
||||
runtimeDir := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(runtimeDir, "spawn-pi"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv(envHostPiRuntimeDir, runtimeDir)
|
||||
|
||||
res, err := sp.Start(context.Background(), "group/project", "", "", false)
|
||||
if err != nil {
|
||||
t.Fatalf("Start: %v", err)
|
||||
}
|
||||
waitJobState(t, sp, res.SessionID, stateRunning)
|
||||
creates := f.createsByName("lvmh-agent-")
|
||||
binds := creates[0].HostConfig.Binds
|
||||
want := filepath.Join(runtimeDir, "spawn-pi") + ":/root/.pi/spawn-pi"
|
||||
ok := false
|
||||
for _, b := range binds {
|
||||
if b == want {
|
||||
ok = true
|
||||
}
|
||||
}
|
||||
if !ok {
|
||||
t.Fatalf("spawn-pi mesh bind missing from %v", binds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkerBindsCaches(t *testing.T) {
|
||||
useFakeGit(t, fakeGitModeOK)
|
||||
f := newFakeDocker()
|
||||
|
||||
Reference in New Issue
Block a user