Commit 3ecfefa
Fix GC hidden attribute in case of SIGTERM signal
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 179f3f7 commit 3ecfefa
1 file changed
+23
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
535 | 535 | | |
536 | 536 | | |
537 | 537 | | |
538 | | - | |
| 538 | + | |
539 | 539 | | |
540 | 540 | | |
541 | 541 | | |
| |||
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
641 | | - | |
| 641 | + | |
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
649 | | - | |
| 649 | + | |
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
677 | | - | |
| 677 | + | |
678 | 678 | | |
679 | 679 | | |
680 | 680 | | |
| |||
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
753 | | - | |
| 753 | + | |
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
| |||
1007 | 1007 | | |
1008 | 1008 | | |
1009 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
1010 | 1015 | | |
1011 | 1016 | | |
1012 | | - | |
| 1017 | + | |
1013 | 1018 | | |
1014 | 1019 | | |
| 1020 | + | |
1015 | 1021 | | |
1016 | | - | |
| 1022 | + | |
1017 | 1023 | | |
1018 | 1024 | | |
1019 | 1025 | | |
| |||
1136 | 1142 | | |
1137 | 1143 | | |
1138 | 1144 | | |
1139 | | - | |
| 1145 | + | |
1140 | 1146 | | |
1141 | 1147 | | |
1142 | 1148 | | |
| |||
1189 | 1195 | | |
1190 | 1196 | | |
1191 | 1197 | | |
1192 | | - | |
| 1198 | + | |
1193 | 1199 | | |
1194 | 1200 | | |
1195 | 1201 | | |
| |||
1314 | 1320 | | |
1315 | 1321 | | |
1316 | 1322 | | |
1317 | | - | |
| 1323 | + | |
1318 | 1324 | | |
1319 | 1325 | | |
1320 | 1326 | | |
1321 | 1327 | | |
1322 | 1328 | | |
| 1329 | + | |
1323 | 1330 | | |
1324 | | - | |
| 1331 | + | |
1325 | 1332 | | |
1326 | 1333 | | |
1327 | 1334 | | |
| |||
1330 | 1337 | | |
1331 | 1338 | | |
1332 | 1339 | | |
1333 | | - | |
| 1340 | + | |
1334 | 1341 | | |
1335 | 1342 | | |
1336 | 1343 | | |
| |||
2612 | 2619 | | |
2613 | 2620 | | |
2614 | 2621 | | |
2615 | | - | |
| 2622 | + | |
2616 | 2623 | | |
2617 | | - | |
| 2624 | + | |
2618 | 2625 | | |
2619 | 2626 | | |
2620 | 2627 | | |
| |||
2827 | 2834 | | |
2828 | 2835 | | |
2829 | 2836 | | |
2830 | | - | |
| 2837 | + | |
2831 | 2838 | | |
2832 | | - | |
| 2839 | + | |
2833 | 2840 | | |
2834 | 2841 | | |
2835 | 2842 | | |
| |||
0 commit comments