mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
fix(instances): a new VM's disk cache goes with the disk I/O of Settings
Settings refuse disk I/O native with a cache other than none or directsync, which libvirt refuses. A new VM took the I/O from Settings and its cache from the create form, unchecked: native I/O with a writeback cache was queued, the disks were made, and libvirt then refused the VM. The create job now refuses such a pair when it is asked for, and again when it runs, before it makes a disk: Settings may have changed meanwhile. Two administrators saving the I/O and the cache at once each checked the pair as their page read it, and both saves made one libvirt refuses. The pair is now checked again as saved, with its rows locked, when a change of it is saved; the log row keeps the reason in English.
This commit is contained in:
parent
7bbc951082
commit
5a52bcf43e
8 changed files with 207 additions and 122 deletions
|
|
@ -80,6 +80,29 @@ class CreateJobTestCase(TransactionTestCase):
|
|||
self.assertEqual(response.status_code, 400)
|
||||
self.assertFalse(Operation.objects.exists())
|
||||
|
||||
def test_a_cache_that_does_not_go_with_the_settings_io_is_refused_and_the_io_kept(self):
|
||||
# libvirt refuses native I/O with a cache other than none or directsync, after the disks are made
|
||||
from appsettings.models import AppSettings
|
||||
|
||||
self.conn.get_cache_modes.return_value = {"none": "Disable cache", "writeback": "Write back"}
|
||||
# a TransactionTestCase run before may have emptied the table
|
||||
AppSettings.objects.update_or_create(key="INSTANCE_VOLUME_DEFAULT_IO", defaults={
|
||||
"name": "Disk IO Type", "value": "native", "choices": "default,native,threads"})
|
||||
url = f"/api/v1/computes/{self.compute.pk}/instances/create/x86_64/q35/"
|
||||
response = self.client.post(url, {**BODY, "cache_mode": "writeback"}, content_type="application/json")
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertIn("does not go with disk I/O native", str(response.json()))
|
||||
self.assertEqual(self.client.post(url, BODY, content_type="application/json").status_code, 202)
|
||||
# a pair Settings made one libvirt refuses after the job was asked for: refused before a disk is made
|
||||
op = Operation.objects.get()
|
||||
Operation.objects.filter(pk=op.pk).update(params={**op.params, "cache_mode": "writeback"})
|
||||
acquire("wvc-test:1:a", "wvc-test")
|
||||
Operation.objects.filter(pk=op.pk).update(state=Operation.RUNNING, worker="wvc-test:1:a")
|
||||
op.refresh_from_db()
|
||||
with self.assertRaisesRegex(OperationError, "does not go with disk I/O native"):
|
||||
CreateInstance().run(op, Context(op, SimpleNamespace(identity="wvc-test:1:a")))
|
||||
self.conn.create_volume.assert_not_called()
|
||||
|
||||
def test_the_cpu_is_a_mode_or_a_model_the_host_offers(self):
|
||||
url = f"/api/v1/computes/{self.compute.pk}/instances/create/x86_64/q35/"
|
||||
# a model name longer than 20 characters is taken; none, or one the host lacks, is refused
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue