Skip to content

Commit ff26d60

Browse files
committed
Update properties for started stratis pools during populate
We can't get all information (like whether overprovisioning is enabled) for locked pools. So when the pool is unlocked and populate() is run we need to update some of the properties.
1 parent c190dfd commit ff26d60

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

blivet/populator/helpers/stratis.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ def _unlock_locked_pool(self, pool):
166166

167167
return False
168168

169+
def _update_pool_info(self, pool):
170+
pool_info = stratis_info.pools.get(pool.uuid)
171+
if not pool_info:
172+
log.warning("Failed to get information about Stratis pool %s (%s)",
173+
pool.name, pool.uuid)
174+
return
175+
176+
pool._overprovisioning = pool_info.overprovisioning
177+
pool._fs_limit = pool_info.fs_limit
178+
169179
def _add_pool_device(self):
170180
bd_info = stratis_info.blockdevs.get(self.device.format.uuid)
171181
if not bd_info:
@@ -194,10 +204,14 @@ def _add_pool_device(self):
194204
return
195205

196206
pool_device = self._devicetree.get_device_by_uuid(bd_info.pool_uuid)
197-
if pool_device and self.device not in pool_device.parents:
198-
pool_device.parents.append(self.device)
199-
callbacks.parent_added(device=pool_device, parent=self.device)
200-
return
207+
if pool_device:
208+
# update pool information for newly started pools
209+
self._update_pool_info(pool_device)
210+
211+
if self.device not in pool_device.parents:
212+
pool_device.parents.append(self.device)
213+
callbacks.parent_added(device=pool_device, parent=self.device)
214+
return
201215
elif pool_device is None:
202216
# started pool
203217
pool_info = stratis_info.pools.get(bd_info.pool_uuid)

tests/storage_tests/devices_test/stratis_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ def test_stratis_pool_start_stop_encrypted(self):
375375
blivet.partitioning.do_partitioning(self.storage)
376376

377377
pool = self.storage.new_stratis_pool(name="blivetTestPool", parents=[bd],
378-
encrypted=True, passphrase="fipsneeds8chars")
378+
encrypted=True, passphrase="fipsneeds8chars",
379+
overprovisioning=True)
379380
self.storage.create_device(pool)
380381

381382
fs = self.storage.new_stratis_filesystem(name="blivetTestFS", parents=[pool],
@@ -414,9 +415,10 @@ def test_stratis_pool_start_stop_encrypted(self):
414415
pool.setup()
415416
self.assertTrue(pool.status)
416417

417-
# populate should add the filesystems to the devicetree
418+
# populate should add the filesystems to the devicetree and update pool properties
418419
self.storage.devicetree.populate()
419420
self.assertEqual(len(pool.children), 1)
421+
self.assertTrue(pool.overprovisioning)
420422

421423
fs = self.storage.devicetree.get_device_by_name("blivetTestPool/blivetTestFS")
422424
self.assertIsNotNone(fs)

0 commit comments

Comments
 (0)