-
Notifications
You must be signed in to change notification settings - Fork 0
/
atlascluster_upgrade.sh
executable file
·50 lines (39 loc) · 1.22 KB
/
atlascluster_upgrade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
echo 'This script recreate AtlasCluster CRs using the patch files after MongoDB Atlas Operator for RHODA has been upgraded to the new rebased release.
You must have logged into the OpenShift cluster as a cluster administrator in order to proceed.'
read -p "Would you like to continue (y/n)?" answer
case ${answer:0:1} in
y|Y )
echo Yes
;;
* )
exit 1
;;
esac
for FILE in ./upgrade/*;
do
oc apply -f $FILE
done
echo "Checking the updated AtlasCluster CRs..."
fail="false"
oc get atlascluster --all-namespaces |sed 1d |
while IFS= read -r line;
do
NAMESPACE=$(echo $line |awk '{print $1}')
NAME=$(echo $line |awk '{print $2}')
SPEC=`oc get atlascluster $NAME -n $NAMESPACE -o=jsonpath='{.spec}'`
echo $SPEC
if [[ $SPEC == *"clusterSpec"* ]]; then
echo -e "\nAtlasCluster $NAME in namespace $NAMESPACE has been upgraded."
echo $SPEC
else # This should not happen
echo -e "\nAtlasCluster $NAME in namespace $NAMESPACE has not been upgraded!"
fail="true"
fi
done
if [[ $fail == "true" ]]
then
echo -e "AtlasCluster CR migration completed with errors."
else
echo -e "AtlasCluster CR migration completed successfully."
fi