Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aspirational hack project) Auto-generate EFS usage report & Log storage #173

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions scripts/efs-cron-pod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: v1
kind: Pod
metadata:
name: inspect-pvc-pod
spec:
containers:
- name: inspect-pvc-container
image: busybox
command:
- /bin/sh
- -c
- |
#!/bin/sh
set -eux

# EFS_PERSIST_MNT is the mount point for the PVC
EFS_PERSIST_MNT="/mnt/efs-persist"
EFS_HOME="$EFS_PERSIST_MNT/home"

# Generate the size report
du -sh $EFS_HOME/* | awk '{print $1, $2}' > $EFS_HOME/size_report.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you do this way (storing into EFS itself), better to IMHO

Suggested change
du -sh $EFS_HOME/* | awk '{print $1, $2}' > $EFS_HOME/size_report.txt
cd "$EFS_HOME" && d8 -sh * | awk '{print $1, $2}' > size_report.txt

then you would avoid having some irrelevant path prefix there.


# Display the size report
cat "$EFS_HOME/size_report.txt"

# Keep the container running
sleep 3600
Comment on lines +26 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs cleanup

Suggested change
# Keep the container running
sleep 3600

volumeMounts:
- name: efs-storage
mountPath: /mnt/efs-persist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATM we are transferring 10TB but good amount of space is occupied by a few users, e.g. the largest (500G) is by one user having 1 single NWB file. We could/should quickly inspect and reach out asking if could be removed.

But ideally we need a simple script which may be prints N largest files per each user and sorts users by the total size or smth like that....

# cd /mnt/efs-persist/home; for u in *; do biggies=$(find $u -size +1000000 -print0 | xargs -0 -r ls -Sl | head -n 5 | tr '\n' '>'); [ -z "$biggies" ] || { du -sm $u; echo  "${biggies}" | tr '>' '\n'; }; done

but ran on the original efs

here is the pod definition we used for pod to mount target EFS

apiVersion: v1
kind: Pod
metadata:
  name: sleep-tender
spec:
  containers:
  - name: inspect-pvc-container
    image: busybox
    command:
        - /bin/sh
        - -c
        - ls -la /mnt/efs-persist; echo sleeping; sleep 3600; echo exiting
    volumeMounts:
    - name: efs-storage
      mountPath: /mnt/efs-persist
      readOnly: true
  volumes:
  - name: efs-storage
    persistentVolumeClaim:
      claimName: efs-persist

volumes:
- name: efs-storage
persistentVolumeClaim:
claimName: efs-persist

10 changes: 10 additions & 0 deletions scripts/efs-cron-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -eux

# EFS_PERSIST_MNT = "/mnt/efs-persist"
EFS_PERSIST_MNT="/tmp/efs-script-dump"
EFS_HOME="$EFS_PERSIST_MNT/home"

du -sh $EFS_HOME/* | awk '{print $1, $2}' > $EFS_HOME/size_report.txt
cat $EFS_HOME/size_report.txt