Skip to content

Commit

Permalink
Update cephfs-mds-shard.py
Browse files Browse the repository at this point in the history
add override feature to repin pinned directories
  • Loading branch information
Hutch-45D committed Apr 29, 2024
1 parent 45109be commit 4fd9eae
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cephfs-mds-shard.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# Mitch Hall
# Edit Matthew Hutchinson
# 45Drives
# Version 1.1 - July 31/23
# Version 1.2 - April 29/24
import os
import json
import time
Expand All @@ -13,6 +14,7 @@ def main():
parser = argparse.ArgumentParser(description='Shard directories and pin each to a different MDS.')
parser.add_argument('-d', '--dir', help='The top-level directory to shard.')
parser.add_argument('-D', '--dry-run', action='store_true', help='Run the script in dry run mode. No actions will be performed.')
parser.add_argument('-F', '--force', action='store_true', help='Ignore existing pins')
args = parser.parse_args()

if args.dir:
Expand All @@ -38,7 +40,7 @@ def main():

if "ceph.dir.pin" in pinned_mds:
current_mds = re.search('ceph.dir.pin="(.*)"', pinned_mds).group(1)
if current_mds != "-1":
if current_mds != "-1" and not args.force :
print(f"{dir} is already pinned by MDS {current_mds}")
else:
if args.dry_run:
Expand All @@ -65,4 +67,3 @@ def main():

if __name__ == "__main__":
main()

0 comments on commit 4fd9eae

Please sign in to comment.