Skip to content

Commit

Permalink
DocumentMigration entrypoint - Stop looping if we're eating up more d…
Browse files Browse the repository at this point in the history
…isk space.

Signed-off-by: Greg Schohn <[email protected]>
  • Loading branch information
gregschohn committed Oct 4, 2024
1 parent 69f3844 commit 63216c5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion DocumentsFromSnapshotMigration/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ if [[ $RFS_COMMAND != *"--target-password"* ]]; then
fi
fi

# Monitor how much aggregate free space is left, if we drop below a certain amount,
# don't allow another process to run again
space_drop_fraction=4
initial_free_space=$(df --output=avail | awk 'NR>1 {sum+=$1} END {print sum}')
still_enough_space_left() {
current_free=$(df --output=avail | awk 'NR>1 {sum+=$1} END {print sum}')
if (((initial_free_space - current_free) >= (initial_free_space / $space_drop_fraction))); then
return 1;
else
return 0;
fi
}


[ -z "$RFS_COMMAND" ] && \
{ echo "Warning: RFS_COMMAND is empty! Exiting."; exit 1; } || \
until ! { echo "Running command $RFS_COMMAND"; eval "$RFS_COMMAND"; }; do :; done
until ! { echo "Running command $RFS_COMMAND"; eval "$RFS_COMMAND" && still_enough_space_left; }; do :; done

0 comments on commit 63216c5

Please sign in to comment.