From b2342dbe238939029c47ec6839e7854f65495170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Nicol?= Date: Mon, 3 Feb 2025 16:29:26 +0100 Subject: [PATCH] improved run-local port-forward management (#239) Co-authored-by: Herve Nicol <12008875+hervenicol@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ hack/bin/run-local.sh | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5d13893..e0fdaef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- improved run-local port-forward management + ### Removed - Remove turtle related Alertmanager configuration diff --git a/hack/bin/run-local.sh b/hack/bin/run-local.sh index 445e518e..07221b85 100755 --- a/hack/bin/run-local.sh +++ b/hack/bin/run-local.sh @@ -33,24 +33,32 @@ function setEnvFromSecrets { # Port-forward the Grafana service function grafanaPortForward { - kubectl port-forward -n "$NAMESPACE" svc/grafana 3000:80 &>/dev/null & + while true; do + kubectl port-forward -n "$NAMESPACE" svc/grafana 3000:80 &>/dev/null || true + done & GRAFANAPORTFORWARDPID="$!" } # Stop the Grafana service port-forward function stopGrafanaPortForward { + childpids=$(ps -o pid= --ppid "$GRAFANAPORTFORWARDPID") kill "$GRAFANAPORTFORWARDPID" || true + kill $childpids || true } # Port-forward the mimir service function mimirPortForward { - kubectl port-forward -n mimir svc/mimir-gateway 8180:80 &>/dev/null & + while true; do + kubectl port-forward -n mimir svc/mimir-gateway 8180:80 &>/dev/null || true + done & MIMIRPORTFORWARDPID="$!" } # Stop the Grafana service port-forward function stopMimirPortForward { + childpids=$(ps -o pid= --ppid "$MIMIRPORTFORWARDPID") kill "$MIMIRPORTFORWARDPID" || true + kill $childpids || true } # Pause the in-cluster operator @@ -90,7 +98,7 @@ function main { pauseInClusterOperator echo "### Running operator" - go run . "${OLLYOPARGS[@]}" -grafana-url http://localhost:3000 -monitoring-metrics-query-url http://localhost:8180 + go run . "${OLLYOPARGS[@]}" -grafana-url http://localhost:3000 -monitoring-metrics-query-url http://localhost:8180/prometheus echo "### Cleanup" }