devtools/deploy_worker.sh: only update traffic to latest if needed
Skip the update-traffic command if it isn't necessary.
Change-Id: Ic3dee8b82d73dccd919f839d6e039bb14eff9749
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/376994
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/devtools/deploy_worker.sh b/devtools/deploy_worker.sh
index a92c22d..7c02741 100755
--- a/devtools/deploy_worker.sh
+++ b/devtools/deploy_worker.sh
@@ -49,7 +49,11 @@
# If there was a rollback, `gcloud run deploy` will create a revision but
# not point traffic to it. The following command ensures that the new revision
# will get traffic.
- $prefix gcloud run services --project $project update-traffic $env-vuln-worker --to-latest
+ latestTraffic=$(gcloud run services --project $project describe $env-vuln-worker \
+ --format='value(status.traffic.latestRevision)')
+ if [[ $latestTraffic != True ]]; then
+ $prefix gcloud run services --project $project update-traffic $env-vuln-worker --to-latest
+ fi
}
main $@