mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Handle the case when min pods is nil for "kubectl get hpa"
This commit is contained in:
parent
f12171b430
commit
013096cb6e
@ -1388,7 +1388,7 @@ func printHorizontalPodAutoscaler(hpa *extensions.HorizontalPodAutoscaler, w io.
|
|||||||
hpa.Spec.ScaleRef.Namespace,
|
hpa.Spec.ScaleRef.Namespace,
|
||||||
hpa.Spec.ScaleRef.Name,
|
hpa.Spec.ScaleRef.Name,
|
||||||
hpa.Spec.ScaleRef.Subresource)
|
hpa.Spec.ScaleRef.Subresource)
|
||||||
target := "<unknown>"
|
target := "<unset>"
|
||||||
if hpa.Spec.CPUUtilization != nil {
|
if hpa.Spec.CPUUtilization != nil {
|
||||||
target = fmt.Sprintf("%d%%", hpa.Spec.CPUUtilization.TargetPercentage)
|
target = fmt.Sprintf("%d%%", hpa.Spec.CPUUtilization.TargetPercentage)
|
||||||
}
|
}
|
||||||
@ -1396,7 +1396,10 @@ func printHorizontalPodAutoscaler(hpa *extensions.HorizontalPodAutoscaler, w io.
|
|||||||
if hpa.Status.CurrentCPUUtilizationPercentage != nil {
|
if hpa.Status.CurrentCPUUtilizationPercentage != nil {
|
||||||
current = fmt.Sprintf("%d%%", *hpa.Status.CurrentCPUUtilizationPercentage)
|
current = fmt.Sprintf("%d%%", *hpa.Status.CurrentCPUUtilizationPercentage)
|
||||||
}
|
}
|
||||||
minPods := hpa.Spec.MinReplicas
|
minPods := "<unset>"
|
||||||
|
if hpa.Spec.MinReplicas != nil {
|
||||||
|
minPods = fmt.Sprintf("%d", *hpa.Spec.MinReplicas)
|
||||||
|
}
|
||||||
maxPods := hpa.Spec.MaxReplicas
|
maxPods := hpa.Spec.MaxReplicas
|
||||||
if withNamespace {
|
if withNamespace {
|
||||||
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
|
if _, err := fmt.Fprintf(w, "%s\t", namespace); err != nil {
|
||||||
@ -1404,12 +1407,12 @@ func printHorizontalPodAutoscaler(hpa *extensions.HorizontalPodAutoscaler, w io.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%d\t%s",
|
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%d\t%s",
|
||||||
name,
|
name,
|
||||||
reference,
|
reference,
|
||||||
target,
|
target,
|
||||||
current,
|
current,
|
||||||
*minPods,
|
minPods,
|
||||||
maxPods,
|
maxPods,
|
||||||
translateTimestamp(hpa.CreationTimestamp),
|
translateTimestamp(hpa.CreationTimestamp),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user