-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker resources underlying toolkit container image
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |