forked from raystack/optimus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add change namespace script (#165)
- Loading branch information
1 parent
923b765
commit 3bd0d94
Showing
1 changed file
with
57 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,57 @@ | ||
#!/bin/bash | ||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
YEL='\033[0;33m' | ||
NC='\033[0m' # No Color | ||
|
||
|
||
source_namespace="yash" | ||
destination_namespace="yash1" | ||
project_name="g-pilotdata-gl" | ||
host="localhost:9100" | ||
|
||
# list the jobs to be migrated | ||
jobs=("sample_select" | ||
"weekly_hello_test_2" | ||
"daily_hello_test_1") | ||
|
||
jobs_successfully_migrated=() | ||
jobs_failed_migration=() | ||
|
||
for value in "${jobs[@]}"; do | ||
echo "" | ||
echo -e "${YEL}> optimus job change-namespace ${NC}${GREEN}$value ${NC} ${YEL} -o=$source_namespace -n=$destination_namespace -p=$project_name --host=$host ${NC}" | ||
OPTIMUS_INSECURE=true ./optimus job change-namespace $value -o=$source_namespace -n=$destination_namespace -p=$project_name --host=$host | ||
if [ $? -ne 0 ]; then | ||
jobs_failed_migration+=($value) | ||
else | ||
jobs_successfully_migrated+=($value) | ||
fi | ||
done | ||
echo "" | ||
|
||
if [ ${#jobs_successfully_migrated[@]} -ne 0 ]; then | ||
echo -e "${GREEN}[OK] Successfully migrated jobs from namespace $source_namespace to $destination_namespace ${NC}" | ||
for job_name in "${jobs_successfully_migrated[@]}"; do | ||
echo -e "${GREEN} $job_name ${NC}" | ||
done | ||
fi | ||
echo "" | ||
echo "" | ||
|
||
if [ ${#jobs_failed_migration[@]} -ne 0 ]; then | ||
echo -e "${RED}[ERROR] failed migrating: ${NC}" | ||
for job_name in "${jobs_failed_migration[@]}"; do | ||
echo -e "${RED} $job_name ${NC}" | ||
done | ||
echo "" | ||
echo -e "${YEL}[INFO] Please consider migrating these jobs manually. ${NC}" | ||
echo "" | ||
echo -e "${YEL}[INFO] Reverting migration for jobs that failed migration. ${NC}" | ||
|
||
for job_name in "${jobs_failed_migration[@]}"; do | ||
echo "" | ||
echo -e "${YEL}> optimus job change-namespace ${NC}${GREEN}$value ${NC} ${YEL} -n=$source_namespace -o=$destination_namespace -p=$project_name --host=$host ${NC}" | ||
OPTIMUS_INSECURE=true ./optimus job change-namespace $value -n=$source_namespace -o=$destination_namespace -p=$project_name --host=$host | ||
done | ||
fi |