-
Notifications
You must be signed in to change notification settings - Fork 66
Add images to resource accounting #9613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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. |
|
Yeah, images are backed by volumes in the same way that snapshots and crucible disks are, and the same replication factor applies |
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. |
| project_id | ||
| ) AS totals | ||
| WHERE | ||
| vpc.id = totals.project_id; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, totally forgot about image promotion / demotion.
I've updated promotion/demotion to handle this case by "subtracting the old accounting, then adding the new accounting" within a transaction.
Added tests for this, as well as tests that "double demotion" and "double promotion" returns errors (as expected).
| ), | ||
| time_modified = NOW() | ||
| WHERE | ||
| collection_type = 'Fleet'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These operations are not idempotent: if run more than once, they will add the sums to the total again every time. How bad is that? Feels a little complicated to avoid it, but we might have to.
|
Two issues found by Codex and confirmed by Claude. First one checks out, seems straightforward. Second one is pretty subtle but it sounds real. The robot is correct that the easy thing to do is just say you can't promote/demote images when you're over quota, even though technically you should be able to. Issue 1: Missing Clickhouse MetricsThe helper methods in The promote/demote code in Issue 2: Quota Check Blocking Over-Quota SilosConsider
The net silo change is zero. However, the insert query ( quota >= current_silo_storage + sizeAfter step 1 commits within the transaction, If the silo was already over quota ( Possible FixesFor issue 1: Either call the helper methods instead of the raw queries, or explicitly call For issue 2: This is more complex. Options include:
|
Adds images as a virtual provisioning resource. Images are now tracked as a fourth resource type alongside Instance, Disk, and Snapshot.
Resource Accounting
virtual_disk_bytes_provisionedat the appropriate collection levelsNew Code
ResourceTypeProvisionedandStorageTypeenumsnew_insert_silo_storage,new_delete_silo_storage) for images without a projectSPACE_ACCOUNTsaga action to bothimage_createandimage_deletesagasTesting
test_image_virtual_provisioning_collectionintegration testFixes #9602