From 41fd26a063a67c9956326b218fc307f8b9139af7 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Wed, 5 Dec 2018 17:29:59 -0800 Subject: [PATCH] Use ip route commands on Linux, as they show the subnet which may be required for deletion --- hack/jenkins/common.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/hack/jenkins/common.sh b/hack/jenkins/common.sh index fe156a3a5c..0f745d9d80 100755 --- a/hack/jenkins/common.sh +++ b/hack/jenkins/common.sh @@ -162,17 +162,19 @@ if pgrep kubectl; then fi function cleanup_stale_routes() { - stale_routes=$(netstat -rn -f inet | awk '{ print $1 }' | grep 10.96.0.0 || true) - if [[ "${stale_routes}" != "" ]]; then - echo "WARNING: deleting stale tunnel routes: ${stale_routes}" - for route in ${stale_routes}; do - if [[ "$(uname)" == "Linux" ]]; then - sudo ip route delete "${route}" || true - else - sudo route -n delete "${route}" || true - fi - done + local show="netstat -rn -f inet" + local del="sudo route -n delete" + + if [[ "$(uname)" == "Linux" ]]; then + show="ip route show" + del="sudo ip route delete" fi + + local troutes=$($show | awk '{ print $1 }' | grep 10.96.0.0 || true) + for route in ${troutes}; do + echo "WARNING: deleting stale tunnel route: ${route}" + $del "${route}" || true + done } cleanup_stale_routes || true