Skip to content

Commit

Permalink
Merge pull request #2560 from phillxnet/2395_Allow_delete_of_un-mount…
Browse files Browse the repository at this point in the history
…ed/un-mountable_pool

Allow delete of un-mounted/un-mountable pool #2395
  • Loading branch information
phillxnet authored May 29, 2023
2 parents 79ed934 + 90b9cb6 commit 8f06d99
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/rockstor/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ def umount_root(root_pool_mnt):
if ce.rc == 32:
for l in ce.err:
l = l.strip()
if re.search("not mounted$", l) is not None:
if re.search("not mounted\.$", l) is not None:
return
raise ce
for i in range(20):
Expand Down Expand Up @@ -1149,8 +1149,8 @@ def share_id(pool, share_name):

def remove_share(pool, share_name, pqgroup, force=False):
"""
umount share if its mounted.
unsures given pool is mounted.
umount share if it's mounted.
ensures given pool is mounted.
if force flag set then first delete all share's subvolumes.
btrfs subvolume delete root_mnt/vol_name.
destroy shares qgroup and associated pqgroup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@
</div>
<div class="modal-body">
<div class="messages"></div>
<h4>{{poolName}} will be deleted including it's Shares listed below and their Snapshots, NFS exports, Samba and SFTP config and Replicas. Are you sure?</h4>
<h4>Pool and all associated Shares, Snapshots, NFS/Samba/SFTP exports, and Replicas, will be deleted.</h4>
<div class="alert alert-danger">Are you sure? DATA WILL BE LOST!</div>
Rockstor managed Shares:
<ul>
{{#each share}}
<li>{{this.name}} ({{this.size_gb}} GB)</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@
</div>
<div class="modal-body">
<div class="messages"></div>
<h4>{{this.name}} will be deleted including it's Shares listed below and their Snapshots, NFS exports, Samba and SFTP config and Replics. Are you sure?</h4>
<h4>Pool and all associated Shares, Snapshots, NFS/Samba/SFTP exports, and Replicas, will be deleted.</h4>
<div class="alert alert-danger">Are you sure? DATA WILL BE LOST!</div>
Rockstor managed Shares:
<ul id="pool-shares"></ul>
</div>
<div class="modal-footer">
Expand Down
21 changes: 12 additions & 9 deletions src/rockstor/storageadmin/views/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,17 @@ def delete(self, request, pid, command=""):
).format(pool.name)
handle_exception(Exception(e_msg), request)

if Share.objects.filter(pool=pool).exists():
if not pool.is_mounted:
logger.info(
"Pool ({}) to be deleted is not mounted. "
"Proceeding with database removal only.".format(pool.name)
)
elif pool.redundancy_exceeded:
logger.info(
"Pool ({}) to be deleted has exceeded its redundancy limits. "
"Proceeding with database removal only.".format(pool.name)
)
elif Share.objects.filter(pool=pool).exists():
if not force:
e_msg = (
"Pool ({}) is not empty. Delete is not allowed "
Expand All @@ -785,14 +795,7 @@ def delete(self, request, pid, command=""):
pool_path = "{}{}".format(settings.MNT_PT, pool.name)
umount_root(pool_path)
pool.delete()
try:
# TODO: this call fails as the inheritance of disks was removed
# We need another method to invoke this as self no good now.
self._update_disk_state()
except Exception as e:
logger.error(
("Exception while updating disk state: ({}).").format(e.__str__())
)
# We may need to update disk state here.
return Response()


Expand Down

0 comments on commit 8f06d99

Please sign in to comment.