mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Update printers to include changes from autoscaling/v2beta2
This commit is contained in:
parent
e31eff092f
commit
17740a2857
@ -2972,50 +2972,50 @@ func describeHorizontalPodAutoscaler(hpa *autoscaling.HorizontalPodAutoscaler, e
|
|||||||
for i, metric := range hpa.Spec.Metrics {
|
for i, metric := range hpa.Spec.Metrics {
|
||||||
switch metric.Type {
|
switch metric.Type {
|
||||||
case autoscaling.ExternalMetricSourceType:
|
case autoscaling.ExternalMetricSourceType:
|
||||||
if metric.External.TargetAverageValue != nil {
|
if metric.External.Target.AverageValue != nil {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil &&
|
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil &&
|
||||||
hpa.Status.CurrentMetrics[i].External.CurrentAverageValue != nil {
|
&hpa.Status.CurrentMetrics[i].External.Current.AverageValue != nil {
|
||||||
current = hpa.Status.CurrentMetrics[i].External.CurrentAverageValue.String()
|
current = hpa.Status.CurrentMetrics[i].External.Current.AverageValue.String()
|
||||||
}
|
}
|
||||||
w.Write(LEVEL_1, "%q (target average value):\t%s / %s\n", metric.External.MetricName, current, metric.External.TargetAverageValue.String())
|
w.Write(LEVEL_1, "%q (target average value):\t%s / %s\n", metric.External.Metric.Name, current, metric.External.Target.AverageValue.String())
|
||||||
} else {
|
} else {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil {
|
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].External != nil {
|
||||||
current = hpa.Status.CurrentMetrics[i].External.CurrentValue.String()
|
current = hpa.Status.CurrentMetrics[i].External.Current.Value.String()
|
||||||
}
|
}
|
||||||
w.Write(LEVEL_1, "%q (target value):\t%s / %s\n", metric.External.MetricName, current, metric.External.TargetValue.String())
|
w.Write(LEVEL_1, "%q (target value):\t%s / %s\n", metric.External.Metric.Name, current, metric.External.Target.Value.String())
|
||||||
|
|
||||||
}
|
}
|
||||||
case autoscaling.PodsMetricSourceType:
|
case autoscaling.PodsMetricSourceType:
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Pods != nil {
|
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Pods != nil {
|
||||||
current = hpa.Status.CurrentMetrics[i].Pods.CurrentAverageValue.String()
|
current = hpa.Status.CurrentMetrics[i].Pods.Current.AverageValue.String()
|
||||||
}
|
}
|
||||||
w.Write(LEVEL_1, "%q on pods:\t%s / %s\n", metric.Pods.MetricName, current, metric.Pods.TargetAverageValue.String())
|
w.Write(LEVEL_1, "%q on pods:\t%s / %s\n", metric.Pods.Metric.Name, current, metric.Pods.Target.AverageValue.String())
|
||||||
case autoscaling.ObjectMetricSourceType:
|
case autoscaling.ObjectMetricSourceType:
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Object != nil {
|
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Object != nil {
|
||||||
current = hpa.Status.CurrentMetrics[i].Object.CurrentValue.String()
|
current = hpa.Status.CurrentMetrics[i].Object.Current.Value.String()
|
||||||
}
|
}
|
||||||
w.Write(LEVEL_1, "%q on %s/%s:\t%s / %s\n", metric.Object.MetricName, metric.Object.Target.Kind, metric.Object.Target.Name, current, metric.Object.TargetValue.String())
|
w.Write(LEVEL_1, "%q on %s/%s:\t%s / %s\n", metric.Object.Metric.Name, metric.Object.DescribedObject.Kind, metric.Object.DescribedObject.Name, current, metric.Object.Target.Value.String())
|
||||||
case autoscaling.ResourceMetricSourceType:
|
case autoscaling.ResourceMetricSourceType:
|
||||||
w.Write(LEVEL_1, "resource %s on pods", string(metric.Resource.Name))
|
w.Write(LEVEL_1, "resource %s on pods", string(metric.Resource.Name))
|
||||||
if metric.Resource.TargetAverageValue != nil {
|
if metric.Resource.Target.AverageValue != nil {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil {
|
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil {
|
||||||
current = hpa.Status.CurrentMetrics[i].Resource.CurrentAverageValue.String()
|
current = hpa.Status.CurrentMetrics[i].Resource.Current.AverageValue.String()
|
||||||
}
|
}
|
||||||
w.Write(LEVEL_0, ":\t%s / %s\n", current, metric.Resource.TargetAverageValue.String())
|
w.Write(LEVEL_0, ":\t%s / %s\n", current, metric.Resource.Target.AverageValue.String())
|
||||||
} else {
|
} else {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil && hpa.Status.CurrentMetrics[i].Resource.CurrentAverageUtilization != nil {
|
if len(hpa.Status.CurrentMetrics) > i && hpa.Status.CurrentMetrics[i].Resource != nil && hpa.Status.CurrentMetrics[i].Resource.Current.AverageUtilization != nil {
|
||||||
current = fmt.Sprintf("%d%% (%s)", *hpa.Status.CurrentMetrics[i].Resource.CurrentAverageUtilization, hpa.Status.CurrentMetrics[i].Resource.CurrentAverageValue.String())
|
current = fmt.Sprintf("%d%% (%s)", *hpa.Status.CurrentMetrics[i].Resource.Current.AverageUtilization, hpa.Status.CurrentMetrics[i].Resource.Current.AverageValue.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
target := "<auto>"
|
target := "<auto>"
|
||||||
if metric.Resource.TargetAverageUtilization != nil {
|
if metric.Resource.Target.AverageUtilization != nil {
|
||||||
target = fmt.Sprintf("%d%%", *metric.Resource.TargetAverageUtilization)
|
target = fmt.Sprintf("%d%%", *metric.Resource.Target.AverageUtilization)
|
||||||
}
|
}
|
||||||
w.Write(LEVEL_1, "(as a percentage of request):\t%s / %s\n", current, target)
|
w.Write(LEVEL_1, "(as a percentage of request):\t%s / %s\n", current, target)
|
||||||
}
|
}
|
||||||
|
@ -1483,6 +1483,10 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
minReplicasVal := int32(2)
|
minReplicasVal := int32(2)
|
||||||
targetUtilizationVal := int32(80)
|
targetUtilizationVal := int32(80)
|
||||||
currentUtilizationVal := int32(50)
|
currentUtilizationVal := int32(50)
|
||||||
|
metricLabelSelector, err := metav1.ParseToLabelSelector("label=value")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unable to parse label selector: %v", err)
|
||||||
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
hpa autoscaling.HorizontalPodAutoscaler
|
hpa autoscaling.HorizontalPodAutoscaler
|
||||||
@ -1517,13 +1521,14 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1548,13 +1553,14 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1566,13 +1572,13 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricStatus{
|
External: &autoscaling.ExternalMetricStatus{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
CurrentAverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1593,13 +1599,14 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
TargetValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1624,13 +1631,14 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
TargetValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1642,13 +1650,13 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricStatus{
|
External: &autoscaling.ExternalMetricStatus{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
Value: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
CurrentValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1669,8 +1677,13 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1695,8 +1708,13 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1708,8 +1726,12 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricStatus{
|
Pods: &autoscaling.PodsMetricStatus{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1730,12 +1752,17 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ObjectMetricSourceType,
|
Type: autoscaling.ObjectMetricSourceType,
|
||||||
Object: &autoscaling.ObjectMetricSource{
|
Object: &autoscaling.ObjectMetricSource{
|
||||||
Target: autoscaling.CrossVersionObjectReference{
|
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||||
Name: "some-service",
|
Name: "some-service",
|
||||||
Kind: "Service",
|
Kind: "Service",
|
||||||
},
|
},
|
||||||
MetricName: "some-service-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-service-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1760,12 +1787,17 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ObjectMetricSourceType,
|
Type: autoscaling.ObjectMetricSourceType,
|
||||||
Object: &autoscaling.ObjectMetricSource{
|
Object: &autoscaling.ObjectMetricSource{
|
||||||
Target: autoscaling.CrossVersionObjectReference{
|
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||||
Name: "some-service",
|
Name: "some-service",
|
||||||
Kind: "Service",
|
Kind: "Service",
|
||||||
},
|
},
|
||||||
MetricName: "some-service-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-service-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1777,12 +1809,16 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ObjectMetricSourceType,
|
Type: autoscaling.ObjectMetricSourceType,
|
||||||
Object: &autoscaling.ObjectMetricStatus{
|
Object: &autoscaling.ObjectMetricStatus{
|
||||||
Target: autoscaling.CrossVersionObjectReference{
|
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||||
Name: "some-service",
|
Name: "some-service",
|
||||||
Kind: "Service",
|
Kind: "Service",
|
||||||
},
|
},
|
||||||
MetricName: "some-service-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
CurrentValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Name: "some-service-metric",
|
||||||
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
Value: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1803,8 +1839,11 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1829,8 +1868,11 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1842,8 +1884,10 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricStatus{
|
Resource: &autoscaling.ResourceMetricStatus{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1865,7 +1909,10 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageUtilization: &targetUtilizationVal,
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.UtilizationMetricType,
|
||||||
|
AverageUtilization: &targetUtilizationVal,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1891,7 +1938,10 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageUtilization: &targetUtilizationVal,
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.UtilizationMetricType,
|
||||||
|
AverageUtilization: &targetUtilizationVal,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1904,8 +1954,10 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricStatus{
|
Resource: &autoscaling.ResourceMetricStatus{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
CurrentAverageUtilization: ¤tUtilizationVal,
|
Current: autoscaling.MetricValueStatus{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(40, resource.DecimalSI),
|
AverageUtilization: ¤tUtilizationVal,
|
||||||
|
AverageValue: resource.NewMilliQuantity(40, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1926,22 +1978,35 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageUtilization: &targetUtilizationVal,
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.UtilizationMetricType,
|
||||||
|
AverageUtilization: &targetUtilizationVal,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "other-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(400, resource.DecimalSI),
|
Name: "other-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(400, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1953,16 +2018,22 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricStatus{
|
Pods: &autoscaling.PodsMetricStatus{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricStatus{
|
Resource: &autoscaling.ResourceMetricStatus{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
CurrentAverageUtilization: ¤tUtilizationVal,
|
Current: autoscaling.MetricValueStatus{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(40, resource.DecimalSI),
|
AverageUtilization: ¤tUtilizationVal,
|
||||||
|
AverageValue: resource.NewMilliQuantity(40, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1580,47 +1580,47 @@ func formatHPAMetrics(specs []autoscaling.MetricSpec, statuses []autoscaling.Met
|
|||||||
for i, spec := range specs {
|
for i, spec := range specs {
|
||||||
switch spec.Type {
|
switch spec.Type {
|
||||||
case autoscaling.ExternalMetricSourceType:
|
case autoscaling.ExternalMetricSourceType:
|
||||||
if spec.External.TargetAverageValue != nil {
|
if spec.External.Target.AverageValue != nil {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(statuses) > i && statuses[i].External != nil && statuses[i].External.CurrentAverageValue != nil {
|
if len(statuses) > i && statuses[i].External != nil && &statuses[i].External.Current.AverageValue != nil {
|
||||||
current = statuses[i].External.CurrentAverageValue.String()
|
current = statuses[i].External.Current.AverageValue.String()
|
||||||
}
|
}
|
||||||
list = append(list, fmt.Sprintf("%s/%s (avg)", current, spec.External.TargetAverageValue.String()))
|
list = append(list, fmt.Sprintf("%s/%s (avg)", current, spec.External.Target.AverageValue.String()))
|
||||||
} else {
|
} else {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(statuses) > i && statuses[i].External != nil {
|
if len(statuses) > i && statuses[i].External != nil {
|
||||||
current = statuses[i].External.CurrentValue.String()
|
current = statuses[i].External.Current.Value.String()
|
||||||
}
|
}
|
||||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.External.TargetValue.String()))
|
list = append(list, fmt.Sprintf("%s/%s", current, spec.External.Target.Value.String()))
|
||||||
}
|
}
|
||||||
case autoscaling.PodsMetricSourceType:
|
case autoscaling.PodsMetricSourceType:
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(statuses) > i && statuses[i].Pods != nil {
|
if len(statuses) > i && statuses[i].Pods != nil {
|
||||||
current = statuses[i].Pods.CurrentAverageValue.String()
|
current = statuses[i].Pods.Current.AverageValue.String()
|
||||||
}
|
}
|
||||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Pods.TargetAverageValue.String()))
|
list = append(list, fmt.Sprintf("%s/%s", current, spec.Pods.Target.AverageValue.String()))
|
||||||
case autoscaling.ObjectMetricSourceType:
|
case autoscaling.ObjectMetricSourceType:
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(statuses) > i && statuses[i].Object != nil {
|
if len(statuses) > i && statuses[i].Object != nil {
|
||||||
current = statuses[i].Object.CurrentValue.String()
|
current = statuses[i].Object.Current.Value.String()
|
||||||
}
|
}
|
||||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Object.TargetValue.String()))
|
list = append(list, fmt.Sprintf("%s/%s", current, spec.Object.Target.Value.String()))
|
||||||
case autoscaling.ResourceMetricSourceType:
|
case autoscaling.ResourceMetricSourceType:
|
||||||
if spec.Resource.TargetAverageValue != nil {
|
if spec.Resource.Target.AverageValue != nil {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(statuses) > i && statuses[i].Resource != nil {
|
if len(statuses) > i && statuses[i].Resource != nil {
|
||||||
current = statuses[i].Resource.CurrentAverageValue.String()
|
current = statuses[i].Resource.Current.AverageValue.String()
|
||||||
}
|
}
|
||||||
list = append(list, fmt.Sprintf("%s/%s", current, spec.Resource.TargetAverageValue.String()))
|
list = append(list, fmt.Sprintf("%s/%s", current, spec.Resource.Target.AverageValue.String()))
|
||||||
} else {
|
} else {
|
||||||
current := "<unknown>"
|
current := "<unknown>"
|
||||||
if len(statuses) > i && statuses[i].Resource != nil && statuses[i].Resource.CurrentAverageUtilization != nil {
|
if len(statuses) > i && statuses[i].Resource != nil && statuses[i].Resource.Current.AverageUtilization != nil {
|
||||||
current = fmt.Sprintf("%d%%", *statuses[i].Resource.CurrentAverageUtilization)
|
current = fmt.Sprintf("%d%%", *statuses[i].Resource.Current.AverageUtilization)
|
||||||
}
|
}
|
||||||
|
|
||||||
target := "<auto>"
|
target := "<auto>"
|
||||||
if spec.Resource.TargetAverageUtilization != nil {
|
if spec.Resource.Target.AverageUtilization != nil {
|
||||||
target = fmt.Sprintf("%d%%", *spec.Resource.TargetAverageUtilization)
|
target = fmt.Sprintf("%d%%", *spec.Resource.Target.AverageUtilization)
|
||||||
}
|
}
|
||||||
list = append(list, fmt.Sprintf("%s/%s", current, target))
|
list = append(list, fmt.Sprintf("%s/%s", current, target))
|
||||||
}
|
}
|
||||||
|
@ -2172,6 +2172,10 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
minReplicasVal := int32(2)
|
minReplicasVal := int32(2)
|
||||||
targetUtilizationVal := int32(80)
|
targetUtilizationVal := int32(80)
|
||||||
currentUtilizationVal := int32(50)
|
currentUtilizationVal := int32(50)
|
||||||
|
metricLabelSelector, err := metav1.ParseToLabelSelector("label=value")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unable to parse label selector: %v", err)
|
||||||
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
hpa autoscaling.HorizontalPodAutoscaler
|
hpa autoscaling.HorizontalPodAutoscaler
|
||||||
expected string
|
expected string
|
||||||
@ -2209,13 +2213,14 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2242,13 +2247,14 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2260,13 +2266,13 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricStatus{
|
External: &autoscaling.ExternalMetricStatus{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
CurrentAverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2289,13 +2295,14 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-service-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-service-metric",
|
|
||||||
TargetValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2322,13 +2329,14 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricSource{
|
External: &autoscaling.ExternalMetricSource{
|
||||||
MetricSelector: &metav1.LabelSelector{
|
Metric: autoscaling.MetricIdentifier{
|
||||||
MatchLabels: map[string]string{
|
Name: "some-external-metric",
|
||||||
"label": "value",
|
Selector: metricLabelSelector,
|
||||||
},
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
},
|
},
|
||||||
MetricName: "some-external-metric",
|
|
||||||
TargetValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2340,8 +2348,12 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ExternalMetricSourceType,
|
Type: autoscaling.ExternalMetricSourceType,
|
||||||
External: &autoscaling.ExternalMetricStatus{
|
External: &autoscaling.ExternalMetricStatus{
|
||||||
MetricName: "some-external-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
CurrentValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Name: "some-external-metric",
|
||||||
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
Value: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2364,8 +2376,13 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2392,8 +2409,13 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2405,8 +2427,12 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricStatus{
|
Pods: &autoscaling.PodsMetricStatus{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2429,12 +2455,17 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ObjectMetricSourceType,
|
Type: autoscaling.ObjectMetricSourceType,
|
||||||
Object: &autoscaling.ObjectMetricSource{
|
Object: &autoscaling.ObjectMetricSource{
|
||||||
Target: autoscaling.CrossVersionObjectReference{
|
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||||
Name: "some-service",
|
Name: "some-service",
|
||||||
Kind: "Service",
|
Kind: "Service",
|
||||||
},
|
},
|
||||||
MetricName: "some-service-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-service-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2461,12 +2492,17 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ObjectMetricSourceType,
|
Type: autoscaling.ObjectMetricSourceType,
|
||||||
Object: &autoscaling.ObjectMetricSource{
|
Object: &autoscaling.ObjectMetricSource{
|
||||||
Target: autoscaling.CrossVersionObjectReference{
|
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||||
Name: "some-service",
|
Name: "some-service",
|
||||||
Kind: "Service",
|
Kind: "Service",
|
||||||
},
|
},
|
||||||
MetricName: "some-service-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-service-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.ValueMetricType,
|
||||||
|
Value: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2478,12 +2514,16 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ObjectMetricSourceType,
|
Type: autoscaling.ObjectMetricSourceType,
|
||||||
Object: &autoscaling.ObjectMetricStatus{
|
Object: &autoscaling.ObjectMetricStatus{
|
||||||
Target: autoscaling.CrossVersionObjectReference{
|
DescribedObject: autoscaling.CrossVersionObjectReference{
|
||||||
Name: "some-service",
|
Name: "some-service",
|
||||||
Kind: "Service",
|
Kind: "Service",
|
||||||
},
|
},
|
||||||
MetricName: "some-service-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
CurrentValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Name: "some-service-metric",
|
||||||
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
Value: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2506,8 +2546,11 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2534,8 +2577,11 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2547,8 +2593,10 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricStatus{
|
Resource: &autoscaling.ResourceMetricStatus{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2572,7 +2620,10 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageUtilization: &targetUtilizationVal,
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.UtilizationMetricType,
|
||||||
|
AverageUtilization: &targetUtilizationVal,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2600,7 +2651,10 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageUtilization: &targetUtilizationVal,
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.UtilizationMetricType,
|
||||||
|
AverageUtilization: &targetUtilizationVal,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2613,8 +2667,10 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricStatus{
|
Resource: &autoscaling.ResourceMetricStatus{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
CurrentAverageUtilization: ¤tUtilizationVal,
|
Current: autoscaling.MetricValueStatus{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(40, resource.DecimalSI),
|
AverageUtilization: ¤tUtilizationVal,
|
||||||
|
AverageValue: resource.NewMilliQuantity(40, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2637,22 +2693,35 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(100, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(100, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricSource{
|
Resource: &autoscaling.ResourceMetricSource{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
TargetAverageUtilization: &targetUtilizationVal,
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.UtilizationMetricType,
|
||||||
|
AverageUtilization: &targetUtilizationVal,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricSource{
|
Pods: &autoscaling.PodsMetricSource{
|
||||||
MetricName: "other-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
TargetAverageValue: *resource.NewMilliQuantity(400, resource.DecimalSI),
|
Name: "other-pods-metric",
|
||||||
|
},
|
||||||
|
Target: autoscaling.MetricTarget{
|
||||||
|
Type: autoscaling.AverageValueMetricType,
|
||||||
|
AverageValue: resource.NewMilliQuantity(400, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2664,16 +2733,22 @@ func TestPrintHPA(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Type: autoscaling.PodsMetricSourceType,
|
Type: autoscaling.PodsMetricSourceType,
|
||||||
Pods: &autoscaling.PodsMetricStatus{
|
Pods: &autoscaling.PodsMetricStatus{
|
||||||
MetricName: "some-pods-metric",
|
Metric: autoscaling.MetricIdentifier{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(50, resource.DecimalSI),
|
Name: "some-pods-metric",
|
||||||
|
},
|
||||||
|
Current: autoscaling.MetricValueStatus{
|
||||||
|
AverageValue: resource.NewMilliQuantity(50, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: autoscaling.ResourceMetricSourceType,
|
Type: autoscaling.ResourceMetricSourceType,
|
||||||
Resource: &autoscaling.ResourceMetricStatus{
|
Resource: &autoscaling.ResourceMetricStatus{
|
||||||
Name: api.ResourceCPU,
|
Name: api.ResourceCPU,
|
||||||
CurrentAverageUtilization: ¤tUtilizationVal,
|
Current: autoscaling.MetricValueStatus{
|
||||||
CurrentAverageValue: *resource.NewMilliQuantity(40, resource.DecimalSI),
|
AverageUtilization: ¤tUtilizationVal,
|
||||||
|
AverageValue: resource.NewMilliQuantity(40, resource.DecimalSI),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user