mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-05 04:18:50 +00:00
Fix acceptance tests (after pods status request change) (#545)
This commit is contained in:
parent
cba0c682e5
commit
2d78785558
@ -304,11 +304,10 @@ func cleanupCommand(cmd *exec.Cmd) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getPods(tapStatusInterface interface{}) ([]map[string]interface{}, error) {
|
func getPods(tapStatusInterface interface{}) ([]map[string]interface{}, error) {
|
||||||
tapStatus := tapStatusInterface.(map[string]interface{})
|
tapPodsInterface := tapStatusInterface.([]interface{})
|
||||||
podsInterface := tapStatus["pods"].([]interface{})
|
|
||||||
|
|
||||||
var pods []map[string]interface{}
|
var pods []map[string]interface{}
|
||||||
for _, podInterface := range podsInterface {
|
for _, podInterface := range tapPodsInterface {
|
||||||
pods = append(pods, podInterface.(map[string]interface{}))
|
pods = append(pods, podInterface.(map[string]interface{}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"plugin"
|
"plugin"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -468,11 +467,7 @@ func startMizuTapperSyncer(ctx context.Context, provider *kubernetes.Provider) (
|
|||||||
}
|
}
|
||||||
providers.TapStatus = shared.TapStatus{Pods: kubernetes.GetPodInfosForPods(tapperSyncer.CurrentlyTappedPods)}
|
providers.TapStatus = shared.TapStatus{Pods: kubernetes.GetPodInfosForPods(tapperSyncer.CurrentlyTappedPods)}
|
||||||
|
|
||||||
tappedPodsStatus := make([]shared.TappedPodStatus, 0)
|
tappedPodsStatus := utils.GetTappedPodsStatus()
|
||||||
for _, pod := range providers.TapStatus.Pods {
|
|
||||||
isTapped := strings.ToLower(providers.TappersStatus[pod.NodeName].Status) == "started"
|
|
||||||
tappedPodsStatus = append(tappedPodsStatus, shared.TappedPodStatus{Name: pod.Name, Namespace: pod.Namespace, IsTapped: isTapped})
|
|
||||||
}
|
|
||||||
|
|
||||||
serializedTapStatus, err := json.Marshal(shared.CreateWebSocketStatusMessage(tappedPodsStatus))
|
serializedTapStatus, err := json.Marshal(shared.CreateWebSocketStatusMessage(tappedPodsStatus))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,18 +3,17 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/up9inc/mizu/shared"
|
||||||
|
"github.com/up9inc/mizu/shared/logger"
|
||||||
"mizuserver/pkg/api"
|
"mizuserver/pkg/api"
|
||||||
"mizuserver/pkg/config"
|
"mizuserver/pkg/config"
|
||||||
"mizuserver/pkg/holder"
|
"mizuserver/pkg/holder"
|
||||||
"mizuserver/pkg/providers"
|
"mizuserver/pkg/providers"
|
||||||
"mizuserver/pkg/up9"
|
"mizuserver/pkg/up9"
|
||||||
|
"mizuserver/pkg/utils"
|
||||||
"mizuserver/pkg/validation"
|
"mizuserver/pkg/validation"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/up9inc/mizu/shared"
|
|
||||||
"github.com/up9inc/mizu/shared/logger"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func HealthCheck(c *gin.Context) {
|
func HealthCheck(c *gin.Context) {
|
||||||
@ -54,11 +53,7 @@ func PostTappedPods(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func broadcastTappedPodsStatus() {
|
func broadcastTappedPodsStatus() {
|
||||||
tappedPodsStatus := make([]shared.TappedPodStatus, 0)
|
tappedPodsStatus := utils.GetTappedPodsStatus()
|
||||||
for _, pod := range providers.TapStatus.Pods {
|
|
||||||
isTapped := strings.ToLower(providers.TappersStatus[pod.NodeName].Status) == "started"
|
|
||||||
tappedPodsStatus = append(tappedPodsStatus, shared.TappedPodStatus{Name: pod.Name, Namespace: pod.Namespace, IsTapped: isTapped})
|
|
||||||
}
|
|
||||||
|
|
||||||
message := shared.CreateWebSocketStatusMessage(tappedPodsStatus)
|
message := shared.CreateWebSocketStatusMessage(tappedPodsStatus)
|
||||||
if jsonBytes, err := json.Marshal(message); err != nil {
|
if jsonBytes, err := json.Marshal(message); err != nil {
|
||||||
@ -101,11 +96,7 @@ func GetAuthStatus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetTappingStatus(c *gin.Context) {
|
func GetTappingStatus(c *gin.Context) {
|
||||||
tappedPodsStatus := make([]shared.TappedPodStatus, 0)
|
tappedPodsStatus := utils.GetTappedPodsStatus()
|
||||||
for _, pod := range providers.TapStatus.Pods {
|
|
||||||
isTapped := strings.ToLower(providers.TappersStatus[pod.NodeName].Status) == "started"
|
|
||||||
tappedPodsStatus = append(tappedPodsStatus, shared.TappedPodStatus{Name: pod.Name, Namespace: pod.Namespace, IsTapped: isTapped})
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, tappedPodsStatus)
|
c.JSON(http.StatusOK, tappedPodsStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,12 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"mizuserver/pkg/providers"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"reflect"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -44,15 +45,13 @@ func StartServer(app *gin.Engine) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReverseSlice(data interface{}) {
|
func GetTappedPodsStatus() []shared.TappedPodStatus {
|
||||||
value := reflect.ValueOf(data)
|
tappedPodsStatus := make([]shared.TappedPodStatus, 0)
|
||||||
valueLen := value.Len()
|
for _, pod := range providers.TapStatus.Pods {
|
||||||
for i := 0; i <= int((valueLen-1)/2); i++ {
|
isTapped := strings.ToLower(providers.TappersStatus[pod.NodeName].Status) == "started"
|
||||||
reverseIndex := valueLen - 1 - i
|
tappedPodsStatus = append(tappedPodsStatus, shared.TappedPodStatus{Name: pod.Name, Namespace: pod.Namespace, IsTapped: isTapped})
|
||||||
tmp := value.Index(reverseIndex).Interface()
|
|
||||||
value.Index(reverseIndex).Set(value.Index(i))
|
|
||||||
value.Index(i).Set(reflect.ValueOf(tmp))
|
|
||||||
}
|
}
|
||||||
|
return tappedPodsStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckErr(e error) {
|
func CheckErr(e error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user