Fix for #2842, instead of returning the first Pod, return the one whi… (#2846)

* Fix for #2842, instead of returning the first Pod, return the one which is Running

* a more memory efficient version of the fix, string -> bool

* fix with no extra fields in struct, return nil at Pod conversion if Pod is not Running

* let Kuberneretes filter for Running Pods using FieldSelector

* filter for Pods that are Running and Pending (implicit)
This commit is contained in:
Andras Spitzer 2019-05-29 08:06:46 +01:00 committed by Miek Gieben
parent 4e6c2b41db
commit 7dde3f3958
2 changed files with 8 additions and 0 deletions

View file

@ -214,6 +214,10 @@ func podListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(meta
if s != nil {
opts.LabelSelector = s.String()
}
if len(opts.FieldSelector) > 0 {
opts.FieldSelector = opts.FieldSelector + ","
}
opts.FieldSelector = opts.FieldSelector + "status.phase!=Succeeded,status.phase!=Failed,status.phase!=Unknown"
listV1, err := c.CoreV1().Pods(ns).List(opts)
return listV1, err
}