From 33f2a81ab1b6b035cbe1fd30c2e4cbbee824cf5b Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 14 Sep 2009 13:25:18 +0200
Subject: [PATCH] Treat virtual LVs as inexistent
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Currently, β€œgnt-cluster verify” and β€œgnt-cluster verify-disks” use the
list of LVs as returned by backend.GetVolumeList to determine whether an
LV exists or not. However, LVs can also be β€˜virtual’, which is handled
correctly (i.e. as missing) by the bdev code, but not by this function.

This patch changed GetVolumeList to simply skip virtual LVs; this makes
cluster verify and verify-disks report these correctly as missing. The
only downside is that an user could get confused (lvs reports the volume
as existing, but ganeti as missing). However, this is better than simply
considering virtual LVs as β€œgood”.

No other code beside these two gnt-cluster operations uses the
GetVolumeList function, so we don't change the behaviour of the rest of
the code (e.g. replace-disks, instance info, etc.).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/backend.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/backend.py b/lib/backend.py
index ca78055ed..b0d7c71ec 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -547,6 +547,11 @@ def GetVolumeList(vg_name):
     name, size, attr = match.groups()
     inactive = attr[4] == '-'
     online = attr[5] == 'o'
+    virtual = attr[0] == 'v'
+    if virtual:
+      # we don't want to report such volumes as existing, since they
+      # don't really hold data
+      continue
     lvs[name] = (size, inactive, online)
 
   return lvs
-- 
GitLab