Skip to content

fix(instances): correct stopped VM resource reporting and add tests - #55

Merged
laolusrael merged 3 commits into
developfrom
feature/edit-instance-resources
Apr 23, 2026
Merged

fix(instances): correct stopped VM resource reporting and add tests#55
laolusrael merged 3 commits into
developfrom
feature/edit-instance-resources

Conversation

@laolusrael

Copy link
Copy Markdown
Owner

Summary

Fixes the endpoint /api/instances/{name} returning incorrect resource values (memory: "0 B", disk: "0 B") for stopped instances.

Problem

When a VM is stopped, multipass info reports memory.total: 0 and disk.total: 0. The existing fallback logic checked instance.Memory == "" and instance.Disk == "", but formatBytes(0) returns "0 B" -- so the fallback to multipass get never triggered.

Fix

  • Check the raw memBytes and diskBytes values (before formatting) for zero instead of checking the formatted strings
  • This correctly triggers the fallback to multipass get local.<name>.{cpus,memory,disk} for stopped VMs

Also Includes

  • Linux disk detection improvements -- GetHostInfo() uses multipassDataDir() to locate VM data directory
  • macOS data directory detection -- added Library/Application Support/multipassd paths
  • Handler tests -- 8 UpdateResources tests + HostHandler tests
  • Mock client fix -- GetInstance returns proper error instead of nil, nil
  • Integration test fix -- skips when multipass is unavailable

Test Results

  • go test -tags ci ./... -- Pass
  • gofmt -d . -- Clean
  • npx vitest --run -- 15/15 pass
  • npm run lint -- Clean
  • npm run build -- Success

@laolusrael
laolusrael merged commit 2620d07 into develop Apr 23, 2026
5 checks passed
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