From 2bce5080f355eaa2dbd5ea1fdc43eaad4c993f2d Mon Sep 17 00:00:00 2001 From: jeffy Date: Fri, 10 Mar 2023 15:59:31 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=EF=BC=9APrevents=20grep=20from=20prematur?= =?UTF-8?q?ely=20exiting=20the=20shell=20script=20if=20it=20cannot=20find?= =?UTF-8?q?=20a=20pattern=20(#2466)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yl4811 --- dist/images/update/1.10-1.11.2.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/dist/images/update/1.10-1.11.2.sh b/dist/images/update/1.10-1.11.2.sh index e9288c36254..be59a6188f5 100644 --- a/dist/images/update/1.10-1.11.2.sh +++ b/dist/images/update/1.10-1.11.2.sh @@ -4,31 +4,30 @@ 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 @@ -36,19 +35,21 @@ for snat in $all_snat;do 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!" \ No newline at end of file