remove vm session feature
Cuts the daemon-managed guest-session machinery (start/list/show/
logs/stop/kill/attach/send). The feature shipped aimed at agent-
orchestration workflows (programmatic stdin piping into a long-lived
guest process) that aren't driving any concrete user today, and the
~2.3K LOC of daemon surface area — attach bridge, FIFO keepalive,
controller registry, sessionstream framing, SQLite persistence — was
locking in an API we'd have to keep through v0.1.0.
Anything session-flavoured that people actually need today can be
done with `vm ssh + tmux` or `vm run -- cmd`.
Deleted:
- internal/cli/commands_vm_session.go
- internal/daemon/{guest_sessions,session_lifecycle,session_attach,session_stream,session_controller}.go
- internal/daemon/session/ (guest-session helpers package)
- internal/sessionstream/ (framing package)
- internal/daemon/guest_sessions_test.go
- internal/store/guest_session_test.go
- GuestSession* types from internal/{api,model}
- Store UpsertGuestSession/GetGuestSession/ListGuestSessionsByVM/DeleteGuestSession + scanner helpers
- guest.session.* RPC dispatch entries
- 5 CLI session tests, 2 completion tests, 2 printer tests
Extracted:
- ShellQuote + FormatStepError lifted to internal/daemon/workspace/util.go
(only non-session consumer); workspace package now self-contained
- internal/daemon/guest_ssh.go keeps guestSSHClient + dialGuest +
waitForGuestSSH — still used by workspace prepare/export
- internal/daemon/fake_firecracker_test.go preserves the test helper
that used to live in guest_sessions_test.go
Store schema: CREATE TABLE guest_sessions and its column migrations
removed. Existing dev DBs keep an orphan table (harmless, pre-v0.1.0).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c42fcbe012
commit
2b6437d1b4
34 changed files with 194 additions and 4031 deletions
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -52,37 +51,6 @@ func TestDashIfEmpty(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestParseKeyValuePairs(t *testing.T) {
|
||||
t.Run("nil when empty", func(t *testing.T) {
|
||||
got, err := parseKeyValuePairs(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if got != nil {
|
||||
t.Fatalf("got %v, want nil", got)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("parses entries", func(t *testing.T) {
|
||||
got, err := parseKeyValuePairs([]string{"a=1", " b = two", "c=x=y"})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
want := map[string]string{"a": "1", "b": " two", "c": "x=y"}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("got %v, want %v", got, want)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("rejects malformed entries", func(t *testing.T) {
|
||||
for _, bad := range []string{"noequals", "=noKey", " =v"} {
|
||||
if _, err := parseKeyValuePairs([]string{bad}); err == nil {
|
||||
t.Errorf("expected error for %q", bad)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestExitCodeErrorError(t *testing.T) {
|
||||
e := ExitCodeError{Code: 42}
|
||||
got := e.Error()
|
||||
|
|
@ -234,38 +202,6 @@ func TestPrintKernelCatalogTable(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPrintGuestSessionTable(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
sessions := []model.GuestSession{
|
||||
{ID: "abcdef0123456789", Name: "planner", Status: "running", Command: "pi", CWD: "/root/repo", Attachable: true},
|
||||
{ID: "short", Name: "once", Status: "exited", Command: "true", CWD: "/tmp", Attachable: false},
|
||||
}
|
||||
if err := printGuestSessionTable(&buf, sessions); err != nil {
|
||||
t.Fatalf("printGuestSessionTable: %v", err)
|
||||
}
|
||||
got := buf.String()
|
||||
for _, want := range []string{"ID", "NAME", "planner", "once", "yes", "no", "pi"} {
|
||||
if !strings.Contains(got, want) {
|
||||
t.Errorf("output missing %q:\n%s", want, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintGuestSessionSummary(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
session := model.GuestSession{
|
||||
ID: "id1", Name: "s", Status: "exited", Command: "true", CWD: "/root",
|
||||
}
|
||||
if err := printGuestSessionSummary(&buf, session); err != nil {
|
||||
t.Fatalf("printGuestSessionSummary: %v", err)
|
||||
}
|
||||
got := buf.String()
|
||||
fields := strings.Split(strings.TrimRight(got, "\n"), "\t")
|
||||
if len(fields) != 5 {
|
||||
t.Fatalf("expected 5 tab-separated fields, got %d: %q", len(fields), got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintJSON(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
if err := printJSON(&buf, map[string]int{"a": 1, "b": 2}); err != nil {
|
||||
|
|
@ -340,10 +276,6 @@ type failWriter struct{}
|
|||
func (failWriter) Write([]byte) (int, error) { return 0, fmt.Errorf("boom") }
|
||||
|
||||
func TestPrintersPropagateWriteErrors(t *testing.T) {
|
||||
sessions := []model.GuestSession{{ID: "id", Name: "n"}}
|
||||
if err := printGuestSessionTable(failWriter{}, sessions); err == nil {
|
||||
t.Error("expected write error from printGuestSessionTable")
|
||||
}
|
||||
kernels := []api.KernelEntry{{Name: "k"}}
|
||||
if err := printKernelListTable(failWriter{}, kernels); err == nil {
|
||||
t.Error("expected write error from printKernelListTable")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue