Skip to content

An open-source, faster Devin alternative

TypeScript

fix live migration issues

Brian Reardon7d438642c05c
diff --git a/internal/api/sandbox.go b/internal/api/sandbox.go
index 33f6f85e..649425d6 100644
--- a/internal/api/sandbox.go
+++ b/internal/api/sandbox.go
@@ -866,31 +866,45 @@ func (s *Server) migrateSandbox(c echo.Context) error {
t0 := time.Now()
- // Step 1: Prepare target worker — starts QEMU with -incoming tcp
- // Use session config for VM parameters. Drives are created fresh on target;
- // memory contents (including filesystem cache) migrate via QMP tcp.
- prepCtx, prepCancel := context.WithTimeout(ctx, 2*time.Minute)
- defer prepCancel()
- // Parse sandbox config to get the actual memory/CPU (must match source for migration)
- var sbCfg struct {
- MemoryMB int `json:"memoryMB"`
- CpuCount int `json:"cpuCount"`
+ // Step 1: Pre-copy drives to S3 (thin overlay, never flatten).
+ preCopyCtx, preCopyCancel := context.WithTimeout(ctx, 3*time.Minute)
+ defer preCopyCancel()
+ preCopyResp, err := sourceClient.PreCopyDrives(preCopyCtx, &pb.PreCopyDrivesRequest{
+ SandboxId: id,
+ })
+ if err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": "pre-copy drives: " + err.Error()})
+ }
+
+ if preCopyResp.GoldenVersion == "" {
+ return c.JSON(http.StatusBadRequest, map[string]string{"error": "source sandbox has no goldenVersion — cannot live migrate safely; use hibernate/wake instead"})
+ }
+
+ log.Printf("migrate %s: drives pre-copied to S3 (%dms, golden=%s)", id, time.Since(t0).Milliseconds(), preCopyResp.GoldenVersion)
+
+ // Step 2: Prepare target (downloads thin overlay, rebases if needed, starts QEMU -incoming).
+ // CPU and memory come from the source worker — must match exactly for QEMU migration.
+ cpuCount := preCopyResp.BaseCpuCount
+ memoryMB := preCopyResp.BaseMemoryMb
+ if cpuCount == 0 {
+ cpuCount = 2
}
- _ = json.Unmarshal(session.Config, &sbCfg)
- // IMPORTANT: Use the QEMU base memory (from golden snapshot), not the API-requested total.
- // Virtio-mem hotplug state transfers during migration — the target QEMU must start
- // with the same base memory as the source for the memory layout to match.
- sbCfg.MemoryMB = 256
- if sbCfg.CpuCount <= 0 {
- sbCfg.CpuCount = 1
+ if memoryMB == 0 {
+ memoryMB = 1024
}
+ prepCtx, prepCancel := context.WithTimeout(ctx, 3*time.Minute)
+ defer prepCancel()
prepResp, err := targetClient.PrepareMigrationIncoming(prepCtx, &pb.PrepareMigrationIncomingRequest{
- SandboxId: id,
- CpuCount: int32(sbCfg.CpuCount),
- MemoryMb: int32(sbCfg.MemoryMB),
- GuestPort: 80,
- Template: session.Template,
+ SandboxId: id,
+ CpuCount: cpuCount,
+ MemoryMb: memoryMB,
+ GuestPort: 80,
+ Template: session.Template,
+ RootfsS3Key: preCopyResp.RootfsKey,
+ WorkspaceS3Key: preCopyResp.WorkspaceKey,
+ OverlayMode: true,
+ SourceGoldenVersion: preCopyResp.GoldenVersion,
})
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{"error": "prepare target: " + err.Error()})
@@ -1273,24 +1287,43 @@ func (s *Server) migrateForScale(ctx context.Context, sandboxID string, session
template = "default"
}
- // IMPORTANT: Use the QEMU base memory (from golden snapshot), not the API-requested total.
- // Virtio-mem hotplug state transfers during migration — the target QEMU must start
- // with the same base memory as the source for the memory layout to match.
- baseMem := 256
- baseCPU := 1
+ // Step 1: Pre-copy drives to S3 (thin overlay).
+ preCopyCtx, preCopyCancel := context.WithTimeout(ctx, 3*time.Minute)
+ defer preCopyCancel()
+ preCopyResp, err := sourceClient.PreCopyDrives(preCopyCtx, &pb.PreCopyDrivesRequest{
+ SandboxId: sandboxID,
+ })
+ if err != nil {
+ return fmt.Errorf("pre-copy drives: %w", err)
+ }
+
+ // CPU and memory from source — must match for QEMU migration.
+ baseCPU := preCopyResp.BaseCpuCount
+ baseMem := preCopyResp.BaseMemoryMb
+ if baseCPU == 0 {
+ baseCPU = 2
+ }
+ if baseMem == 0 {
+ baseMem = 1024
+ }
- log.Printf("scale-migrate %s: migrating to %s (template=%s, baseMem=%dMB, targetMem=%dMB, cpu=%d)", sandboxID, target.ID, template, baseMem, memoryMB, cpuCount)
+ log.Printf("scale-migrate %s: drives pre-copied (%dms), migrating to %s (baseMem=%dMB, targetMem=%dMB, cpu=%d)",
+ sandboxID, time.Since(t0).Milliseconds(), target.ID, baseMem, memoryMB, baseCPU)
- // Step 1: Prepare target with the SOURCE's base memory (must match for migration)
- prepCtx, prepCancel := context.WithTimeout(ctx, 2*time.Minute)
+ // Step 2: Prepare target with the SOURCE's base memory (must match for migration)
+ prepCtx, prepCancel := context.WithTimeout(ctx, 3*time.Minute)
defer prepCancel()
prepResp, err := targetClient.PrepareMigrationIncoming(prepCtx, &pb.PrepareMigrationIncomingRequest{
- SandboxId: sandboxID,
- CpuCount: int32(baseCPU),
- MemoryMb: int32(baseMem),
- GuestPort: 80,
- Template: template,
- TargetMemoryMb: int32(memoryMB),
+ SandboxId: sandboxID,
+ CpuCount: baseCPU,
+ MemoryMb: baseMem,
+ GuestPort: 80,
+ Template: template,
+ RootfsS3Key: preCopyResp.RootfsKey,
+ WorkspaceS3Key: preCopyResp.WorkspaceKey,
+ OverlayMode: true,
+ SourceGoldenVersion: preCopyResp.GoldenVersion,
+ TargetMemoryMb: int32(memoryMB),
})
if err != nil {
log.Printf("scale-migrate %s: prepare target failed: %v", sandboxID, err)
diff --git a/internal/controlplane/scaler.go b/internal/controlplane/scaler.go
index 078d348a..52542ae6 100644
--- a/internal/controlplane/scaler.go
+++ b/internal/controlplane/scaler.go
@@ -1037,41 +1037,36 @@ func (s *Scaler) liveMigrateSandbox(ctx context.Context, sandboxID, sourceWorker
t0 := time.Now()
- // Determine if source and target share the same golden snapshot version.
- // Same version → upload thin overlay, target rebases to local base image (fast, small).
- // Different version → flatten rootfs before upload, target uses it as-is (slow, large).
- sourceWorker := s.getWorkerInfo(sourceWorkerID)
- targetWorker := s.getWorkerInfo(targetWorkerID)
- sameGolden := sourceWorker != nil && targetWorker != nil &&
- sourceWorker.GoldenVersion != "" && sourceWorker.GoldenVersion == targetWorker.GoldenVersion
- flatten := !sameGolden
-
- // Step 1: Pre-copy drives to S3 (source uploads qcow2s)
+ // Step 1: Pre-copy drives to S3 (source uploads thin overlay — never flattens).
+ // Target worker rebases to its own base if golden versions differ.
preCopyCtx, preCopyCancel := context.WithTimeout(ctx, 3*time.Minute)
defer preCopyCancel()
preCopyResp, err := sourceClient.PreCopyDrives(preCopyCtx, &pb.PreCopyDrivesRequest{
- SandboxId: sandboxID,
- FlattenRootfs: flatten,
+ SandboxId: sandboxID,
})
if err != nil {
return fmt.Errorf("pre-copy drives: %w", err)
}
- migrationMode := "overlay"
- if flatten {
- migrationMode = "flatten"
+ // If the source has no goldenVersion, we can't safely rebase on the target.
+ // Fall back to hibernate → wake which handles legacy checkpoints.
+ if preCopyResp.GoldenVersion == "" {
+ return fmt.Errorf("source sandbox has no goldenVersion — cannot live migrate safely; use hibernate/wake instead")
}
- log.Printf("scaler: migrate %s: drives pre-copied to S3 (%dms, mode=%s)", sandboxID, time.Since(t0).Milliseconds(), migrationMode)
- // Step 2: Prepare target (downloads from S3, starts QEMU -incoming)
- // IMPORTANT: Use the BASE memory (from creation), not the scaled total.
- // QEMU migration requires matching memory layout: -m <base> + virtio-mem pool.
- // The hotplugged virtio-mem state transfers as part of the migration stream.
- // The golden snapshot is created with OPENSANDBOX_DEFAULT_SANDBOX_CPUS (2) and
- // OPENSANDBOX_DEFAULT_SANDBOX_MEMORY_MB (1024). QEMU migration requires exact
- // match of -smp and -m between source and target.
- // TODO: read base cpus/memory from source worker heartbeat instead of hardcoding.
- cpuCount, memoryMB, guestPort, template := int32(2), int32(1024), int32(80), "default"
+ log.Printf("scaler: migrate %s: drives pre-copied to S3 (%dms, golden=%s)", sandboxID, time.Since(t0).Milliseconds(), preCopyResp.GoldenVersion)
+
+ // Step 2: Prepare target (downloads thin overlay from S3, rebases if needed, starts QEMU -incoming)
+ // CPU and memory come from the source worker — must match exactly for QEMU migration.
+ cpuCount := preCopyResp.BaseCpuCount
+ memoryMB := preCopyResp.BaseMemoryMb
+ if cpuCount == 0 {
+ cpuCount = 2 // fallback for old workers that don't report
+ }
+ if memoryMB == 0 {
+ memoryMB = 1024
+ }
+ guestPort, template := int32(80), "default"
if s.store != nil {
session, err := s.store.GetSandboxSession(ctx, sandboxID)
if err == nil && session != nil {
@@ -1084,15 +1079,16 @@ func (s *Scaler) liveMigrateSandbox(ctx context.Context, sandboxID, sourceWorker
prepCtx, prepCancel := context.WithTimeout(ctx, 3*time.Minute)
defer prepCancel()
prepResp, err := targetClient.PrepareMigrationIncoming(prepCtx, &pb.PrepareMigrationIncomingRequest{
- SandboxId: sandboxID,
- CpuCount: cpuCount,
- MemoryMb: memoryMB,
- GuestPort: guestPort,
- Template: template,
- RootfsS3Key: preCopyResp.RootfsKey,
- WorkspaceS3Key: preCopyResp.WorkspaceKey,
- OverlayMode: sameGolden,
- TargetMemoryMb: 4096, // default tier — worker checks real capacity atomically
+ SandboxId: sandboxID,
+ CpuCount: cpuCount,
+ MemoryMb: memoryMB,
+ GuestPort: guestPort,
+ Template: template,
+ RootfsS3Key: preCopyResp.RootfsKey,
+ WorkspaceS3Key: preCopyResp.WorkspaceKey,
+ OverlayMode: true,
+ SourceGoldenVersion: preCopyResp.GoldenVersion,
+ TargetMemoryMb: 4096,
})
if err != nil {
return fmt.Errorf("prepare target: %w", err)
diff --git a/internal/qemu/migration.go b/internal/qemu/migration.go
index 3800f27d..e25dbeab 100644
--- a/internal/qemu/migration.go
+++ b/internal/qemu/migration.go
@@ -548,15 +548,16 @@ func (m *Manager) CompleteIncomingMigration(ctx context.Context, sandboxID strin
}
// PreCopyDrives uploads a sandbox's drives to S3 for cross-worker migration.
-// If flatten is true, the rootfs qcow2 overlay is flattened (backing file merged)
-// before upload, making it self-contained for cross-golden-version migration.
-// Returns the S3 keys and the sandbox's golden version.
-func (m *Manager) PreCopyDrives(ctx context.Context, sandboxID string, checkpointStore *storage.CheckpointStore, flatten bool) (rootfsKey, workspaceKey, goldenVer string, err error) {
- // Look up golden version from the VM
+// Always uploads the thin overlay (never flattens). The target worker rebases
+// to its own base image if golden versions differ.
+// Returns S3 keys, golden version, and base CPU/memory for QEMU matching.
+func (m *Manager) PreCopyDrives(ctx context.Context, sandboxID string, checkpointStore *storage.CheckpointStore) (rootfsKey, workspaceKey, goldenVer string, baseCPU, baseMem int, err error) {
m.mu.RLock()
vm, exists := m.vms[sandboxID]
if exists {
goldenVer = vm.goldenVersion
+ baseCPU = vm.CpuCount
+ baseMem = vm.baseMemoryMB
}
m.mu.RUnlock()
@@ -566,19 +567,16 @@ func (m *Manager) PreCopyDrives(ctx context.Context, sandboxID string, checkpoin
migrations: make(map[string]*MigrationState),
}
- if flatten && goldenVer != "" {
- // Flatten the rootfs before upload — merge backing file into overlay
- rootfsKey, workspaceKey, err = mc.MigrateToS3Flatten(ctx, sandboxID)
- } else {
- rootfsKey, workspaceKey, err = mc.MigrateToS3(ctx, sandboxID)
- }
- return rootfsKey, workspaceKey, goldenVer, err
+ rootfsKey, workspaceKey, err = mc.MigrateToS3(ctx, sandboxID)
+ return
}
// PrepareIncomingMigrationWithS3 downloads drives from S3 then prepares incoming migration.
-// If overlayMode is true, the rootfs is a thin qcow2 overlay — rebase it to point to
-// the local base image instead of downloading a flattened file.
-func (m *Manager) PrepareIncomingMigrationWithS3(ctx context.Context, sandboxID, rootfsS3Key, workspaceS3Key string, cpus, memMB, guestPort int, template string, checkpointStore *storage.CheckpointStore, overlayMode bool) (incomingAddr string, hostPort int, err error) {
+// If overlayMode is true, the rootfs is a thin qcow2 overlay. When sourceGoldenVersion
+// matches the target's current golden version, a fast metadata-only repoint is used.
+// When versions differ, a full rebase downloads the old base from S3 and migrates
+// the overlay to the current base — same logic as checkpoint fork rebase.
+func (m *Manager) PrepareIncomingMigrationWithS3(ctx context.Context, sandboxID, rootfsS3Key, workspaceS3Key string, cpus, memMB, guestPort int, template string, checkpointStore *storage.CheckpointStore, overlayMode bool, sourceGoldenVersion string) (incomingAddr string, hostPort int, err error) {
sandboxDir := filepath.Join(m.cfg.DataDir, "sandboxes", sandboxID)
if err := os.MkdirAll(sandboxDir, 0755); err != nil {
return "", 0, fmt.Errorf("mkdir: %w", err)
@@ -590,19 +588,31 @@ func (m *Manager) PrepareIncomingMigrationWithS3(ctx context.Context, sandboxID,
return "", 0, fmt.Errorf("download rootfs from S3: %w", err)
}
- // In overlay mode, the rootfs is a thin overlay backed by the base ext4 image.
- // Rebase it to point to this worker's local base image path.
if overlayMode {
- baseImage, resolveErr := ResolveBaseImage(m.cfg.ImagesDir, "default")
- if resolveErr != nil {
- return "", 0, fmt.Errorf("resolve base image for overlay rebase: %w", resolveErr)
- }
- absBase, _ := filepath.Abs(baseImage)
- rebaseCmd := exec.Command("qemu-img", "rebase", "-u", "-b", absBase, "-F", "raw", rootfsPath)
- if out, err := rebaseCmd.CombinedOutput(); err != nil {
- return "", 0, fmt.Errorf("rebase rootfs to local base: %w (%s)", err, strings.TrimSpace(string(out)))
+ currentGolden := m.GoldenVersion()
+ if sourceGoldenVersion != "" && sourceGoldenVersion != currentGolden {
+ // Cross-version: safe rebase via old base download + block comparison.
+ // Ensure checkpointStore is available for downloading the old base.
+ if m.checkpointStore == nil && checkpointStore != nil {
+ m.SetCheckpointStore(checkpointStore)
+ }
+ if err := m.rebaseCheckpointToCurrentBase(ctx, sandboxDir, sourceGoldenVersion); err != nil {
+ return "", 0, fmt.Errorf("rebase rootfs across golden versions: %w", err)
+ }
+ log.Printf("qemu: migration %s: rootfs rebased from %s to %s (cross-version)", sandboxID, sourceGoldenVersion, currentGolden)
+ } else {
+ // Same version (or no version info): metadata-only repoint to local path.
+ baseImage, resolveErr := ResolveBaseImage(m.cfg.ImagesDir, "default")
+ if resolveErr != nil {
+ return "", 0, fmt.Errorf("resolve base image for overlay rebase: %w", resolveErr)
+ }
+ absBase, _ := filepath.Abs(baseImage)
+ rebaseCmd := exec.Command("qemu-img", "rebase", "-u", "-b", absBase, "-F", "raw", rootfsPath)
+ if out, err := rebaseCmd.CombinedOutput(); err != nil {
+ return "", 0, fmt.Errorf("rebase rootfs to local base: %w (%s)", err, strings.TrimSpace(string(out)))
+ }
+ log.Printf("qemu: migration %s: rootfs rebased to local base (same version)", sandboxID)
}
- log.Printf("qemu: migration %s: rootfs rebased to local base image (overlay mode)", sandboxID)
}
// Download workspace from S3
diff --git a/internal/worker/grpc_server.go b/internal/worker/grpc_server.go
index 234bfd8f..54cba080 100644
--- a/internal/worker/grpc_server.go
+++ b/internal/worker/grpc_server.go
@@ -32,8 +32,8 @@ import (
// LiveMigrator is implemented by VM managers that support live migration (e.g. QEMU).
type LiveMigrator interface {
PrepareIncomingMigration(ctx context.Context, sandboxID, rootfsPath, workspacePath string, cpus, memMB, guestPort int, template string) (incomingAddr string, hostPort int, err error)
- PrepareIncomingMigrationWithS3(ctx context.Context, sandboxID, rootfsS3Key, workspaceS3Key string, cpus, memMB, guestPort int, template string, checkpointStore *storage.CheckpointStore, overlayMode bool) (incomingAddr string, hostPort int, err error)
- PreCopyDrives(ctx context.Context, sandboxID string, checkpointStore *storage.CheckpointStore, flatten bool) (rootfsKey, workspaceKey, goldenVersion string, err error)
+ PrepareIncomingMigrationWithS3(ctx context.Context, sandboxID, rootfsS3Key, workspaceS3Key string, cpus, memMB, guestPort int, template string, checkpointStore *storage.CheckpointStore, overlayMode bool, sourceGoldenVersion string) (incomingAddr string, hostPort int, err error)
+ PreCopyDrives(ctx context.Context, sandboxID string, checkpointStore *storage.CheckpointStore) (rootfsKey, workspaceKey, goldenVersion string, baseCPU, baseMem int, err error)
CompleteIncomingMigration(ctx context.Context, sandboxID string) error
LiveMigrate(ctx context.Context, sandboxID, incomingAddr string) error
}
@@ -963,7 +963,7 @@ func (s *GRPCServer) PreCopyDrives(ctx context.Context, req *pb.PreCopyDrivesReq
if s.migrator == nil {
return nil, fmt.Errorf("live migration not supported on this worker")
}
- rootfsKey, workspaceKey, goldenVersion, err := s.migrator.PreCopyDrives(ctx, req.SandboxId, s.checkpointStore, req.FlattenRootfs)
+ rootfsKey, workspaceKey, goldenVersion, baseCPU, baseMem, err := s.migrator.PreCopyDrives(ctx, req.SandboxId, s.checkpointStore)
if err != nil {
return nil, fmt.Errorf("pre-copy drives: %w", err)
}
@@ -971,6 +971,8 @@ func (s *GRPCServer) PreCopyDrives(ctx context.Context, req *pb.PreCopyDrivesReq
RootfsKey: rootfsKey,
WorkspaceKey: workspaceKey,
GoldenVersion: goldenVersion,
+ BaseMemoryMb: int32(baseMem),
+ BaseCpuCount: int32(baseCPU),
}, nil
}
@@ -1002,7 +1004,7 @@ func (s *GRPCServer) PrepareMigrationIncoming(ctx context.Context, req *pb.Prepa
if req.RootfsS3Key != "" && req.WorkspaceS3Key != "" {
addr, hostPort, err = s.migrator.PrepareIncomingMigrationWithS3(ctx,
req.SandboxId, req.RootfsS3Key, req.WorkspaceS3Key,
- int(req.CpuCount), int(req.MemoryMb), int(req.GuestPort), req.Template, s.checkpointStore, req.OverlayMode)
+ int(req.CpuCount), int(req.MemoryMb), int(req.GuestPort), req.Template, s.checkpointStore, req.OverlayMode, req.SourceGoldenVersion)
} else {
addr, hostPort, err = s.migrator.PrepareIncomingMigration(ctx,
req.SandboxId, req.RootfsPath, req.WorkspacePath,
diff --git a/proto/worker/worker.pb.go b/proto/worker/worker.pb.go
index ef5dc90a..b7eff451 100644
--- a/proto/worker/worker.pb.go
+++ b/proto/worker/worker.pb.go
@@ -2786,6 +2786,8 @@ type PreCopyDrivesResponse struct {
RootfsKey string `protobuf:"bytes,1,opt,name=rootfs_key,json=rootfsKey,proto3" json:"rootfs_key,omitempty"` // S3 key for rootfs qcow2
WorkspaceKey string `protobuf:"bytes,2,opt,name=workspace_key,json=workspaceKey,proto3" json:"workspace_key,omitempty"` // S3 key for workspace qcow2
GoldenVersion string `protobuf:"bytes,3,opt,name=golden_version,json=goldenVersion,proto3" json:"golden_version,omitempty"` // golden version the sandbox was created from
+ BaseMemoryMb int32 `protobuf:"varint,4,opt,name=base_memory_mb,json=baseMemoryMb,proto3" json:"base_memory_mb,omitempty"` // QEMU -m value from source
+ BaseCpuCount int32 `protobuf:"varint,5,opt,name=base_cpu_count,json=baseCpuCount,proto3" json:"base_cpu_count,omitempty"` // QEMU -smp value from source
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -2841,6 +2843,20 @@ func (x *PreCopyDrivesResponse) GetGoldenVersion() string {
return ""
}
+func (x *PreCopyDrivesResponse) GetBaseMemoryMb() int32 {
+ if x != nil {
+ return x.BaseMemoryMb
+ }
+ return 0
+}
+
+func (x *PreCopyDrivesResponse) GetBaseCpuCount() int32 {
+ if x != nil {
+ return x.BaseCpuCount
+ }
+ return 0
+}
+
type PrepareMigrationIncomingRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
SandboxId string `protobuf:"bytes,1,opt,name=sandbox_id,json=sandboxId,proto3" json:"sandbox_id,omitempty"`
@@ -2852,10 +2868,11 @@ type PrepareMigrationIncomingRequest struct {
Template string `protobuf:"bytes,7,opt,name=template,proto3" json:"template,omitempty"`
RootfsS3Key string `protobuf:"bytes,8,opt,name=rootfs_s3_key,json=rootfsS3Key,proto3" json:"rootfs_s3_key,omitempty"` // if set, download from S3 instead of using local rootfs_path
WorkspaceS3Key string `protobuf:"bytes,9,opt,name=workspace_s3_key,json=workspaceS3Key,proto3" json:"workspace_s3_key,omitempty"` // if set, download from S3 instead of using local workspace_path
- OverlayMode bool `protobuf:"varint,10,opt,name=overlay_mode,json=overlayMode,proto3" json:"overlay_mode,omitempty"` // if true, rootfs is thin overlay — rebase to local golden on target
- TargetMemoryMb int32 `protobuf:"varint,11,opt,name=target_memory_mb,json=targetMemoryMb,proto3" json:"target_memory_mb,omitempty"` // final memory after scale — worker checks capacity and reserves atomically
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ OverlayMode bool `protobuf:"varint,10,opt,name=overlay_mode,json=overlayMode,proto3" json:"overlay_mode,omitempty"` // if true, rootfs is thin overlay — rebase to local golden on target
+ TargetMemoryMb int32 `protobuf:"varint,11,opt,name=target_memory_mb,json=targetMemoryMb,proto3" json:"target_memory_mb,omitempty"` // final memory after scale — worker checks capacity and reserves atomically
+ SourceGoldenVersion string `protobuf:"bytes,12,opt,name=source_golden_version,json=sourceGoldenVersion,proto3" json:"source_golden_version,omitempty"` // source's golden version — target rebases if different
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *PrepareMigrationIncomingRequest) Reset() {
@@ -2965,6 +2982,13 @@ func (x *PrepareMigrationIncomingRequest) GetTargetMemoryMb() int32 {
return 0
}
+func (x *PrepareMigrationIncomingRequest) GetSourceGoldenVersion() string {
+ if x != nil {
+ return x.SourceGoldenVersion
+ }
+ return ""
+}
+
type PrepareMigrationIncomingResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
IncomingAddr string `protobuf:"bytes,1,opt,name=incoming_addr,json=incomingAddr,proto3" json:"incoming_addr,omitempty"` // TCP address for source to migrate to (e.g. "10.100.1.7:49152")
diff --git a/proto/worker/worker.proto b/proto/worker/worker.proto
index 3e4d6c77..370212ea 100644
--- a/proto/worker/worker.proto
+++ b/proto/worker/worker.proto
@@ -322,13 +322,15 @@ message SetSandboxLimitsResponse {}
// Live migration messages
message PreCopyDrivesRequest {
string sandbox_id = 1;
- bool flatten_rootfs = 2; // if true, flatten qcow2 overlay before upload (cross-golden-version)
+ reserved 2; // was flatten_rootfs — no longer used; source always uploads thin overlay
}
message PreCopyDrivesResponse {
string rootfs_key = 1; // S3 key for rootfs qcow2
string workspace_key = 2; // S3 key for workspace qcow2
string golden_version = 3; // golden version the sandbox was created from
+ int32 base_memory_mb = 4; // QEMU -m value from source (target must match for migration)
+ int32 base_cpu_count = 5; // QEMU -smp value from source (target must match for migration)
}
message PrepareMigrationIncomingRequest {
@@ -343,6 +345,7 @@ message PrepareMigrationIncomingRequest {
string workspace_s3_key = 9; // if set, download from S3 instead of using local workspace_path
bool overlay_mode = 10; // if true, rootfs is thin overlay — rebase to local golden on target
int32 target_memory_mb = 11; // final memory after scale — worker checks capacity and reserves atomically
+ string source_golden_version = 12; // source's golden version — target rebases overlay if different from its own
}
message PrepareMigrationIncomingResponse {