Skip to content

Commit

Permalink
wait ovn-central pods running before delete ovs-ovn pods (#1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Jun 20, 2022
1 parent f55e32b commit 75ece0e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions dist/images/kubectl-ko
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,23 @@ dbtool(){
# mv all db files
for pod in ${podNameArray[@]}
do
kubectl exec -it -n $KUBE_OVN_NS $pod -- mv /etc/ovn/ovnnb_db.db /tmp
kubectl exec -it -n $KUBE_OVN_NS $pod -- mv /etc/ovn/ovnsb_db.db /tmp
kubectl exec -it -n $KUBE_OVN_NS $pod -- mv -f /etc/ovn/ovnnb_db.db /tmp
kubectl exec -it -n $KUBE_OVN_NS $pod -- mv -f /etc/ovn/ovnsb_db.db /tmp
done

# restore db and replicas
echo "restore nb db file, operate in pod ${podNameArray[0]}"
kubectl exec -it -n $KUBE_OVN_NS ${podNameArray[0]} -- mv /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db
kubectl exec -it -n $KUBE_OVN_NS ${podNameArray[0]} -- mv -f /etc/ovn/ovnnb_db_standalone.db /etc/ovn/ovnnb_db.db
kubectl scale deployment -n $KUBE_OVN_NS ovn-central --replicas=$replicas

# wait ovn-central pods running
availabelNum=$(kubectl get deployment -n $KUBE_OVN_NS | grep ovn-central | awk {'print $4'})
while [ $availabelNum != $replicas ]
do
availabelNum=$(kubectl get deployment -n $KUBE_OVN_NS | grep ovn-central | awk {'print $4'})
echo "wait all ovn-central pods running, availabel $availabelNum"
sleep 1
done
echo "finish restore nb db file and ovn-central replicas"

echo "recreate ovs-ovn pods"
Expand Down

0 comments on commit 75ece0e

Please sign in to comment.