From 33fa43252e06ad1a3e5899c2547d1e2339ccb7fd Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Tue, 19 Apr 2022 11:08:16 -0700 Subject: [PATCH] cmd/proxy-to-grafana: prevent premature termination This commit changes proxy-to-grafana to report errors while polling for tailscaled status instead of terminating at the first sign of an error. This allows tailscale some time to come up before the proxy decides to give up. Signed-off-by: Blake Mizerany --- cmd/proxy-to-grafana/proxy-to-grafana.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/proxy-to-grafana/proxy-to-grafana.go b/cmd/proxy-to-grafana/proxy-to-grafana.go index 1625f30b3..b81f1dec5 100644 --- a/cmd/proxy-to-grafana/proxy-to-grafana.go +++ b/cmd/proxy-to-grafana/proxy-to-grafana.go @@ -86,11 +86,12 @@ func main() { for i := 0; i < 60; i++ { st, err := tailscale.Status(context.Background()) if err != nil { - log.Fatal(err) - } - log.Printf("tailscale status: %v", st.BackendState) - if st.BackendState == "Running" { - break + log.Printf("error retrieving tailscale status; retrying: %v", err) + } else { + log.Printf("tailscale status: %v", st.BackendState) + if st.BackendState == "Running" { + break + } } time.Sleep(time.Second) }