fix #1024
parent
66e4528244
commit
89ff119977
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
|
"k8s.io/client-go/1.5/pkg/api"
|
||||||
mv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
|
mv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -121,7 +122,7 @@ func (p Pod) Render(o interface{}, ns string, row *Row) error {
|
||||||
mapToStr(po.Labels),
|
mapToStr(po.Labels),
|
||||||
asStatus(p.diagnose(phase, cr, len(ss))),
|
asStatus(p.diagnose(phase, cr, len(ss))),
|
||||||
asNominated(po.Status.NominatedNodeName),
|
asNominated(po.Status.NominatedNodeName),
|
||||||
asReadinessGate(po.Spec.ReadinessGates),
|
asReadinessGate(po),
|
||||||
toAge(po.ObjectMeta.CreationTimestamp),
|
toAge(po.ObjectMeta.CreationTimestamp),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,15 +150,25 @@ func asNominated(n string) string {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func asReadinessGate(gg []v1.PodReadinessGate) string {
|
func asReadinessGate(pod v1.Pod) string {
|
||||||
if len(gg) == 0 {
|
if len(pod.Spec.ReadinessGates) == 0 {
|
||||||
return MissingValue
|
return MissingValue
|
||||||
}
|
}
|
||||||
ss := make([]string, 0, len(gg))
|
|
||||||
for _, g := range gg {
|
trueConditions := 0
|
||||||
ss = append(ss, string(g.ConditionType))
|
for _, readinessGate := range pod.Spec.ReadinessGates {
|
||||||
|
conditionType := readinessGate.ConditionType
|
||||||
|
for _, condition := range pod.Status.Conditions {
|
||||||
|
if condition.Type == conditionType {
|
||||||
|
if condition.Status == api.ConditionTrue {
|
||||||
|
trueConditions++
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return strings.Join(ss, ",")
|
|
||||||
|
return strconv.Itoa(trueConditions) + "/" + strconv.Itoa(len(pod.Spec.ReadinessGates))
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodWithMetrics represents a pod and its metrics.
|
// PodWithMetrics represents a pod and its metrics.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue