Skip to content

Commit

Permalink
Support excluding certain directories from quota
Browse files Browse the repository at this point in the history
We have _shared and _shared-public directories that should have
a different quota setup. While we wait for implementation of
a tiered quota config system, this simply allows us to exclude them
from being quota'd
  • Loading branch information
yuvipanda committed Dec 12, 2024
1 parent cbaaa24 commit 875860d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions get-quota-your-home/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_quotas():
return quotas


def reconcile_projfiles(paths, projects_file_path, projid_file_path, min_projid):
def reconcile_projfiles(paths, projects_file_path, projid_file_path, min_projid, exclude_dirs):
"""
Make sure each homedir in paths has an appropriate projid entry.
Expand All @@ -101,9 +101,12 @@ def reconcile_projfiles(paths, projects_file_path, projid_file_path, min_projid)
"""
# Fetch existing home directories
# Sort to provide consistent ordering across runs
homedirs = sorted(
[ent.path for path in paths for ent in os.scandir(path) if ent.is_dir()]
)
homedirs = []
for path in paths:
for ent in os.scandir(path):
if ent.name not in exclude_dirs and ent.is_dir():
homedirs.append(ent.path)

print(homedirs)

# Fetch list of projects in /etc/projid file, assumed to sync'd to /etc/projects file
Expand Down Expand Up @@ -218,6 +221,11 @@ def main():
type=float,
help="Hard quota limit (in GB) to set for all home directories",
)
argparser.add_argument(
"--exclude",
action='append',
help='List of directory names to exclude setting quotas on'
)
args = argparser.parse_args()

# xfs_quota reports in kb
Expand All @@ -227,7 +235,7 @@ def main():

while True:
reconcile_projfiles(
args.paths, args.projects_file, args.projid_file, args.min_projid
args.paths, args.projects_file, args.projid_file, args.min_projid, args.exclude
)
reconcile_quotas(args.projid_file, hard_quota_kb)
time.sleep(args.wait_time)
Expand Down

0 comments on commit 875860d

Please sign in to comment.