1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 04:36:48 +00:00

fix(storages): an unexpected ISO upload failure is logged

The upload view sent the error of an unexpected failure to the browser
but left nothing in the server log, so whoever runs the server had no
trace of it. It is logged with its traceback now; the superuser still
sees the message.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
catborise 2026-10-21 21:38:34 +03:00
parent 2144b3fe20
commit ef1faf57c8
2 changed files with 10 additions and 0 deletions

View file

@ -644,6 +644,13 @@ class UploadViewTests(LocalPool, UploadTestCase):
response = self.post()
self.assertEqual((response.status_code, response.json()["error"]), (400, "ISO image already exists"))
def test_an_unexpected_failure_is_logged(self):
with patch("storages.views.write_chunk", side_effect=OSError("disk gone")), \
self.assertLogs("storages.views", "ERROR") as logs:
response = self.post()
self.assertEqual((response.status_code, response.json()["error"]), (500, "disk gone"))
self.assertIn("OSError: disk gone", logs.output[0])
def test_a_busy_session_is_retried(self):
self.post(0, total=2, size="6")
claims.admit({f"upload:{self.job().pk}": Claim.EXCLUSIVE}, holder="192.0.2.30:1:1")