diff --git a/cmd/tapRunner.go b/cmd/tapRunner.go index 970b3d286..d9527d01f 100644 --- a/cmd/tapRunner.go +++ b/cmd/tapRunner.go @@ -426,6 +426,9 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider log.Error().Err(err).Send() } + // Storage Limit + connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes()) + // Pod regex connector.PostRegexToHub(config.Config.Tap.PodRegexStr, state.targetNamespaces) diff --git a/internal/connect/hub.go b/internal/connect/hub.go index 624c822a4..4f6064517 100644 --- a/internal/connect/hub.go +++ b/internal/connect/hub.go @@ -8,7 +8,6 @@ import ( "net/url" "time" - "github.com/kubeshark/kubeshark/config" "github.com/kubeshark/kubeshark/config/configStructs" "github.com/kubeshark/kubeshark/utils" @@ -71,7 +70,8 @@ func (connector *Connector) PostWorkerPodToHub(pod *v1.Pod) { } else { ok := false for !ok { - if _, err = utils.Post(postWorkerUrl, "application/json", bytes.NewBuffer(podMarshalled), connector.client); err != nil { + var resp *http.Response + if resp, err = utils.Post(postWorkerUrl, "application/json", bytes.NewBuffer(podMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK { if _, ok := err.(*url.Error); ok { break } @@ -79,7 +79,6 @@ func (connector *Connector) PostWorkerPodToHub(pod *v1.Pod) { } else { ok = true log.Debug().Interface("worker-pod", pod).Msg("Reported worker pod to Hub:") - connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes()) } time.Sleep(time.Second) } @@ -101,7 +100,8 @@ func (connector *Connector) PostStorageLimitToHub(limit int64) { } else { ok := false for !ok { - if _, err = utils.Post(postStorageLimitUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil { + var resp *http.Response + if resp, err = utils.Post(postStorageLimitUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK { if _, ok := err.(*url.Error); ok { break } @@ -133,7 +133,8 @@ func (connector *Connector) PostRegexToHub(regex string, namespaces []string) { } else { ok := false for !ok { - if _, err = utils.Post(postRegexUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil { + var resp *http.Response + if resp, err = utils.Post(postRegexUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK { if _, ok := err.(*url.Error); ok { break } @@ -163,7 +164,8 @@ func (connector *Connector) PostLicense(license string) { } else { ok := false for !ok { - if _, err = utils.Post(postLicenseUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil { + var resp *http.Response + if resp, err = utils.Post(postLicenseUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK { if _, ok := err.(*url.Error); ok { break } @@ -189,7 +191,8 @@ func (connector *Connector) PostConsts(consts map[string]interface{}) { } else { ok := false for !ok { - if _, err = utils.Post(postConstsUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil { + var resp *http.Response + if resp, err = utils.Post(postConstsUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK { if _, ok := err.(*url.Error); ok { break } @@ -211,7 +214,8 @@ func (connector *Connector) PostScript(script *configStructs.Script) { } else { ok := false for !ok { - if _, err = utils.Post(postScriptUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil { + var resp *http.Response + if resp, err = utils.Post(postScriptUrl, "application/json", bytes.NewBuffer(payloadMarshalled), connector.client); err != nil || resp.StatusCode != http.StatusOK { if _, ok := err.(*url.Error); ok { break }