From 2a20dc173cdf5e5f0c170ed7fd00ff594a040058 Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Tue, 7 Feb 2023 12:25:41 +0300 Subject: [PATCH] :sparkles: Call `POST /scripts/done` after the posting the scripts to mark the end --- cmd/tapRunner.go | 2 ++ internal/connect/hub.go | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/cmd/tapRunner.go b/cmd/tapRunner.go index d9527d01f..4f92e1a86 100644 --- a/cmd/tapRunner.go +++ b/cmd/tapRunner.go @@ -450,6 +450,8 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider connector.PostScript(script) } + connector.PostScriptDone() + // Hub proxy URL url := kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort) log.Info().Str("url", url).Msg(fmt.Sprintf(utils.Green, "Hub is available at:")) diff --git a/internal/connect/hub.go b/internal/connect/hub.go index 4f6064517..5c90fabec 100644 --- a/internal/connect/hub.go +++ b/internal/connect/hub.go @@ -228,3 +228,23 @@ func (connector *Connector) PostScript(script *configStructs.Script) { } } } + +func (connector *Connector) PostScriptDone() { + postScripDonetUrl := fmt.Sprintf("%s/scripts/done", connector.url) + + ok := false + var err error + for !ok { + var resp *http.Response + if resp, err = utils.Post(postScripDonetUrl, "application/json", nil, connector.client); err != nil || resp.StatusCode != http.StatusOK { + if _, ok := err.(*url.Error); ok { + break + } + log.Debug().Err(err).Msg("Failed sending the POST script done to Hub:") + } else { + ok = true + log.Debug().Msg("Reported POST script done to Hub:") + } + time.Sleep(time.Second) + } +}