mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 04:36:48 +00:00
fix(instances): a snapshot needs free space in the VM's storage pools
A disk-only snapshot was taken without any space check, though its overlays grow as the guest writes and a later delete merges them down; a full pool pauses the guest and can leave the snapshot undeletable. Only a memory snapshot was checked, for the memory alone. Before a snapshot, each storage pool with a disk of the VM must have free a share of those disks' virtual size (10%, at least 1 GiB), and the pool of the memory file the VM's memory on top. Both values are on the Settings page (Snapshot Free Percent, Snapshot Free Min GiB; 0 turns a rule off, an invalid value keeps the default). The pools are refreshed first, and a failed refresh or an unreadable volume refuses the snapshot instead of skipping the check; a disk in no pool is not checked. Nothing is reserved: later writes can still fill a pool.
This commit is contained in:
parent
f766890825
commit
5f8f7a8643
8 changed files with 227 additions and 30 deletions
|
|
@ -40,3 +40,14 @@ class NicTypeTestCase(TestCase):
|
|||
nic_type.fix_rtl8139(apps, SimpleNamespace(connection=connection))
|
||||
setting.refresh_from_db()
|
||||
self.assertEqual((setting.value, setting.choices), ("rtl8139", "default,e1000,e1000e,rtl8139,virtio"))
|
||||
|
||||
|
||||
class SnapshotFreeSpaceSettingsTestCase(TestCase):
|
||||
def test_the_rows_fit_their_columns(self):
|
||||
# PostgreSQL refuses a value longer than the column, sqlite does not
|
||||
for key in ("SNAPSHOT_FREE_SPACE_PERCENT", "SNAPSHOT_FREE_SPACE_MIN_GIB"):
|
||||
setting = AppSettings.objects.get(key=key)
|
||||
for field in ("name", "key", "value", "description"):
|
||||
limit = AppSettings._meta.get_field(field).max_length
|
||||
if limit:
|
||||
self.assertLessEqual(len(getattr(setting, field)), limit, f"{key} {field}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue