Skip to content

Commit fcb280a

Browse files
vmagrofacebook-github-bot
authored andcommitted
[devserver][clean_disk] make antlir2-out cleaner more resilient
Summary: The top level `antlir2-out` dir has not held subvolumes since D76380320. But there might still be devservers that have subvols in the old location. This just cleans up this script to handle Test Plan: Created a convoluted setup with subvols in both `antlir2-out/` and `antlir2-out/subvols`, including nested subvolumes in read-only parents. This new script still cleaned it up. ``` [email protected] in fbsource/antlir2-out ❯ btrfs subvolume create foo Create subvolume './foo' [email protected] in fbsource/antlir2-out ❯ btrfs subvolume create subvols/bar Create subvolume 'subvols/bar' [email protected] in fbsource/antlir2-out ❯ btrfs subvolume create subvols/bar/baz Create subvolume 'subvols/bar/baz' [email protected] in fbsource/antlir2-out ❯ sudo btrfs property set subvols/bar ro true [email protected] in fbsource/antlir2-out ❯ tree . ├── foo └── subvols └── bar └── baz 4 directories, 0 files [email protected] in fbsource/antlir2-out ❯ ~fbcode/antlir/clean-antlir2-out.sh + '[' '!' -d antlir2-out ']' + '[' '!' -d antlir2-out ']' + pushd antlir2-out /data/users/vmagro/fbsource/antlir2-out /data/users/vmagro/fbsource + find . -maxdepth 2 -depth -type d -inum 256 -exec sudo btrfs property set '{}' ro false ';' + sudo find . -depth -type d -inum 256 -exec btrfs subvolume delete '{}' ';' Delete subvolume 3169 (no-commit): '/data/users/vmagro/fbsource/antlir2-out/subvols/bar/baz' Delete subvolume 3168 (no-commit): '/data/users/vmagro/fbsource/antlir2-out/subvols/bar' Delete subvolume 3167 (no-commit): '/data/users/vmagro/fbsource/antlir2-out/foo' [email protected] in fbsource/antlir2-out ❯ tree . └── subvols 1 directory, 0 files ``` Rollback Plan: Reviewed By: sergeyfd Differential Revision: D81242825 fbshipit-source-id: abf6737aa74418c8339a08f526941ad6d4b0c536
1 parent c11f0d9 commit fcb280a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

antlir/clean-antlir2-out.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set -ex
8+
9+
if [ ! -d "antlir2-out" ]; then
10+
cd "$(hg root)"
11+
fi
12+
13+
if [ ! -d "antlir2-out" ]; then
14+
echo "no antlir2-out found in repo root, exiting..."
15+
exit
16+
fi
17+
18+
pushd "antlir2-out"
19+
20+
# all top-level subvolumes must be made read-write in case any nested
21+
# subvolume needs to be deleted (the compiler will now loudly fail if these are
22+
# found, but we still want to clean them up)
23+
# subvolumes may be found in either antlir2-out (old style) or
24+
# antlir2-out/subvols (new style) hence the -maxdepth 2
25+
find . -maxdepth 2 -depth -type d -inum 256 -exec sudo btrfs property set {} ro false \;
26+
27+
# delete any nested subvolumes (sudo because we might not have permissions to
28+
# read the directories that they're found in)
29+
sudo find . -depth -type d -inum 256 -exec btrfs subvolume delete {} \;

0 commit comments

Comments
 (0)