diff --git a/src/middlewared/middlewared/plugins/pool_/replace_disk.py b/src/middlewared/middlewared/plugins/pool_/replace_disk.py index 60d619693ca70..c9f440dd937ec 100644 --- a/src/middlewared/middlewared/plugins/pool_/replace_disk.py +++ b/src/middlewared/middlewared/plugins/pool_/replace_disk.py @@ -73,6 +73,7 @@ async def replace(self, job, oid, options): min_size = min(min_size, size) swap_disks = [disk['devname']] + from_disk = None if found[1] and await self.middleware.run_in_thread(os.path.exists, found[1]['path']): if from_disk := await self.middleware.call('disk.label_to_disk', found[1]['path'].replace('/dev/', '')): # If the disk we are replacing is still available, remove it from swap as well @@ -93,6 +94,11 @@ async def replace(self, job, oid, options): job.set_progress(30, 'Replacing disk') new_devname = vdev[0].replace('/dev/', '') await self.middleware.call('zfs.pool.replace', pool['name'], options['label'], new_devname) + except Exception: + raise + else: + if from_disk: + await self.middleware.call('disk.wipe', from_disk, 'QUICK') finally: # Needs to happen even if replace failed to put back disk that had been # removed from swap prior to replacement