Skip to content

Conversation

@smklein
Copy link
Collaborator

@smklein smklein commented Jan 8, 2026

Adds images as a virtual provisioning resource. Images are now tracked as a fourth resource type alongside Instance, Disk, and Snapshot.

Resource Accounting

  • Image creation increments virtual_disk_bytes_provisioned at the appropriate collection levels
  • Image deletion decrements it
  • Project-scoped images update: Project -> Silo -> Fleet collections
  • Silo-scoped images update: Silo -> Fleet collections

New Code

  • Added Image variant to ResourceTypeProvisioned and StorageType enums
  • Added silo-scoped CTE queries (new_insert_silo_storage, new_delete_silo_storage) for images without a project
  • Added SPACE_ACCOUNT saga action to both image_create and image_delete sagas
  • Data migration backfills accounting for all existing non-deleted images

Testing

  • Expectorate & Explain tests for all new SQL queries
  • Migration validation test for project and silo scoped images
  • Added a test_image_virtual_provisioning_collection integration test

Fixes #9602

@smklein smklein marked this pull request as ready for review January 9, 2026 00:08
@david-crespo
Copy link
Contributor

Maybe this is a silly question, but are images replicated the way disk volumes are? I ask because when you see virtual disk storage you can sort of mentally triple or quadruple it to reason about the physical disk size (as dubious an endeavor as that is) but if images are not replicated, then that math no longer works. Again that is probably fine because it is unwise to attempt to reason about physical capacity on the basis of these metrics anyway.

@jmpesp
Copy link
Contributor

jmpesp commented Jan 9, 2026

Yeah, images are backed by volumes in the same way that snapshots and crucible disks are, and the same replication factor applies

@smklein
Copy link
Collaborator Author

smklein commented Jan 9, 2026

Maybe this is a silly question, but are images replicated the way disk volumes are? I ask because when you see virtual disk storage you can sort of mentally triple or quadruple it to reason about the physical disk size (as dubious an endeavor as that is) but if images are not replicated, then that math no longer works. Again that is probably fine because it is unwise to attempt to reason about physical capacity on the basis of these metrics anyway.

This is a good question, and kinda the crux of the discussion in RFD 624 (which we still need to resolve - I'm just trying to track all these resources consistently to start). Local disks can/will violate this property, so we will need to adapt the accounting system to cope.

However, images are currently stored with triplicate redundancy, like distributed disks and snapshots.

@smklein smklein requested review from david-crespo and jmpesp January 9, 2026 22:02
.fetch()
.await;

if let Ok((.., authz_image, db_image)) = lookup_result {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth considering the possibility that this lookup fails for a reason other than the image not existing?

project_id
) AS totals
WHERE
vpc.id = totals.project_id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here in the migration you account for existing images in their current projects, but when these images are promoted to silo-level or demoted from silo to project there is nothing updating the accounting for that.

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.

Track image storage usage

4 participants