Skip to content

Commit

Permalink
Merge pull request ceph#8786 from tchaikov/wip-btrfs-sudo
Browse files Browse the repository at this point in the history
test: sudo to rm btrfs subvol

Reviewed-by: Erwan Velu <[email protected]>
  • Loading branch information
tchaikov committed May 9, 2016
2 parents 367bd0a + a5b2658 commit f7331fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
13 changes: 4 additions & 9 deletions qa/workunits/ceph-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,10 @@ function teardown() {

function __teardown_btrfs() {
local btrfs_base_dir=$1

btrfs_dirs=`ls -l $btrfs_base_dir | egrep '^d' | awk '{print $9}'`
current_path=`pwd`
# extracting the current existing subvolumes
for subvolume in $(cd $btrfs_base_dir; btrfs subvolume list . -t |egrep '^[0-9]' | awk '{print $4}' |grep "$btrfs_base_dir/$btrfs_dir"); do
# Compute the relative path by removing the local path
# Like "erwan/chroot/ceph/src/testdir/test-7202/dev/osd1/snap_439" while we want "testdir/test-7202/dev/osd1/snap_439"
local_subvolume=$(echo $subvolume | sed -e "s|.*$current_path/||"g)
btrfs subvolume delete $local_subvolume
local btrfs_root=$(df -P . | tail -1 | awk '{print $NF}')
local btrfs_dirs=$(cd $btrfs_base_dir; sudo btrfs subvolume list . -t | awk '/^[0-9]/ {print $4}' | grep "$btrfs_base_dir/$btrfs_dir")
for subvolume in $btrfs_dirs; do
sudo btrfs subvolume delete $btrfs_root/$subvolume
done
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/ceph_objectstore_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1897,14 +1897,14 @@ def remove_btrfs_subvolumes(path):
result = subprocess.Popen("stat -f -c '%%T' %s" % path, shell=True, stdout=subprocess.PIPE)
filesystem = result.stdout.readlines()[0]
if filesystem.rstrip('\n') == "btrfs":
result = subprocess.Popen("btrfs subvolume list %s" % path, shell=True, stdout=subprocess.PIPE)
result = subprocess.Popen("sudo btrfs subvolume list %s" % path, shell=True, stdout=subprocess.PIPE)
for line in result.stdout.readlines():
subvolume=line.split()[8]
# extracting the relative volume name
m = re.search(".*(%s.*)" % path, subvolume)
if m:
found = m.group(1)
call("btrfs subvolume delete %s" % found, shell=True)
call("sudo btrfs subvolume delete %s" % found, shell=True)


if __name__ == "__main__":
Expand Down

0 comments on commit f7331fd

Please sign in to comment.