Skip to content

Commit

Permalink
Fixed:Prevents grep from prematurely exiting the shell script if it c…
Browse files Browse the repository at this point in the history
…annot find a pattern (#2466)

Co-authored-by: yl4811 <yl4811@yealink.com>
  • Loading branch information
ShaPoHun and yl4811 committed Mar 10, 2023
1 parent 4d850e0 commit 2bce508
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions dist/images/update/1.10-1.11.2.sh
Expand Up @@ -4,51 +4,52 @@ set -eo pipefail
echo "begin upgrade iptables-dnat-rules"
all_dnat=$(kubectl get dnat -o name)
for dnat in $all_dnat;do
nat_anno=$(kubectl get $dnat -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip")
nat_anno=$(kubectl get $dnat -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip") || true
if [ -n "$nat_anno" ];then
continue
fi
eip=$(kubectl get $dnat -o jsonpath='{.spec.eip}')
kubectl annotate $dnat ovn.kubernetes.io/vpc_eip=$eip
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat")
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat") || true
if [ -n "$eip_anno" ];then
continue
fi
echo "annotate $eip ovn.kubernetes.io/vpc_nat"
nat_name=$(kubectl get $dnat -o jsonpath='{.metadata.name}')
kubectl annotate eip $eip ovn.kubernetes.io/vpc_nat=$nat_name
done

echo "begin annotate iptables-snat-rules.kubeovn.io"
echo "begin upgrade iptables-snat-rules.kubeovn.io"
all_snat=$(kubectl get snat -o name)
for snat in $all_snat;do
nat_anno=$(kubectl get $snat -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip")
nat_anno=$(kubectl get $snat -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip") || true
if [ -n "$nat_anno" ];then
continue
fi
eip=$(kubectl get $snat -o jsonpath='{.spec.eip}')
kubectl annotate $snat ovn.kubernetes.io/vpc_eip=$eip
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat")
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat") || true
if [ -n "$eip_anno" ];then
continue
fi
nat_name=$(kubectl get $snat -o jsonpath='{.metadata.name}')
kubectl annotate eip $eip ovn.kubernetes.io/vpc_nat=$nat_name
done

echo "begin annotate iptables-fip-rules.kubeovn.io"
echo "begin upgrade iptables-fip-rules.kubeovn.io"
all_fip=$(kubectl get fip -o name)
for fip in $all_fip;do
nat_anno=$(kubectl get $fip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip")
nat_anno=$(kubectl get $fip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_eip") || true
if [ -n "$nat_anno" ];then
continue
fi
eip=$(kubectl get $fip -o jsonpath='{.spec.eip}')
kubectl annotate $fip ovn.kubernetes.io/vpc_eip=$eip
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat")
eip_anno=$(kubectl get eip $eip -o jsonpath='{.metadata.annotations}'|grep "ovn.kubernetes.io/vpc_nat") || true
if [ -n "$eip_anno" ];then
continue
fi
nat_name=$(kubectl get $snat -o jsonpath='{.metadata.name}')
nat_name=$(kubectl get $fip -o jsonpath='{.metadata.name}')
kubectl annotate eip $eip ovn.kubernetes.io/vpc_nat=$nat_name
done

echo "upgrade iptables success!"

0 comments on commit 2bce508

Please sign in to comment.