Skip to content

Commit

Permalink
Add docker resources underlying toolkit container image
Browse files Browse the repository at this point in the history
  • Loading branch information
dystewart committed Jan 23, 2024
1 parent 1461ebd commit d2bbdac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM quay.io/operate-first/opf-toolbox:v0.8.0
RUN dnf -y update
RUN dnf -y install jq
WORKDIR /shell-scripts
COPY src/* /shell-scripts
CMD ["/bin/sh"]
24 changes: 24 additions & 0 deletions docker/src/ope-notebook-culler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

echo "Running ope-notebook-culler.sh..."

#threshold to stop running notebooks. Currently set to 24 hours
cutoff_time=86400
current_time=$(date +%s)
notebooks=$(oc get notebooks -n ope-rhods-testing-1fef2f -o jsonpath='{range .items[?(@.status.containerState.running)]}{.metadata.name}{" "}{.metadata.namespace}{" "}{.status.containerState.running.startedAt}{"\n"}{end}')
if [ -z "$notebooks" ]; then
echo "No running notebooks found"
exit 0
fi

# Loop through each notebook
while read -r nb ns ts; do
timestamp=$(date -d $ts +%s)
difference=$((current_time - timestamp))
if [ $difference -gt $cutoff_time ]; then
echo "$nb is more than 24 hours old, stopping the notebook"
oc patch notebook $nb -n $ns --type merge -p '{"metadata":{"annotations":{"kubeflow-resource-stopped":"'$(date -u +"%Y-%m-%dT%H:%M:%SZ")'"}}}'
fi
done <<< "$notebooks"

echo "ope-notebook-culler.sh run complete."

0 comments on commit d2bbdac

Please sign in to comment.