Skip to content

Commit f67bd89

Browse files
authored
fix(linstor): ignore unknown res to get volume info (#122)
Avoid issuing errors if the size of a volume cannot be fetched after a bad delete call. Signed-off-by: Ronan Abhamon <ronan.abhamon@vates.tech>
1 parent c86171c commit f67bd89

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/linstorvolumemanager.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,8 @@ def get_volumes_with_info(self):
11841184

11851185
volumes = {}
11861186

1187-
all_volume_info = self._get_volumes_info()
11881187
volume_names = self.get_volumes_with_name()
1188+
all_volume_info = self._get_volumes_info(volume_names)
11891189
for volume_uuid, volume_name in volume_names.items():
11901190
if volume_name:
11911191
volume_info = all_volume_info.get(volume_name)
@@ -2107,12 +2107,18 @@ def _fetch_resource_names(self, ignore_deleted=True):
21072107
resource_names.add(dfn.name)
21082108
return resource_names
21092109

2110-
def _get_volumes_info(self, volume_name=None):
2110+
def _get_volumes_info(self, volume_names=None):
21112111
all_volume_info = {}
21122112

21132113
if not self._volume_info_cache_dirty:
21142114
return self._volume_info_cache
21152115

2116+
# `volume_names` MUST contain all volumes registered in the KV store.
2117+
# It can be provided to the function to avoid double fetching.
2118+
if not volume_names:
2119+
volume_names = self.get_volumes_with_name()
2120+
volume_names = set(volume_names.values())
2121+
21162122
def process_resource(resource):
21172123
if resource.name not in all_volume_info:
21182124
current = all_volume_info[resource.name] = self.VolumeInfo(
@@ -2145,7 +2151,8 @@ def process_resource(resource):
21452151

21462152
try:
21472153
for resource in self._get_resource_cache().resources:
2148-
process_resource(resource)
2154+
if resource.name in volume_names:
2155+
process_resource(resource)
21492156
for volume in all_volume_info.values():
21502157
if volume.allocated_size <= 0:
21512158
raise LinstorVolumeManagerError('Failed to get allocated size of `{}`'.format(resource.name))

0 commit comments

Comments
 (0)