From 76bd48b1405b2356428615a870b4e871b1d3d259 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Wed, 5 Sep 2018 18:46:50 -0400 Subject: [PATCH] Fix up potentially empty fields in HPA v2beta2 There were a few cases where fields that should have been marked optional were not. This was causing weird validation issues, but is now fixed. --- api/openapi-spec/swagger.json | 5 ----- api/swagger-spec/autoscaling_v2beta2.json | 5 ----- .../autoscaling/v2beta2/definitions.html | 6 +++--- .../api/autoscaling/v2beta2/generated.proto | 6 ++++++ .../k8s.io/api/autoscaling/v2beta2/types.go | 19 ++++++++++++------- staging/src/k8s.io/metrics/Godeps/Godeps.json | 4 ---- test/e2e/instrumentation/monitoring/BUILD | 3 ++- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 53d1c1cc535..2f52c9eb9bd 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -79039,11 +79039,6 @@ }, "io.k8s.api.autoscaling.v2beta2.MetricValueStatus": { "description": "MetricValueStatus holds the current value for a metric", - "required": [ - "value", - "averageValue", - "averageUtilization" - ], "properties": { "averageUtilization": { "description": "currentAverageUtilization is the current value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods.", diff --git a/api/swagger-spec/autoscaling_v2beta2.json b/api/swagger-spec/autoscaling_v2beta2.json index 82faa15867a..626fbb33c01 100644 --- a/api/swagger-spec/autoscaling_v2beta2.json +++ b/api/swagger-spec/autoscaling_v2beta2.json @@ -1840,11 +1840,6 @@ "v2beta2.MetricValueStatus": { "id": "v2beta2.MetricValueStatus", "description": "MetricValueStatus holds the current value for a metric", - "required": [ - "value", - "averageValue", - "averageUtilization" - ], "properties": { "value": { "type": "string", diff --git a/docs/api-reference/autoscaling/v2beta2/definitions.html b/docs/api-reference/autoscaling/v2beta2/definitions.html index 9264640854e..28559ba3536 100755 --- a/docs/api-reference/autoscaling/v2beta2/definitions.html +++ b/docs/api-reference/autoscaling/v2beta2/definitions.html @@ -1002,21 +1002,21 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }

value

value is the current value of the metric (as a quantity).

-

true

+

false

string

averageValue

averageValue is the current value of the average of the metric across all relevant pods (as a quantity)

-

true

+

false

string

averageUtilization

currentAverageUtilization is the current value of the average of the resource metric across all relevant pods, represented as a percentage of the requested value of the resource for the pods.

-

true

+

false

integer (int32)

diff --git a/staging/src/k8s.io/api/autoscaling/v2beta2/generated.proto b/staging/src/k8s.io/api/autoscaling/v2beta2/generated.proto index 38f099ae74b..b4e4c95a3b1 100644 --- a/staging/src/k8s.io/api/autoscaling/v2beta2/generated.proto +++ b/staging/src/k8s.io/api/autoscaling/v2beta2/generated.proto @@ -259,31 +259,37 @@ message MetricTarget { optional string type = 1; // value is the target value of the metric (as a quantity). + // +optional optional k8s.io.apimachinery.pkg.api.resource.Quantity value = 2; // averageValue is the target value of the average of the // metric across all relevant pods (as a quantity) + // +optional optional k8s.io.apimachinery.pkg.api.resource.Quantity averageValue = 3; // averageUtilization is the target value of the average of the // resource metric across all relevant pods, represented as a percentage of // the requested value of the resource for the pods. // Currently only valid for Resource metric source type + // +optional optional int32 averageUtilization = 4; } // MetricValueStatus holds the current value for a metric message MetricValueStatus { // value is the current value of the metric (as a quantity). + // +optional optional k8s.io.apimachinery.pkg.api.resource.Quantity value = 1; // averageValue is the current value of the average of the // metric across all relevant pods (as a quantity) + // +optional optional k8s.io.apimachinery.pkg.api.resource.Quantity averageValue = 2; // currentAverageUtilization is the current value of the average of the // resource metric across all relevant pods, represented as a percentage of // the requested value of the resource for the pods. + // +optional optional int32 averageUtilization = 3; } diff --git a/staging/src/k8s.io/api/autoscaling/v2beta2/types.go b/staging/src/k8s.io/api/autoscaling/v2beta2/types.go index e873971f3fb..2d337953740 100644 --- a/staging/src/k8s.io/api/autoscaling/v2beta2/types.go +++ b/staging/src/k8s.io/api/autoscaling/v2beta2/types.go @@ -200,16 +200,18 @@ type MetricTarget struct { // type represents whether the metric type is Utilization, Value, or AverageValue Type MetricTargetType `json:"type" protobuf:"bytes,1,name=type"` // value is the target value of the metric (as a quantity). - Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,2,name=value"` + // +optional + Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"` // averageValue is the target value of the average of the // metric across all relevant pods (as a quantity) - AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,3,name=averageValue"` - + // +optional + AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,3,opt,name=averageValue"` // averageUtilization is the target value of the average of the // resource metric across all relevant pods, represented as a percentage of // the requested value of the resource for the pods. // Currently only valid for Resource metric source type - AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,4,name=averageUtilization"` + // +optional + AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,4,opt,name=averageUtilization"` } // MetricTargetType specifies the type of metric being targeted, and should be either @@ -364,14 +366,17 @@ type ExternalMetricStatus struct { // MetricValueStatus holds the current value for a metric type MetricValueStatus struct { // value is the current value of the metric (as a quantity). - Value *resource.Quantity `json:"value" protobuf:"bytes,1,name=value"` + // +optional + Value *resource.Quantity `json:"value,omitempty" protobuf:"bytes,1,opt,name=value"` // averageValue is the current value of the average of the // metric across all relevant pods (as a quantity) - AverageValue *resource.Quantity `json:"averageValue" protobuf:"bytes,2,name=averageValue"` + // +optional + AverageValue *resource.Quantity `json:"averageValue,omitempty" protobuf:"bytes,2,opt,name=averageValue"` // currentAverageUtilization is the current value of the average of the // resource metric across all relevant pods, represented as a percentage of // the requested value of the resource for the pods. - AverageUtilization *int32 `json:"averageUtilization" protobuf:"bytes,3,name=averageUtilization"` + // +optional + AverageUtilization *int32 `json:"averageUtilization,omitempty" protobuf:"bytes,3,opt,name=averageUtilization"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/staging/src/k8s.io/metrics/Godeps/Godeps.json b/staging/src/k8s.io/metrics/Godeps/Godeps.json index 59a8e39a3d7..5a2e5ba459b 100644 --- a/staging/src/k8s.io/metrics/Godeps/Godeps.json +++ b/staging/src/k8s.io/metrics/Godeps/Godeps.json @@ -450,10 +450,6 @@ "ImportPath": "k8s.io/client-go/discovery", "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }, - { - "ImportPath": "k8s.io/client-go/discovery/cached", - "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - }, { "ImportPath": "k8s.io/client-go/discovery/fake", "Rev": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" diff --git a/test/e2e/instrumentation/monitoring/BUILD b/test/e2e/instrumentation/monitoring/BUILD index 9ccc20d8136..8f647a964c3 100644 --- a/test/e2e/instrumentation/monitoring/BUILD +++ b/test/e2e/instrumentation/monitoring/BUILD @@ -22,6 +22,7 @@ go_library( "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/extensions/v1beta1:go_default_library", "//staging/src/k8s.io/api/rbac/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", @@ -29,8 +30,8 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/selection:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library", "//staging/src/k8s.io/client-go/discovery:go_default_library", - "//staging/src/k8s.io/client-go/discovery/cached:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library", + "//staging/src/k8s.io/metrics/pkg/apis/custom_metrics/v1beta1:go_default_library", "//staging/src/k8s.io/metrics/pkg/client/custom_metrics:go_default_library", "//staging/src/k8s.io/metrics/pkg/client/external_metrics:go_default_library", "//test/e2e/common:go_default_library",