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

Update script to ensure pods are RUNNING #137

Merged
merged 1 commit into from
Aug 29, 2023
Merged
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
24 changes: 23 additions & 1 deletion kube/utils/backup_staging_production_to_ranch.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
#!/bin/bash
set -ex

#starting production-assets-util
Copy link
Contributor

Choose a reason for hiding this comment

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

Love the comments!

kubectl --context=wma-geospatial apply -f ~geoapi/util/production_assets_util.yaml
#starting staging-assets-util
kubectl --context=geoapi-dev apply -f ~geoapi/util/staging_assets_util.yaml

# Function to check if both pods are in the "Running" state
function are_pods_running() {
local pod1_status=$(kubectl --context=wma-geospatial get pods production-assets-util -o jsonpath='{.status.phase}')
local pod2_status=$(kubectl --context=geoapi-dev get pods staging-assets-util -o jsonpath='{.status.phase}')

if [[ "$pod1_status" == "Running" ]] && [[ "$pod2_status" == "Running" ]]; then
return 0 # Both pods are running
else
return 1 # At least one pod is not running
fi
}

# Wait for both pods to be ready
while ! are_pods_running; do
echo "Waiting 30s for utility pods to be ready..."
sleep 30
done

echo "Both utility pods are ready."

echo "Removing backups older than 6 weeks (i.e. 42 days) (STAGING)"
ssh [email protected] 'find /stornext/ranch_01/ranch/projects/DesignSafe-Community/geoapi_assets_backup/staging/ -mtime +42 -type f -exec rm {} +'

Expand All @@ -16,4 +38,4 @@ echo "Removing backups older than 6 weeks (i.e. 42 days) (PRODUCTION)"
ssh [email protected] 'find /stornext/ranch_01/ranch/projects/DesignSafe-Community/geoapi_assets_backup/production/ -mtime +42 -type f -exec rm {} +'

echo "Backing up production (skipping /assets/streetview as those are temp files)"
kubectl exec -i pod/production-assets-util --context=wma-geospatial -- tar --exclude /assets/streetview -c -f - /assets/ | ssh [email protected] 'split -b 300G - /stornext/ranch_01/ranch/projects/DesignSafe-Community/geoapi_assets_backup/production/production_assets`date +%Y-%m-%d`.tar.'
kubectl exec -i pod/production-assets-util --context=wma-geospatial -- tar --exclude /assets/streetview -c -f - /assets/ | ssh [email protected] 'split -b 300G - /stornext/ranch_01/ranch/projects/DesignSafe-Community/geoapi_assets_backup/production/production_assets`date +%Y-%m-%d`.tar.'
Loading