Add admin endpoint to create a custom-spec VM - #337
Merged
Conversation
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.
Closes #335.
POST /api/admin/v1/vms/customcreates a VM from an arbitrary spec for any user, billed against a custom pricing plan. Previously the admin create path only acceptedtemplate_id, so an admin could not place the kind of order most customers actually make.CustomVmSpecinlnvps_api_common/src/model.rs:741-802, withto_template()doing all the string→enum parsing. Admin route and worker call the same function, so the request cannot validate differently from the job.disk_type/disk_interface/cpu_mfg/cpu_arch/cpu_featurespellings are a400before any DB lookup, never a default (lnvps_api_admin/src/admin/vms.rs:1279-1284). The customer path defaults silently here; on the admin path a typo would be someone else's machine.WorkJob::CreateCustomVm(lnvps_api_common/src/work/mod.rs:162-171) mirrors the existingCreateVmshape: async job,{ job_id }response,log_vm_createdwith admin metadata (lnvps_api/src/worker.rs:2774-2820).provision_custom, which already validates pricing enabled/expiry, image arch compatibility, spec range and host capacity (lnvps_api/src/provisioner/vm.rs:226-270). No new provisioning logic, and the VM is created unpaid like a customer order.POST /api/admin/v1/vms(template path) is untouched.Open question from the issue — job queue vs. direct call — settled on the queue: it keeps the admin create shape (
{ job_id }) consistent and the admin API has no provisioner.Tests: unit tests for spec→template and the flattened request body (
lnvps_api_common/src/model.rs:994-1065,lnvps_api_admin/src/admin/vms.rs:1441-1465); e2e inlnvps_e2e/src/admin_api.rs(unauthenticated → 403, bad spec values → 400) and the happy path inlnvps_e2e/src/lifecycle.rs:1648-1725, which asserts a new custom-template VM appears for the user.cargo test --workspacegreen at 307c644 (excludinglnvps_e2e, which needs the live stack); full e2e suite 167 passed in 16.5s via./scripts/run-e2e.sh; clippy clean on the lines touched.Docs:
ADMIN_API_ENDPOINTS.mdandAPI_CHANGELOG.mdupdated. Additive only — no response shape changed.Originating channel: general (
721a8a6c-c36c-5fa1-ae07-822ddc8567c5).