forked from kiali/kiali
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidecars_check.go
41 lines (32 loc) · 971 Bytes
/
sidecars_check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package appender
import (
"github.com/kiali/kiali/graph"
"github.com/kiali/kiali/kubernetes"
"github.com/kiali/kiali/services/business/checkers"
)
type SidecarsCheckAppender struct{}
// AppendGraph implements Appender
func (a SidecarsCheckAppender) AppendGraph(trafficMap graph.TrafficMap, _ string) {
if len(trafficMap) == 0 {
return
}
k8s, err := kubernetes.NewClient()
checkError(err)
a.applySidecarsChecks(trafficMap, k8s)
}
func (a SidecarsCheckAppender) applySidecarsChecks(trafficMap graph.TrafficMap, k8s *kubernetes.IstioClient) {
for _, s := range trafficMap {
if s.Name == graph.UnknownService {
return
}
pods, err := k8s.GetServicePods(s.Namespace, s.ServiceName, s.Version)
checkError(err)
checker := checkers.PodChecker{Pods: pods.Items}
validations := checker.Check()
sidecarsOk := true
for _, check := range validations {
sidecarsOk = sidecarsOk && check.Valid
}
s.Metadata["hasMissingSC"] = !sidecarsOk
}
}