An open-source, faster Devin alternative
TypeScript
fix forever natural drain, stale sandbox
Brian Reardon62795b9a84df
diff --git a/deploy/packer/round.txt b/deploy/packer/round.txtindex c06b7a26..e11c1927 100644--- a/deploy/packer/round.txt+++ b/deploy/packer/round.txt@@ -1 +1 @@-round-2+round-3diff --git a/internal/controlplane/scaler.go b/internal/controlplane/scaler.goindex c046972f..535fd280 100644--- a/internal/controlplane/scaler.go+++ b/internal/controlplane/scaler.go@@ -845,12 +845,24 @@ func (s *Scaler) drainWorker(workerID, machineID, region string) {return}- // If too many migration failures, fall back to natural expiry+ // If too many migration failures, back off and retry rather than falling+ // into forever-wait. Drains still bound by drainTimeout (45 min). The+ // failure cause is often transient — target worker just came up, old+ // base only just got uploaded, a previous attempt left stale files —+ // and a periodic reset lets us succeed once the transient clears. If+ // migration genuinely can't complete, drainTimeout terminates the loop+ // and the next eval tick takes over.if migrationFailures >= maxMigrationFailures {- log.Printf("scaler: drain: %d migration failures on %s, waiting for %d sandboxes to expire naturally",+ log.Printf("scaler: drain: %d migration failures on %s, backing off 5min before retry (%d sandboxes remaining)",migrationFailures, workerID, len(running))- s.waitForNaturalDrain(ctx, workerID)- return+ select {+ case <-ctx.Done():+ log.Printf("scaler: drain: timeout reached for worker %s", workerID)+ return+ case <-time.After(5 * time.Minute):+ }+ migrationFailures = 0+ continue}// Find target for this batchdiff --git a/internal/qemu/migration.go b/internal/qemu/migration.goindex 89b28b92..d9751902 100644--- a/internal/qemu/migration.go+++ b/internal/qemu/migration.go@@ -601,6 +601,13 @@ func (m *Manager) PreCopyDrives(ctx context.Context, sandboxID string, checkpoin// 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)+ // Clean any leftover state from a prior failed prepare attempt. Without this,+ // zstd refuses to overwrite an existing workspace.qcow2 and the retry fails+ // with "already exists; not overwritten". The incoming sandbox must not be+ // running on this worker yet, so removing is safe — drives come from S3.+ if err := os.RemoveAll(sandboxDir); err != nil {+ log.Printf("qemu: migration %s: cleanup stale sandbox dir: %v", sandboxID, err)+ }if err := os.MkdirAll(sandboxDir, 0755); err != nil {return "", 0, fmt.Errorf("mkdir: %w", err)}