only list running pods

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
This commit is contained in:
Evan Baker
2021-08-23 12:47:51 -05:00
parent 294b8dda19
commit 980a85b04d
2 changed files with 6 additions and 6 deletions

View File

@@ -57,7 +57,6 @@ func CheckNeighboursNeighbours(ctx context.Context) *models.CheckAllResults {
// CheckCluster does a CheckNeighboursNeighbours and analyses results to produce a binary OK or not OK
func CheckCluster(ctx context.Context) *models.ClusterHealthResults {
start := time.Now()
output := models.ClusterHealthResults{
GeneratedAt: strfmt.DateTime(start),
@@ -156,7 +155,6 @@ type CheckServicePodsResult struct {
// CheckAllPods calls all neighbours and returns a detailed report
func CheckAllPods(checkAllCtx context.Context, pods map[string]*GoldpingerPod) *models.CheckAllResults {
result := models.CheckAllResults{Responses: make(map[string]models.CheckAllPodResult)}
ch := make(chan CheckServicePodsResult, len(pods))
@@ -164,9 +162,7 @@ func CheckAllPods(checkAllCtx context.Context, pods map[string]*GoldpingerPod) *
wg.Add(len(pods))
for _, pod := range pods {
go func(pod *GoldpingerPod) {
// logger
logger := zap.L().With(
zap.String("op", "check"),

View File

@@ -44,7 +44,11 @@ func getPodNamespace() string {
// GetAllPods returns a mapping from a pod name to a pointer to a GoldpingerPod(s)
func GetAllPods() map[string]*GoldpingerPod {
timer := GetLabeledKubernetesCallsTimer()
pods, err := GoldpingerConfig.KubernetesClient.CoreV1().Pods(*GoldpingerConfig.Namespace).List(metav1.ListOptions{LabelSelector: GoldpingerConfig.LabelSelector})
listOpts := metav1.ListOptions{
LabelSelector: GoldpingerConfig.LabelSelector,
FieldSelector: "status.phase=Running", // only select Running pods, otherwise we will get them before they have IPs
}
pods, err := GoldpingerConfig.KubernetesClient.CoreV1().Pods(*GoldpingerConfig.Namespace).List(listOpts)
if err != nil {
zap.L().Error("Error getting pods for selector", zap.String("selector", GoldpingerConfig.LabelSelector), zap.Error(err))
CountError("kubernetes_api")
@@ -52,7 +56,7 @@ func GetAllPods() map[string]*GoldpingerPod {
timer.ObserveDuration()
}
var podMap = make(map[string]*GoldpingerPod)
podMap := make(map[string]*GoldpingerPod)
for _, pod := range pods.Items {
podMap[pod.Name] = &GoldpingerPod{
Name: pod.Name,