Skip to content

feat: OS image popularity, reinstall with new image, admin VM transfer#179

Merged
v0l merged 3 commits into
masterfrom
feat/os-popularity-reinstall-image-transfer
Jul 20, 2026
Merged

feat: OS image popularity, reinstall with new image, admin VM transfer#179
v0l merged 3 commits into
masterfrom
feat/os-popularity-reinstall-image-transfer

Conversation

@v0l

@v0l v0l commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Batch implementation of three issues.

#70 — OS image popularity

GET /api/v1/image now returns a popularity field per image: the fraction (0.0–1.0) of active VMs currently using it. New DB method count_vms_by_os_image.

#177 — Change OS (reinstall)

PATCH /api/v1/vm/{id}/re-install now accepts an optional { image_id } body to switch OS image during reinstall. The image must exist and be enabled; the change is persisted before the reinstall pipeline and recorded in VM history.

#178 — Transfer VM (admin)

New POST /api/admin/v1/vms/{id}/transfer (virtual_machines::update) reassigns a VM (and its billing subscription) to another user, clearing the old owner's SSH key. Adds a Transferred VM-history action + logger. Rejects deleted VMs / self-transfers (409) and unknown users (404).

Tests & docs

  • Unit tests for new DB/mock methods and history logger; e2e tests for transfer endpoint and popularity field.
  • Updated API_CHANGELOG.md, API_DOCUMENTATION.md, ADMIN_API_ENDPOINTS.md.

Fixes #70
Fixes #177
Fixes #178

v0l added 3 commits July 20, 2026 13:48
- #70: add popularity (fraction of active VMs) to GET /api/v1/image
- #177: allow optional image_id in PATCH /api/v1/vm/{id}/re-install
- #178: add POST /api/admin/v1/vms/{id}/transfer for admin VM ownership transfer

Adds DB methods count_vms_by_os_image and admin_transfer_vm, a Transferred
VM-history action + logger, mock impls, unit/e2e tests, and doc updates.
The 20260720130000_cascade_delete_child_tables migration combined
`DROP FOREIGN KEY x, ADD CONSTRAINT x ...` in a single ALTER, which
InnoDB (MySQL & MariaDB) rejects with errno 121 (duplicate key) because
the old constraint name still exists while the same-named new one is
added. This crashed API startup on a fresh DB, breaking the e2e run.
Split each into two separate ALTER statements. Verified all migrations
apply cleanly on a fresh mariadb:latest.
The auto-generated FK names for referral/referral_payout (created without
explicit CONSTRAINT names) are server-version dependent, so the hardcoded
`referral_ibfk_1` drop failed on CI's MariaDB (error 1091). Resolve the
real constraint name from information_schema and drop it via PREPARE/EXECUTE
so the migration is version-independent. Verified end-to-end through the
real sqlx migrator against mariadb:latest.
@v0l
v0l merged commit 145707c into master Jul 20, 2026
8 checks passed
@v0l
v0l deleted the feat/os-popularity-reinstall-image-transfer branch July 20, 2026 13:33
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.

Transfer VM Change OS (reinstall) OS Image popularity

1 participant