From 1c94dd35df8f8142fffe5f57e1cf7d1e624374e5 Mon Sep 17 00:00:00 2001 From: Mads Hartmann Date: Wed, 4 May 2022 09:23:34 +0000 Subject: [PATCH] Improve process handling and show stdout/stderr --- ...tforward-monitoring-satellite-harvester.sh | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/dev/preview/util/portforward-monitoring-satellite-harvester.sh b/dev/preview/util/portforward-monitoring-satellite-harvester.sh index 6a8977aec9becb..38685bc3982b3e 100755 --- a/dev/preview/util/portforward-monitoring-satellite-harvester.sh +++ b/dev/preview/util/portforward-monitoring-satellite-harvester.sh @@ -13,17 +13,26 @@ fi NAMESPACE="preview-${VM_NAME}" -function log { - echo "[$(date)] $*" -} +echo " +Starting port-forwarding: -pkill -f "kubectl port-forward (.*)3000:3000" -kubectl port-forward --context=harvester -n "${NAMESPACE}" svc/proxy "3000:3000" > /dev/null 2>&1 & +Prometheus: +$(gp url 9090) + +Grafana: +$(gp url 3000) + +" +# This is just a bit of extra safety to ensure that no other port-forwards are running +# e.g. maybe you forgot you had it running in another terminal etc. +pkill -f "kubectl port-forward (.*)3000:3000" pkill -f "kubectl port-forward (.*)9090:9090" -kubectl port-forward --context=harvester -n "${NAMESPACE}" svc/proxy "9090:9090" > /dev/null 2>&1 & -log "Please follow the link to access Prometheus' UI: $(gp url 9090)" -log "Please follow the link to access Grafanas' UI: $(gp url 3000)" -echo "" -log "If they are not accessible, make sure to re-run the Werft job with the following annotation: 'with-vm=true'" +# We're using xargs here to run the commands in parallel. This has two benefits as xargs +# +# 1. Will show the stdout/stderr of both processes, making it easier to diagnose issues +# 2. Deals with process termination. If you ^C this script xargs will kill the underlying +#. processes. +# +echo "3000:3000 9090:9090" | xargs -n 1 -P 2 kubectl port-forward --context=harvester -n "${NAMESPACE}" svc/proxy