Call POST /scripts/done after the posting the scripts to mark the end

This commit is contained in:
M. Mert Yildiran 2023-02-07 12:25:41 +03:00
parent a6dd98d241
commit 2a20dc173c
No known key found for this signature in database
GPG Key ID: DA5D6DCBB758A461
2 changed files with 22 additions and 0 deletions

View File

@ -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:"))

View File

@ -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)
}
}