Skip to content

Commit

Permalink
Wipe disk which is getting replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
Qubad786 committed Apr 19, 2023
1 parent f0e51da commit 026691d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/middlewared/middlewared/plugins/pool_/replace_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 026691d

Please sign in to comment.