* 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:
parent
4e6c2b41db
commit
7dde3f3958
2 changed files with 8 additions and 0 deletions
|
@ -214,6 +214,10 @@ func podListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(meta
|
||||||
if s != nil {
|
if s != nil {
|
||||||
opts.LabelSelector = s.String()
|
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)
|
listV1, err := c.CoreV1().Pods(ns).List(opts)
|
||||||
return listV1, err
|
return listV1, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ func podWatchFunc(c kubernetes.Interface, ns string, s labels.Selector) func(opt
|
||||||
if s != nil {
|
if s != nil {
|
||||||
options.LabelSelector = s.String()
|
options.LabelSelector = s.String()
|
||||||
}
|
}
|
||||||
|
if len(options.FieldSelector) > 0 {
|
||||||
|
options.FieldSelector = options.FieldSelector + ","
|
||||||
|
}
|
||||||
|
options.FieldSelector = options.FieldSelector + "status.phase!=Succeeded,status.phase!=Failed,status.phase!=Unknown"
|
||||||
w, err := c.CoreV1().Pods(ns).Watch(options)
|
w, err := c.CoreV1().Pods(ns).Watch(options)
|
||||||
return w, err
|
return w, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue