mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Added metric resource name to HPA table (#122804)
* Added metric resource name to HPA table * Added colon suggested from code review
This commit is contained in:
parent
55f9657e07
commit
1ad143177c
@ -2307,7 +2307,7 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met
|
||||
if len(statuses) > i && statuses[i].Resource != nil {
|
||||
current = statuses[i].Resource.Current.AverageValue.String()
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Resource.Target.AverageValue.String()))
|
||||
list = append(list, fmt.Sprintf("%s: %s/%s", spec.Resource.Name.String(), current, spec.Resource.Target.AverageValue.String()))
|
||||
} else {
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].Resource != nil && statuses[i].Resource.Current.AverageUtilization != nil {
|
||||
@ -2318,7 +2318,7 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met
|
||||
if spec.Resource.Target.AverageUtilization != nil {
|
||||
target = fmt.Sprintf("%d%%", *spec.Resource.Target.AverageUtilization)
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, target))
|
||||
list = append(list, fmt.Sprintf("%s: %s/%s", spec.Resource.Name.String(), current, target))
|
||||
}
|
||||
case autoscaling.ContainerResourceMetricSourceType:
|
||||
if spec.ContainerResource.Target.AverageValue != nil {
|
||||
@ -2326,7 +2326,7 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met
|
||||
if len(statuses) > i && statuses[i].ContainerResource != nil {
|
||||
current = statuses[i].ContainerResource.Current.AverageValue.String()
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.ContainerResource.Target.AverageValue.String()))
|
||||
list = append(list, fmt.Sprintf("%s: %s/%s", spec.ContainerResource.Name.String(), current, spec.ContainerResource.Target.AverageValue.String()))
|
||||
} else {
|
||||
current := "<unknown>"
|
||||
if len(statuses) > i && statuses[i].ContainerResource != nil && statuses[i].ContainerResource.Current.AverageUtilization != nil {
|
||||
@ -2337,7 +2337,7 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met
|
||||
if spec.ContainerResource.Target.AverageUtilization != nil {
|
||||
target = fmt.Sprintf("%d%%", *spec.ContainerResource.Target.AverageUtilization)
|
||||
}
|
||||
list = append(list, fmt.Sprintf("%s/%s", current, target))
|
||||
list = append(list, fmt.Sprintf("%s: %s/%s", spec.ContainerResource.Name.String(), current, target))
|
||||
}
|
||||
default:
|
||||
list = append(list, "<unknown type>")
|
||||
|
@ -3121,7 +3121,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "<unknown>/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: <unknown>/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// resource source type, targetVal
|
||||
{
|
||||
@ -3164,7 +3164,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "50m/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: 50m/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// resource source type, targetUtil (no current)
|
||||
{
|
||||
@ -3196,7 +3196,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "<unknown>/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: <unknown>/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// resource source type, targetUtil
|
||||
{
|
||||
@ -3240,7 +3240,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "50%/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: 50%/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// container resource source type, targetVal (no current)
|
||||
{
|
||||
@ -3273,7 +3273,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "<unknown>/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: <unknown>/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// container resource source type, targetVal
|
||||
{
|
||||
@ -3317,7 +3317,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "50m/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: 50m/100m", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// container resource source type, targetUtil (no current)
|
||||
{
|
||||
@ -3350,7 +3350,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "<unknown>/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: <unknown>/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// container resource source type, targetUtil
|
||||
{
|
||||
@ -3395,7 +3395,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "50%/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "cpu: 50%/80%", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
// multiple specs
|
||||
{
|
||||
@ -3474,7 +3474,7 @@ func TestPrintHPA(t *testing.T) {
|
||||
},
|
||||
},
|
||||
// Columns: Name, Reference, Targets, MinPods, MaxPods, Replicas, Age
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "50m/100m, 50%/80% + 1 more...", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
expected: []metav1.TableRow{{Cells: []interface{}{"some-hpa", "ReplicationController/some-rc", "50m/100m, cpu: 50%/80% + 1 more...", "2", int64(10), int64(4), "<unknown>"}}},
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user