Expose host CPU architecture on customer VM status (#210)#211
Merged
Conversation
Add an optional cpu_arch string to ApiVmStatus, sourced from the host record rather than the template constraint, so it is present whenever the host arch is known. Clients can then always pass ?arch= when listing OS images for a reinstall (#202) and avoid offering images that would fail provisioning (#183). - Reuse the existing get_host fetch in vm_to_status (for host_sunset_date) to also derive cpu_arch; the Unknown sentinel maps to None/omitted. - Unit test covers x86_64, arm64, and the omitted-unknown case. - Docs + changelog.
vm_to_status now takes the VM's host as a parameter (like the running state) rather than fetching it internally. GET /api/v1/vms bulk-loads all hosts once (there are few) and indexes them by id, avoiding one host query per VM. Single-VM handlers pass a single get_host result. Tests updated to supply the host.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #210.
Summary
The customer VM status only carried CPU architecture indirectly via
template.cpu_arch, an optional template constraint that is omitted when the template doesn't pin an architecture. This adds the host's concrete architecture to the VM status so clients are never architecture-blind.Changes
cpu_arch("x86_64"|"arm64") toApiVmStatus(GET /api/v1/vm/{id},GET /api/v1/vms), sourced from the host record.vm_to_statusreuses theget_hostfetch already done forhost_sunset_date; theUnknownsentinel maps toNone(field omitted).Lets clients always pass
?arch=when listing OS images for a reinstall (#202), avoiding incompatible images that #183 rejects at provisioning.Related: #183, #202.