Skip to content

fix(vmm): validate an update before writing any of it - #1351

Merged
kvinwang merged 1 commit into
nextfrom
fix/vmm-update-validate-first
Sep 24, 2026
Merged

kvinwang merged 1 commit into
nextfrom
fix/vmm-update-validate-first

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

Problem

update_vm writes the compose file, encrypted env and user config, grows the data disk with qemu-img resize, and releases the VM's network interfaces before running the checks that can still reject the request (GPU, port mapping, networking, NIC agreement, key provider). A rejected update therefore leaves a new compose hash, env and grown disk against the old manifest.

For example, an update that adds a port the node's cvm.port_mapping refuses (#1286) still replaces the stored compose file:

assertion `left == right` failed
  left: "{\"manifest_version\":\"2\",\"name\":\"new\",\"runner\":\"docker-compose\"}"
 right: "{}"

Fix

Build and validate the new manifest in memory first, then apply side effects in one place: grow the disk, release interfaces, write compose/env/user config, write the manifest. Disk growth moves out of apply_resource_updates into grow_disk_if_needed, which resize_vm also calls. The swtpm decision reads the requested compose instead of the one just written; the result is the same.

Stacked on #1286.

Verification

New a_rejected_update_writes_nothing fails on #1286 (output above) and passes here. cargo test -p dstack-vmm (212 passed), cargo clippy -p dstack-vmm --bins -- -D warnings, cargo fmt --check.

@kvinwang
kvinwang added this pull request to stack #1352 September 24, 2026 06:17
Base automatically changed from fix/operator-boundary to next September 24, 2026 06:36
@kvinwang
kvinwang force-pushed the fix/vmm-update-validate-first branch from 573702d to 07a3287 Compare September 24, 2026 06:36
@kvinwang
kvinwang merged commit bd53a46 into next Sep 24, 2026
11 checks passed
@kvinwang
kvinwang deleted the fix/vmm-update-validate-first branch September 24, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant