From 028757813282f764ebcce05572f9e4b76ea4e552 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Thu, 3 Oct 2019 17:39:37 +0530 Subject: [PATCH] ceph-volume: VolumeGroups.filter shouldn't purge itself VolumeGroups.filter remove VGs from the list that do no match filter. Instead of doing that, return a new list that contains VGs that match the fiter so that VolumeGroups object held by code calling it is not modified. Fixes: https://tracker.ceph.com/issues/42171 Signed-off-by: Rishabh Dave --- src/ceph-volume/ceph_volume/api/lvm.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py index c3d0922018601..f243627b2d2c9 100644 --- a/src/ceph-volume/ceph_volume/api/lvm.py +++ b/src/ceph-volume/ceph_volume/api/lvm.py @@ -764,15 +764,10 @@ class VolumeGroups(list): """ if not any([vg_name, vg_tags]): raise TypeError('.filter() requires vg_name or vg_tags (none given)') - # first find the filtered volumes with the values in self - filtered_groups = self._filter( - vg_name=vg_name, - vg_tags=vg_tags - ) - # then purge everything - self._purge() - # and add the filtered items - self.extend(filtered_groups) + + filtered_vgs = VolumeGroups(populate=False) + filtered_vgs.extend(self._filter(vg_name, vg_tags)) + return filtered_vgs def get(self, vg_name=None, vg_tags=None): """ -- 2.39.5