Skip to content

Commit 1c94dd3

Browse files
committed
Improve process handling and show stdout/stderr
1 parent 982252a commit 1c94dd3

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

dev/preview/util/portforward-monitoring-satellite-harvester.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,26 @@ fi
1313

1414
NAMESPACE="preview-${VM_NAME}"
1515

16-
function log {
17-
echo "[$(date)] $*"
18-
}
16+
echo "
17+
Starting port-forwarding:
1918
20-
pkill -f "kubectl port-forward (.*)3000:3000"
21-
kubectl port-forward --context=harvester -n "${NAMESPACE}" svc/proxy "3000:3000" > /dev/null 2>&1 &
19+
Prometheus:
20+
$(gp url 9090)
21+
22+
Grafana:
23+
$(gp url 3000)
24+
25+
"
2226

27+
# This is just a bit of extra safety to ensure that no other port-forwards are running
28+
# e.g. maybe you forgot you had it running in another terminal etc.
29+
pkill -f "kubectl port-forward (.*)3000:3000"
2330
pkill -f "kubectl port-forward (.*)9090:9090"
24-
kubectl port-forward --context=harvester -n "${NAMESPACE}" svc/proxy "9090:9090" > /dev/null 2>&1 &
2531

26-
log "Please follow the link to access Prometheus' UI: $(gp url 9090)"
27-
log "Please follow the link to access Grafanas' UI: $(gp url 3000)"
28-
echo ""
29-
log "If they are not accessible, make sure to re-run the Werft job with the following annotation: 'with-vm=true'"
32+
# We're using xargs here to run the commands in parallel. This has two benefits as xargs
33+
#
34+
# 1. Will show the stdout/stderr of both processes, making it easier to diagnose issues
35+
# 2. Deals with process termination. If you ^C this script xargs will kill the underlying
36+
#. processes.
37+
#
38+
echo "3000:3000 9090:9090" | xargs -n 1 -P 2 kubectl port-forward --context=harvester -n "${NAMESPACE}" svc/proxy

0 commit comments

Comments
 (0)