Nir Soffer has posted comments on this change.
Change subject: fcp: Deactivate vdsm logical volumes ......................................................................
Patch Set 17:
(4 comments)
.................................................... File lib/vdsm/tool/lvm_deactivate_lvs.py Line 36: """ Line 37: if _was_run(): Line 38: _log("already run") Line 39: return 0 Line 40: _set_was_run() We want to avoid a situation where deactivation fails, we do net set the was run flag, then deactivation fails again on the next run... and so on. Line 41: for vg in _iter_vdsm_vgs(): Line 42: _deactivate_lvs(vg) Line 43: _log("deactivated lvs") Line 44: return 0
Line 56: def _log(msg): Line 57: sys.stderr.write("%s\n" % (msg,)) Line 58: Line 59: Line 60: def _iter_vdsm_vgs(): This will work only if run before sanlock opens the ids lv. When running normally, ids lv is always open and vgchange will always fail. Do you know when sanlock is opening the ids lv? Line 61: rc, out, err = _run_lvm(["vgs", "--noheading", "--separator", Line 62: _SEPARATOR, "-o", "name,tags"]) Line 63: if rc != 0: Line 64: raise RuntimeError("Error finding vgs: %s" % err)
Line 70: Line 71: Line 72: def _iter_active_lvs(vg): Line 73: rc, out, err = _run_lvm(["lvs", "--noheading", "--separator", Line 74: _SEPARATOR, "-o", "name,attr", vg]) Ayal thinks that we should remove the FCP check, and handle any lv active when it should not. I added check because we have a problem with FC lvs, and I did not want to change stuff which is not broken. Line 75: if rc != 0: Line 76: raise RuntimeError("Error finding lvs: %s" % err) Line 77: for line in out.splitlines(): Line 78: line = line.strip()
Line 103: def _deactivate_lvs(vg): Line 104: cmd = ["vgchange", "--available", "n", vg] Line 105: rc, out, err = _run_lvm(cmd) Line 106: if rc != 0: Line 107: # Probbaly there are open lvs. lvm does not gives us any way to detect Done Line 108: # error type. Line 109: cmd = ["lvchange", "--available", "n"] Line 110: cmd.extend("%s/%s" % (vg, lv) for lv in _iter_active_lvs(vg)) Line 111: rc, out, err = _run_lvm(cmd)