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
|
|
@ -1,4 +1,5 @@
|
|||
import re
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.messages import get_messages
|
||||
|
|
@ -125,6 +126,31 @@ class AppSettingsTestCase(TestCase):
|
|||
self.post("LOGS_PER_PAGE", "50")
|
||||
self.assertEqual(AppSettings.objects.get(key="LOGS_PER_PAGE").value, "50")
|
||||
|
||||
def test_the_pair_is_checked_again_as_saved_when_it_is_saved(self):
|
||||
# another administrator saved the cache after this page read the settings: the first
|
||||
# check saw the pair as it was, the second, under the rows' lock, sees it as it is
|
||||
from appsettings import views
|
||||
|
||||
AppSettings.objects.filter(key="INSTANCE_VOLUME_DEFAULT_CACHE").update(value="writeback")
|
||||
real = views.combined_refusal
|
||||
calls = []
|
||||
|
||||
def stale_first(values):
|
||||
calls.append(values)
|
||||
return None if len(calls) == 1 else real(values)
|
||||
|
||||
with patch.object(views, "combined_refusal", side_effect=stale_first):
|
||||
response = self.client.post(reverse("appsettings"), {"INSTANCE_VOLUME_DEFAULT_IO": "native"},
|
||||
HTTP_ACCEPT_LANGUAGE="tr")
|
||||
self.assertEqual(len(calls), 2)
|
||||
self.assertEqual([str(m) for m in get_messages(response.wsgi_request)],
|
||||
["Disk G/Ç native, disk önbelleği none veya directsync olmasını gerektirir"])
|
||||
self.assertEqual(AppSettings.objects.get(key="INSTANCE_VOLUME_DEFAULT_IO").value, "default")
|
||||
# the log row keeps the reason in English, which each reader sees in their language
|
||||
from logs.models import Logs
|
||||
|
||||
self.assertIn("Disk I/O native needs disk cache none or directsync", Logs.objects.latest("id").message)
|
||||
|
||||
def page(self):
|
||||
from lxml import html
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue