mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-04 12:05:35 +00:00
✨ POST storage limit to Hub and better error handling
This commit is contained in:
@@ -426,6 +426,9 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider
|
|||||||
log.Error().Err(err).Send()
|
log.Error().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Storage Limit
|
||||||
|
connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes())
|
||||||
|
|
||||||
// Pod regex
|
// Pod regex
|
||||||
connector.PostRegexToHub(config.Config.Tap.PodRegexStr, state.targetNamespaces)
|
connector.PostRegexToHub(config.Config.Tap.PodRegexStr, state.targetNamespaces)
|
||||||
|
|
||||||
|
@@ -8,7 +8,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kubeshark/kubeshark/config"
|
|
||||||
"github.com/kubeshark/kubeshark/config/configStructs"
|
"github.com/kubeshark/kubeshark/config/configStructs"
|
||||||
"github.com/kubeshark/kubeshark/utils"
|
"github.com/kubeshark/kubeshark/utils"
|
||||||
|
|
||||||
@@ -71,7 +70,8 @@ func (connector *Connector) PostWorkerPodToHub(pod *v1.Pod) {
|
|||||||
} else {
|
} else {
|
||||||
ok := false
|
ok := false
|
||||||
for !ok {
|
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 {
|
if _, ok := err.(*url.Error); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,6 @@ func (connector *Connector) PostWorkerPodToHub(pod *v1.Pod) {
|
|||||||
} else {
|
} else {
|
||||||
ok = true
|
ok = true
|
||||||
log.Debug().Interface("worker-pod", pod).Msg("Reported worker pod to Hub:")
|
log.Debug().Interface("worker-pod", pod).Msg("Reported worker pod to Hub:")
|
||||||
connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes())
|
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
@@ -101,7 +100,8 @@ func (connector *Connector) PostStorageLimitToHub(limit int64) {
|
|||||||
} else {
|
} else {
|
||||||
ok := false
|
ok := false
|
||||||
for !ok {
|
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 {
|
if _, ok := err.(*url.Error); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,8 @@ func (connector *Connector) PostRegexToHub(regex string, namespaces []string) {
|
|||||||
} else {
|
} else {
|
||||||
ok := false
|
ok := false
|
||||||
for !ok {
|
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 {
|
if _, ok := err.(*url.Error); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -163,7 +164,8 @@ func (connector *Connector) PostLicense(license string) {
|
|||||||
} else {
|
} else {
|
||||||
ok := false
|
ok := false
|
||||||
for !ok {
|
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 {
|
if _, ok := err.(*url.Error); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -189,7 +191,8 @@ func (connector *Connector) PostConsts(consts map[string]interface{}) {
|
|||||||
} else {
|
} else {
|
||||||
ok := false
|
ok := false
|
||||||
for !ok {
|
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 {
|
if _, ok := err.(*url.Error); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -211,7 +214,8 @@ func (connector *Connector) PostScript(script *configStructs.Script) {
|
|||||||
} else {
|
} else {
|
||||||
ok := false
|
ok := false
|
||||||
for !ok {
|
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 {
|
if _, ok := err.(*url.Error); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user