Nir Soffer has uploaded a new change for review.

Change subject: guest-lvs: Skip foreign vgs during bootstrap
......................................................................

guest-lvs: Skip foreign vgs during bootstrap

Previously we tried to deactivate any lv in any vg backed by multipath
device. This may clash with non-ovirt vgs created on a multipath device.

We use now the STORAGE_DOMAIN_TAG to detect oVirt vgs and ignore other
vgs during bootstrap.

Change-Id: I8f072a05026cec8b9d027b52d0adf2e236089706
Bug-Url: https://bugzilla.redhat.com/1374545
Signed-off-by: Nir Soffer <[email protected]>
---
M tests/storage_lvm_test.py
M vdsm/storage/hsm.py
M vdsm/storage/lvm.py
3 files changed, 25 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/64370/1

diff --git a/tests/storage_lvm_test.py b/tests/storage_lvm_test.py
index d4a1952..98f5b7e 100644
--- a/tests/storage_lvm_test.py
+++ b/tests/storage_lvm_test.py
@@ -67,13 +67,28 @@
             run("lvcreate", "-n", "ovirt-lv-1", "-L", "128m", "ovirt-vg")
             run("lvcreate", "-n", "ovirt-lv-2", "-L", "128m", "ovirt-vg")
             try:
-                lvm.bootstrap()
+                lvm.bootstrap(blockSD.STORAGE_DOMAIN_TAG)
                 # ovirt-lv must be inactive
                 self.assertEqual(self.find_active_lvs("ovirt-vg"), [])
             finally:
                 run("vgchange", "-an", "ovirt-vg")
 
-    # TODO: do not modify vgs without STORAGE_DOMAIN_TAG
+    @ValidateRunningAsRoot
+    def test_skip_foreign_vgs(self):
+        with fake_env() as env:
+            log.debug("Creating ovirt lvs")
+            run("pvcreate", "-ff", env.device)
+            # This is not ovirt-vg - no STORAGE_DOMAIN_TAG
+            run("vgcreate", "foreign-vg", env.device)
+            run("lvcreate", "-n", "foreign-lv-1", "-L", "128m", "foreign-vg")
+            run("lvcreate", "-n", "foreign-lv-2", "-L", "128m", "foreign-vg")
+            try:
+                lvm.bootstrap(blockSD.STORAGE_DOMAIN_TAG)
+                # foreign lvs should not be modified
+                self.assertEqual(self.find_active_lvs("foreign-vg"),
+                                 ["foreign-lv-1", "foreign-lv-2"])
+            finally:
+                run("vgchange", "-an", "foreign-vg")
 
     @ValidateRunningAsRoot
     def test_deactivate_unused_ovirt_lv_with_guest_lvs(self):
@@ -94,7 +109,7 @@
                 run("lvcreate", "--config", config, "-n", "guest-lv-2",
                     "-L", "128m", "guest-vg")
                 try:
-                    lvm.bootstrap()
+                    lvm.bootstrap(blockSD.STORAGE_DOMAIN_TAG)
                     # ovirt-lv must be inactive
                     self.assertEqual(self.find_active_lvs("ovirt-vg"), [])
                 except AssertionError:
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index d1b50d2..38d8d14 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -372,7 +372,8 @@
 
         def storageRefresh():
             sdCache.refreshStorage()
-            lvm.bootstrap(refreshlvs=blockSD.SPECIAL_LVS)
+            lvm.bootstrap(blockSD.STORAGE_DOMAIN_TAG,
+                          refreshlvs=blockSD.SPECIAL_LVS)
             self._ready = True
             self.log.debug("HSM is ready")
 
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index eadf11d..5e0ce2a 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -638,7 +638,7 @@
 _lvminfo = LVMCache()
 
 
-def bootstrap(refreshlvs=()):
+def bootstrap(vg_tag, refreshlvs=()):
     """
     Bootstrap lvm module
 
@@ -650,6 +650,10 @@
     refreshlvs = set(refreshlvs)
 
     for vg in _lvminfo.getAllVgs():
+        if vg_tag not in vg.tags:
+            log.info("Skipping foreign vg %s", vg.name)
+            continue
+
         deactivate = []
         refresh = []
 


-- 
To view, visit https://gerrit.ovirt.org/64370
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f072a05026cec8b9d027b52d0adf2e236089706
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to