Commit a57ddcd
committed
Fix GC hidden attribute in case of SIGTERM signal (#87)
The GC can be interrupted by a SIGTERM signal. If this is caught while modifying
a volume's hidden flag, this can have bad consequences.
For example in the situation below, the hidden flag of a volume has been changed
but the cached value (self.hidden) in the python process still has the old value
because of the 'util.CommandException' exception that was thrown. A VDI
that normally should not be hidden is still hidden after executing
`_undoInterruptedCoalesceLeaf` because the hidden value was not the correct one.
Code:
```
def _setHidden(self, hidden=True):
vhdutil.setHidden(self.path, hidden)
# Exception! Next line is never executed.
self.hidden = hidden
```
Trace:
```
Jun 5 09:15:50 r620-q6 SMGC: [563219] Removed vhd-parent from dce4b0fc(2.000G/170.336M?)
Jun 5 09:15:50 r620-q6 SMGC: [563219] Removed vhd-blocks from dce4b0fc(2.000G/170.336M?)
Jun 5 09:15:50 r620-q6 SM: [563219] ['/usr/bin/vhd-util', 'set', '--debug', '-n', '/var/run/sr-mount/f816795d-e7a9-43df-170c-23bc329607fc/OLD_dce4b0fc-6ad1-4750-857b-45d8d2758503.vhd', '-f', 'hidden', '-v', '1']
Jun 5 09:15:50 r620-q6 SM: [563219] GC: recieved SIGTERM
Jun 5 09:15:50 r620-q6 SM: [563219] FAILED in util.pread: (rc -15) stdout: '', stderr: ''
Jun 5 09:15:50 r620-q6 SMGC: [563219] *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
Jun 5 09:15:50 r620-q6 SMGC: [563219] ***********************
Jun 5 09:15:50 r620-q6 SMGC: [563219] * E X C E P T I O N *
Jun 5 09:15:50 r620-q6 SMGC: [563219] ***********************
Jun 5 09:15:50 r620-q6 SMGC: [563219] _doCoalesceLeaf: EXCEPTION <class 'util.CommandException'>, Signalled 15
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/cleanup.py", line 2653, in _liveLeafCoalesce
Jun 5 09:15:50 r620-q6 SMGC: [563219] self._doCoalesceLeaf(vdi)
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/cleanup.py", line 2717, in _doCoalesceLeaf
Jun 5 09:15:50 r620-q6 SMGC: [563219] vdi._setHidden(True)
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/cleanup.py", line 1063, in _setHidden
Jun 5 09:15:50 r620-q6 SMGC: [563219] vhdutil.setHidden(self.path, hidden)
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/vhdutil.py", line 235, in setHidden
Jun 5 09:15:50 r620-q6 SMGC: [563219] ret = ioretry(cmd)
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/vhdutil.py", line 94, in ioretry
Jun 5 09:15:50 r620-q6 SMGC: [563219] errlist=[errno.EIO, errno.EAGAIN])
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/util.py", line 347, in ioretry
Jun 5 09:15:50 r620-q6 SMGC: [563219] return f()
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/vhdutil.py", line 93, in <lambda>
Jun 5 09:15:50 r620-q6 SMGC: [563219] return util.ioretry(lambda: util.pread2(cmd, text=text),
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/util.py", line 255, in pread2
Jun 5 09:15:50 r620-q6 SMGC: [563219] return pread(cmdlist, quiet=quiet, text=text)
Jun 5 09:15:50 r620-q6 SMGC: [563219] File "/opt/xensource/sm/util.py", line 217, in pread
Jun 5 09:15:50 r620-q6 SMGC: [563219] raise CommandException(rc, str(cmdlist), stderr.strip())
Jun 5 09:15:50 r620-q6 SMGC: [563219]
Jun 5 09:15:50 r620-q6 SMGC: [563219] *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
Jun 5 09:15:50 r620-q6 SMGC: [563219] *** UNDO LEAF-COALESCE
Jun 5 09:15:50 r620-q6 SMGC: [563219] Renaming parent back: dce4b0fc-6ad1-4750-857b-45d8d2758503 -> 056b6f93-66ff-460a-9354-157540b584a8
Jun 5 09:15:50 r620-q6 SMGC: [563219] Renaming /var/run/sr-mount/f816795d-e7a9-43df-170c-23bc329607fc/dce4b0fc-6ad1-4750-857b-45d8d2758503.vhd -> /var/run/sr-mount/f816795d-e7a9-43df-170c-23bc329607fc/056b6f93-66ff-460a-9354-157540b584a8.vhd
Jun 5 09:15:50 r620-q6 SMGC: [563219] Renaming child back to dce4b0fc-6ad1-4750-857b-45d8d2758503
Jun 5 09:15:50 r620-q6 SMGC: [563219] Renaming /var/run/sr-mount/f816795d-e7a9-43df-170c-23bc329607fc/OLD_dce4b0fc-6ad1-4750-857b-45d8d2758503.vhd -> /var/run/sr-mount/f816795d-e7a9-43df-170c-23bc329607fc/dce4b0fc-6ad1-4750-857b-45d8d2758503.vhd
Jun 5 09:15:50 r620-q6 SMGC: [563219] Updating the VDI record
Jun 5 09:15:50 r620-q6 SMGC: [563219] Set vhd-parent = 056b6f93-66ff-460a-9354-157540b584a8 for dce4b0fc(2.000G/8.500K?)
Jun 5 09:15:50 r620-q6 SMGC: [563219] Set vdi_type = vhd for dce4b0fc(2.000G/8.500K?)
Jun 5 09:15:50 r620-q6 SM: [563219] ['/usr/bin/vhd-util', 'set', '--debug', '-n', '/var/run/sr-mount/f816795d-e7a9-43df-170c-23bc329607fc/056b6f93-66ff-460a-9354-157540b584a8.vhd', '-f', 'hidden', '-v', '1']
Jun 5 09:15:50 r620-q6 SM: [563219] pread SUCCESS
Jun 5 09:15:50 r620-q6 SMGC: [563219] *** leaf-coalesce undo successful
```
Therefore, a VDI impacted by this problem remains hidden and can no longer
be used correctly without manual intervention:
```
Jun 5 09:16:29 r620-q6 SM: [566174] lock: released /var/lock/sm/f816795d-e7a9-43df-170c-23bc329607fc/sr
Jun 5 09:16:29 r620-q6 SM: [566174] ***** generic exception: vdi_clone: EXCEPTION <class 'xs_errors.SROSError'>, Failed to clone VDI [opterr=hidden VDI]
Jun 5 09:16:29 r620-q6 SM: [566174] File "/opt/xensource/sm/SRCommand.py", line 113, in run
Jun 5 09:16:29 r620-q6 SM: [566174] return self._run_locked(sr)
Jun 5 09:16:29 r620-q6 SM: [566174] File "/opt/xensource/sm/SRCommand.py", line 163, in _run_locked
Jun 5 09:16:29 r620-q6 SM: [566174] rv = self._run(sr, target)
Jun 5 09:16:29 r620-q6 SM: [566174] File "/opt/xensource/sm/SRCommand.py", line 270, in _run
Jun 5 09:16:29 r620-q6 SM: [566174] return target.clone(self.params['sr_uuid'], self.vdi_uuid)
Jun 5 09:16:29 r620-q6 SM: [566174] File "/opt/xensource/sm/FileSR.py", line 704, in clone
Jun 5 09:16:29 r620-q6 SM: [566174] return self._do_snapshot(sr_uuid, vdi_uuid, VDI.SNAPSHOT_DOUBLE)
Jun 5 09:16:29 r620-q6 SM: [566174] File "/opt/xensource/sm/FileSR.py", line 754, in _do_snapshot
Jun 5 09:16:29 r620-q6 SM: [566174] return self._snapshot(snapType, cbtlog, consistency_state)
Jun 5 09:16:29 r620-q6 SM: [566174] File "/opt/xensource/sm/FileSR.py", line 797, in _snapshot
Jun 5 09:16:29 r620-q6 SM: [566174] raise xs_errors.XenError('VDIClone', opterr='hidden VDI')
Jun 5 09:16:29 r620-q6 SM: [566174]
```
Signed-off-by: Ronan Abhamon <[email protected]>1 parent 654ffc1 commit a57ddcd
1 file changed
+29
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | | - | |
| 564 | + | |
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| |||
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
667 | | - | |
| 667 | + | |
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
675 | | - | |
| 675 | + | |
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
| |||
700 | 700 | | |
701 | 701 | | |
702 | 702 | | |
703 | | - | |
| 703 | + | |
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
| |||
724 | 724 | | |
725 | 725 | | |
726 | 726 | | |
727 | | - | |
| 727 | + | |
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| |||
795 | 795 | | |
796 | 796 | | |
797 | 797 | | |
798 | | - | |
| 798 | + | |
799 | 799 | | |
800 | 800 | | |
801 | 801 | | |
| |||
1055 | 1055 | | |
1056 | 1056 | | |
1057 | 1057 | | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1058 | 1063 | | |
1059 | 1064 | | |
1060 | | - | |
| 1065 | + | |
1061 | 1066 | | |
1062 | 1067 | | |
| 1068 | + | |
1063 | 1069 | | |
1064 | | - | |
| 1070 | + | |
1065 | 1071 | | |
1066 | 1072 | | |
1067 | 1073 | | |
| |||
1186 | 1192 | | |
1187 | 1193 | | |
1188 | 1194 | | |
1189 | | - | |
| 1195 | + | |
1190 | 1196 | | |
1191 | 1197 | | |
1192 | 1198 | | |
| |||
1245 | 1251 | | |
1246 | 1252 | | |
1247 | 1253 | | |
1248 | | - | |
| 1254 | + | |
1249 | 1255 | | |
1250 | 1256 | | |
1251 | 1257 | | |
| |||
1379 | 1385 | | |
1380 | 1386 | | |
1381 | 1387 | | |
1382 | | - | |
| 1388 | + | |
1383 | 1389 | | |
1384 | 1390 | | |
1385 | 1391 | | |
1386 | 1392 | | |
1387 | 1393 | | |
1388 | 1394 | | |
| 1395 | + | |
1389 | 1396 | | |
1390 | | - | |
| 1397 | + | |
1391 | 1398 | | |
1392 | 1399 | | |
1393 | 1400 | | |
| |||
1397 | 1404 | | |
1398 | 1405 | | |
1399 | 1406 | | |
1400 | | - | |
| 1407 | + | |
1401 | 1408 | | |
1402 | 1409 | | |
1403 | 1410 | | |
| |||
1575 | 1582 | | |
1576 | 1583 | | |
1577 | 1584 | | |
1578 | | - | |
| 1585 | + | |
1579 | 1586 | | |
1580 | 1587 | | |
1581 | 1588 | | |
| |||
1749 | 1756 | | |
1750 | 1757 | | |
1751 | 1758 | | |
| 1759 | + | |
1752 | 1760 | | |
1753 | 1761 | | |
1754 | 1762 | | |
1755 | | - | |
| 1763 | + | |
1756 | 1764 | | |
1757 | 1765 | | |
1758 | 1766 | | |
| |||
3015 | 3023 | | |
3016 | 3024 | | |
3017 | 3025 | | |
3018 | | - | |
| 3026 | + | |
3019 | 3027 | | |
3020 | | - | |
| 3028 | + | |
3021 | 3029 | | |
3022 | 3030 | | |
3023 | 3031 | | |
| |||
3251 | 3259 | | |
3252 | 3260 | | |
3253 | 3261 | | |
3254 | | - | |
| 3262 | + | |
3255 | 3263 | | |
3256 | | - | |
| 3264 | + | |
3257 | 3265 | | |
3258 | 3266 | | |
3259 | 3267 | | |
| |||
3607 | 3615 | | |
3608 | 3616 | | |
3609 | 3617 | | |
3610 | | - | |
| 3618 | + | |
3611 | 3619 | | |
3612 | | - | |
| 3620 | + | |
3613 | 3621 | | |
3614 | 3622 | | |
3615 | 3623 | | |
| |||
0 commit comments