Skip to content

An open-source, faster Devin alternative

TypeScript

merge main

Brian Reardon5f35187bb74d
diff --cc internal/qemu/docs_compliance_test.go
index 12e5f62f,12e5f62f..cacaf3e6
--- a/internal/qemu/docs_compliance_test.go
+++ b/internal/qemu/docs_compliance_test.go
@@@ -398,7 -398,7 +398,7 @@@ var
_ func(context.Context, string, string) ([]types.EntryInfo, error) = (*Manager)(nil).ListDir
_ func(context.Context, string, *storage.CheckpointStore) (*sandbox.HibernateResult, error) = (*Manager)(nil).Hibernate
_ func(context.Context, string, string, *storage.CheckpointStore, int) (*types.Sandbox, error) = (*Manager)(nil).Wake
-- _ func(context.Context, string, string, *storage.CheckpointStore, func()) (string, string, error) = (*Manager)(nil).CreateCheckpoint
++ _ func(context.Context, string, string, *storage.CheckpointStore, func()) (string, string, int64, error) = (*Manager)(nil).CreateCheckpoint
_ func(context.Context, string, string) error = (*Manager)(nil).RestoreFromCheckpoint
_ func(context.Context, string, types.SandboxConfig) (*types.Sandbox, error) = (*Manager)(nil).ForkFromCheckpoint
)
diff --cc internal/qemu/manager.go
index 293028f7,b66bf9e4..6a4acb62
--- a/internal/qemu/manager.go
+++ b/internal/qemu/manager.go
@@@ -2035,18 -2037,56 +2046,68 @@@ func (m *Manager) SetResourceLimits(ct
return vm.agent.SetResourceLimits(ctx, maxPids, maxMemoryBytes, cpuMaxUsec, cpuPeriodUsec)
}
+// UpdateSandboxSecret refreshes the proxy session value for one secret name.
+// Returns (true, nil) on success, (false, nil) if there's no session for the
+// sandbox or the secret name isn't on the session — both treated as transient
+// (e.g. mid-migration); the caller may log + move on. Returns an error only
+// on hard failure (no proxy at all).
+func (m *Manager) UpdateSandboxSecret(_ context.Context, sandboxID, secretName, value string) (bool, error) {
+ if m.secretsProxy == nil {
+ return false, fmt.Errorf("secrets proxy not configured on this worker")
+ }
+ return m.secretsProxy.UpdateSecretValue(sandboxID, secretName, value), nil
+}
+
+ // watchMemoryHotplug polls the guest's /proc/meminfo until at least 1GB of
+ // virtio-mem memory has been onlined (or target if smaller), then closes
+ // vm.memoryReady to unblock getReadyVM. Bounded by a 10s timeout so the
+ // channel always closes even if hotplug stalls.
+ func (m *Manager) watchMemoryHotplug(vm *VMInstance, targetAdditionalMB int) {
+ defer func() {
+ if vm.memoryReady != nil {
+ select {
+ case <-vm.memoryReady:
+ default:
+ close(vm.memoryReady)
+ }
+ }
+ }()
+
+ // We only need ~1GB plugged for most workloads to have breathing room.
+ // The rest hotplugs in the background and is usually done within seconds.
+ readyThresholdMB := 1024
+ if targetAdditionalMB < readyThresholdMB {
+ readyThresholdMB = targetAdditionalMB
+ }
+ requiredTotalMB := vm.baseMemoryMB + readyThresholdMB
+
+ deadline := time.Now().Add(10 * time.Second)
+ for time.Now().Before(deadline) {
+ if vm.agent == nil {
+ return
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
+ resp, err := vm.agent.Exec(ctx, &pb.ExecRequest{
+ Command: "/bin/sh",
+ Args: []string{"-c", "awk '/MemTotal/ {print $2}' /proc/meminfo"},
+ TimeoutSeconds: 2,
+ })
+ cancel()
+ if err == nil && resp != nil {
+ // MemTotal is in kB
+ var kB int
+ fmt.Sscanf(string(resp.Stdout), "%d", &kB)
+ if kB/1024 >= requiredTotalMB {
+ log.Printf("qemu: virtio-mem %s: hotplug gate opened (%dMB onlined, needed %dMB)",
+ vm.ID, kB/1024, requiredTotalMB)
+ return
+ }
+ }
+ time.Sleep(100 * time.Millisecond)
+ }
+ log.Printf("qemu: virtio-mem %s: hotplug gate timed out after 10s, unblocking anyway", vm.ID)
+ }
+
// TotalCommittedMemoryMB returns the sum of MemoryMB (base + virtio-mem) across all running VMs.
// This represents the maximum host memory that could be consumed if all VMs use their full allocation.
func (m *Manager) TotalCommittedMemoryMB() int {