Skip to content

Commit

Permalink
Set up "cron" testing job in staging (datacommonsorg#4769)
Browse files Browse the repository at this point in the history
* This is a cron testing job, but it will never run automatically.
Instead it can be manually run as part of the release process.
* Also, add a comment on the dev schedule string.
  • Loading branch information
hqpho authored Dec 4, 2024
1 parent 5545946 commit 3bfa00a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deploy/helm_charts/envs/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ cronTesting:
enabled: true
screenshotDomain: "dev.datacommons.org"
nodePool: "default-pool"
schedule: "* * 31 2 *"
schedule: "* * 31 2 *" # invalid day for month -> never run automatically
6 changes: 6 additions & 0 deletions deploy/helm_charts/envs/staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ serviceGroups:

svg:
blocklistFile: ["dc/g/Uncategorized", "oecd/g/OECD"]

cronTesting:
enabled: true
screenshotDomain: "staging.datacommons.org"
nodePool: "default-pool"
schedule: "* * 31 2 *" # invalid day for month -> never run automatically
12 changes: 9 additions & 3 deletions tools/delete_cron_outputs/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ set -e

# Delete GCS folders that are older than this many days
MAX_DAYS_OLD=90
PARENT_FOLDERS=("gs://datcom-website-periodic-testing/bard" "gs://datcom-website-periodic-testing/autopush" "gs://datcom-website-screenshot/autopush.datacommons.org/")
PARENT_FOLDERS=(
"gs://datcom-website-periodic-testing/bard"
"gs://datcom-website-periodic-testing/autopush"
"gs://datcom-website-screenshot/autopush.datacommons.org/"
"gs://datcom-website-periodic-testing/staging"
"gs://datcom-website-screenshot/staging.datacommons.org/"
)
CURRENT_TS=$(TZ="America/Los_Angeles" date +"%s")

for parent_folder in "${PARENT_FOLDERS[@]}"; do
Expand All @@ -29,10 +35,10 @@ for parent_folder in "${PARENT_FOLDERS[@]}"; do
folder_timestamp=$(date -j -f "%Y_%m_%d_%H_%M_%S" "$folder_name" +"%s")
# get the difference in days between current timestamp and folder timestamp
timestamp_difference=$((CURRENT_TS - folder_timestamp))
days_difference=$(( timestamp_difference / (60*60*24) ))
days_difference=$((timestamp_difference / (60 * 60 * 24)))
# delete the folder if its older than MAX_DAYS_OLD
if [[ "$days_difference" -gt "$MAX_DAYS_OLD" ]]; then
gsutil rm -r $folder
gsutil -m rm -r $folder
echo "deleted $folder"
fi
done
Expand Down

0 comments on commit 3bfa00a

Please sign in to comment.