Skip to content

Commit 4db0113

Browse files
committed
CA-408105: add logging to _finishInterruptedCoalesceLeaf
No error logging is present in two error paths which make diagnosis difficult/impossible. Signed-off-by: Mark Syms <mark.syms@cloud.com>
1 parent 9f6fb0a commit 4db0113

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

libs/sm/cleanup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,10 +2635,12 @@ def _finishInterruptedCoalesceLeaf(self, childUuid, parentUuid):
26352635
Util.log("*** FINISH LEAF-COALESCE")
26362636
vdi = self.getVDI(childUuid)
26372637
if not vdi:
2638+
Util.log(f"_finishInterruptedCoalesceLeaf, vdi {childUuid} not found, aborting")
26382639
raise util.SMException("VDI %s not found" % childUuid)
26392640
try:
26402641
self.forgetVDI(parentUuid)
26412642
except XenAPI.Failure:
2643+
Util.logException('_finishInterruptedCoalesceLeaf')
26422644
pass
26432645
self._updateSlavesOnResize(vdi)
26442646
util.fistpoint.activate("LVHDRT_coaleaf_finish_end", self.uuid)

tests/test_cleanup.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
from sm import cleanup
1010
from sm import fjournaler
1111
from sm.core import lock
12+
from sm.core.util import SMException
1213

1314
from sm.core import util
1415
from sm import vhdutil
1516

1617
from sm import ipc
1718

1819
import XenAPI
20+
from XenAPI import Failure
1921

2022
MEGA = 1024 * 1024
2123

@@ -1962,3 +1964,46 @@ def test_cannot_acquire_if_other_process_holds_sr_lock(self):
19621964
# When
19631965
with self.assertRaises(BlockingIOError):
19641966
gcLock.acquireNoblock()
1967+
1968+
1969+
class TestFileSR(TestSR):
1970+
"""
1971+
Exercise the specfic bits of the FileSR support
1972+
"""
1973+
1974+
def setUp(self):
1975+
super().setUp()
1976+
1977+
self.sr_uuid = str(uuid.uuid4())
1978+
1979+
def _make_test_sr(self):
1980+
self.mock_sr = cleanup.FileSR(self.sr_uuid, self.xapi_mock,
1981+
createLock=False, force=False)
1982+
1983+
def test_finishInterruptedCoalesceLeaf_no_vdi(self):
1984+
self._make_test_sr()
1985+
self.mock_sr.vdis = {}
1986+
1987+
child_vdi_uuid = str(uuid.uuid4())
1988+
parent_vdi_uuid = str(uuid.uuid4())
1989+
1990+
with self.assertRaises(SMException) as sme:
1991+
self.mock_sr._finishInterruptedCoalesceLeaf(child_vdi_uuid, parent_vdi_uuid)
1992+
1993+
self.assertRegex(str(sme.exception), r"VDI \S+ not found")
1994+
1995+
def test_finishInterruptedCoalesceLeaf_forget_fail_and_complete(self):
1996+
child_vdi_uuid = str(uuid.uuid4())
1997+
parent_vdi_uuid = str(uuid.uuid4())
1998+
1999+
self._make_test_sr()
2000+
self.mock_sr.vdis = {
2001+
child_vdi_uuid: mock.create_autospec(cleanup.FileVDI)
2002+
}
2003+
2004+
def forgetVdi(self, uuid):
2005+
raise Failure(f"ForgetVDI {uuid} failed")
2006+
2007+
self.xapi_mock.forgetVDI.side_effect = forgetVdi
2008+
2009+
self.mock_sr._finishInterruptedCoalesceLeaf(child_vdi_uuid, parent_vdi_uuid)

0 commit comments

Comments
 (0)