Commit a79916fa authored by Mike Dame's avatar Mike Dame

Update autoscaling conversion and validation for v2beta2 inclusion

parent 5d1ee164
......@@ -39,6 +39,7 @@ filegroup(
"//pkg/apis/autoscaling/install:all-srcs",
"//pkg/apis/autoscaling/v1:all-srcs",
"//pkg/apis/autoscaling/v2beta1:all-srcs",
"//pkg/apis/autoscaling/v2beta2:all-srcs",
"//pkg/apis/autoscaling/validation:all-srcs",
],
tags = ["automanaged"],
......
......@@ -52,19 +52,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
}
targetUtilization := int32(c.RandUint64())
averageValue := randomQuantity()
s.Metrics = []autoscaling.MetricSpec{
{
Type: autoscaling.PodsMetricSourceType,
Pods: &autoscaling.PodsMetricSource{
MetricName: c.RandString(),
TargetAverageValue: randomQuantity(),
Metric: autoscaling.MetricIdentifier{
Name: c.RandString(),
},
Target: autoscaling.MetricTarget{
Type: autoscaling.AverageValueMetricType,
AverageValue: &averageValue,
},
},
},
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricSource{
Name: api.ResourceCPU,
TargetAverageUtilization: &targetUtilization,
Target: autoscaling.MetricTarget{
Type: autoscaling.UtilizationMetricType,
AverageUtilization: &targetUtilization,
},
},
},
}
......@@ -78,20 +87,28 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
_ = q.String()
return q
}
averageValue := randomQuantity()
currentUtilization := int32(c.RandUint64())
s.CurrentMetrics = []autoscaling.MetricStatus{
{
Type: autoscaling.PodsMetricSourceType,
Pods: &autoscaling.PodsMetricStatus{
MetricName: c.RandString(),
CurrentAverageValue: randomQuantity(),
Metric: autoscaling.MetricIdentifier{
Name: c.RandString(),
},
Current: autoscaling.MetricValueStatus{
AverageValue: &averageValue,
},
},
},
{
Type: autoscaling.ResourceMetricSourceType,
Resource: &autoscaling.ResourceMetricStatus{
Name: api.ResourceCPU,
CurrentAverageUtilization: &currentUtilization,
Current: autoscaling.MetricValueStatus{
AverageUtilization: &currentUtilization,
AverageValue: &averageValue,
},
},
},
}
......
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["install.go"],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/install",
visibility = ["//visibility:public"],
deps = [
"//pkg/api/legacyscheme:go_default_library",
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/autoscaling/v1:go_default_library",
"//pkg/apis/autoscaling/v2beta1:go_default_library",
"//pkg/apis/autoscaling/v2beta2:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
],
......@@ -30,4 +27,5 @@ filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
......@@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/autoscaling/v1"
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1"
"k8s.io/kubernetes/pkg/apis/autoscaling/v2beta2"
)
func init() {
......@@ -34,7 +35,8 @@ func init() {
// Install registers the API group and adds types to a scheme
func Install(scheme *runtime.Scheme) {
utilruntime.Must(autoscaling.AddToScheme(scheme))
utilruntime.Must(v2beta2.AddToScheme(scheme))
utilruntime.Must(v2beta1.AddToScheme(scheme))
utilruntime.Must(v1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion))
utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion, v2beta2.SchemeGroupVersion))
}
......@@ -251,6 +251,7 @@ type HorizontalPodAutoscalerStatus struct {
DesiredReplicas int32
// CurrentMetrics is the last read state of the metrics used by this autoscaler.
// +optional
CurrentMetrics []MetricStatus
// Conditions is the set of conditions required for this autoscaler to scale its target,
......@@ -343,6 +344,8 @@ type MetricStatus struct {
type ObjectMetricStatus struct {
Metric MetricIdentifier
Current MetricValueStatus
DescribedObject CrossVersionObjectReference
}
// PodsMetricStatus indicates the current value of a metric describing each pod in
......@@ -359,19 +362,8 @@ type PodsMetricStatus struct {
// normal per-pod metrics using the "pods" source.
type ResourceMetricStatus struct {
// Name is the name of the resource in question.
Name api.ResourceName
// 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. It will only be
// present if `targetAverageValue` was set in the corresponding metric
// specification.
// +optional
CurrentAverageUtilization *int32
// CurrentAverageValue is the current value of the average of the
// resource metric across all relevant pods, as a raw value (instead of as
// a percentage of the request), similar to the "pods" metric source type.
// It will always be set, regardless of the corresponding metric specification.
CurrentAverageValue resource.Quantity
Name api.ResourceName
Current MetricValueStatus
}
// ExternalMetricStatus indicates the current value of a global metric
......
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
......@@ -17,12 +11,12 @@ go_library(
"zz_generated.defaults.go",
],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v1",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/core:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1: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/conversion:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
......@@ -55,4 +49,5 @@ filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"conversion.go",
"defaults.go",
"doc.go",
"register.go",
......@@ -16,12 +11,12 @@ go_library(
"zz_generated.defaults.go",
],
importpath = "k8s.io/kubernetes/pkg/apis/autoscaling/v2beta1",
visibility = ["//visibility:public"],
deps = [
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/core:go_default_library",
"//staging/src/k8s.io/api/autoscaling/v2beta1:go_default_library",
"//staging/src/k8s.io/api/core/v1: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/conversion:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
......@@ -29,19 +24,6 @@ go_library(
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
go_test(
name = "go_default_test",
srcs = ["defaults_test.go"],
......@@ -58,3 +40,17 @@ go_test(
"//vendor/k8s.io/utils/pointer:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
......@@ -41,5 +41,5 @@ func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addDefaultingFuncs)
localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
}
......@@ -178,14 +178,16 @@ func validateMetricSpec(spec autoscaling.MetricSpec, fldPath *field.Path) field.
func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, ValidateCrossVersionObjectReference(src.Target, fldPath.Child("target"))...)
if len(src.MetricName) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name"))
allErrs = append(allErrs, ValidateCrossVersionObjectReference(src.DescribedObject, fldPath.Child("describedObject"))...)
allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else {
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
}
if src.TargetValue.Sign() != 1 {
allErrs = append(allErrs, field.Required(fldPath.Child("targetValue"), "must specify a positive target value"))
if src.Target.Value == nil && src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value or averageValue"))
}
return allErrs
......@@ -194,28 +196,19 @@ func validateObjectSource(src *autoscaling.ObjectMetricSource, fldPath *field.Pa
func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(src.MetricName) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name"))
allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else {
for _, msg := range pathvalidation.IsValidPathSegmentName(src.MetricName) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("metricName"), src.MetricName, msg))
}
}
if src.TargetValue == nil && src.TargetAverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("targetValue"), "must set either a target value for metric or a per-pod target"))
}
if src.TargetValue != nil && src.TargetAverageValue != nil {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("targetValue"), "may not set both a target value for metric and a per-pod target"))
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
}
if src.TargetAverageValue != nil && src.TargetAverageValue.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageValue"), src.TargetAverageValue, "must be positive"))
if src.Target.Value == nil && src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must set either a target value for metric or a per-pod target"))
}
if src.TargetValue != nil && src.TargetValue.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetValue"), src.TargetValue, "must be positive"))
if src.Target.Value != nil && src.Target.AverageValue != nil {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("target").Child("value"), "may not set both a target value for metric and a per-pod target"))
}
return allErrs
......@@ -224,12 +217,15 @@ func validateExternalSource(src *autoscaling.ExternalMetricSource, fldPath *fiel
func validatePodsSource(src *autoscaling.PodsMetricSource, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(src.MetricName) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("metricName"), "must specify a metric name"))
allErrs = append(allErrs, validateMetricIdentifier(src.Metric, fldPath.Child("metric"))...)
if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else {
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
}
if src.TargetAverageValue.Sign() != 1 {
allErrs = append(allErrs, field.Required(fldPath.Child("targetAverageValue"), "must specify a positive target value"))
if src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageValue"), "must specify a positive target averageValue"))
}
return allErrs
......@@ -241,22 +237,60 @@ func validateResourceSource(src *autoscaling.ResourceMetricSource, fldPath *fiel
if len(src.Name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a resource name"))
}
if &src.Target == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target"), "must specify a metric target"))
} else {
allErrs = append(allErrs, validateMetricTarget(src.Target, fldPath.Child("target"))...)
}
if src.TargetAverageUtilization == nil && src.TargetAverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("targetAverageUtilization"), "must set either a target raw value or a target utilization"))
if src.Target.AverageUtilization == nil && src.Target.AverageValue == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("target").Child("averageUtilization"), "must set either a target raw value or a target utilization"))
}
if src.TargetAverageUtilization != nil && *src.TargetAverageUtilization < 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageUtilization"), src.TargetAverageUtilization, "must be greater than 0"))
if src.Target.AverageUtilization != nil && src.Target.AverageValue != nil {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("target").Child("averageValue"), "may not set both a target raw value and a target utilization"))
}
if src.TargetAverageUtilization != nil && src.TargetAverageValue != nil {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("targetAverageValue"), "may not set both a target raw value and a target utilization"))
return allErrs
}
func validateMetricTarget(mt autoscaling.MetricTarget, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(mt.Type) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("type"), "must specify a metric target type"))
}
if src.TargetAverageValue != nil && src.TargetAverageValue.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetAverageValue"), src.TargetAverageValue, "must be positive"))
if mt.Type != autoscaling.UtilizationMetricType &&
mt.Type != autoscaling.ValueMetricType &&
mt.Type != autoscaling.AverageValueMetricType {
allErrs = append(allErrs, field.Invalid(fldPath.Child("type"), mt.Type, "must be either Utilization, Value, or AverageValue"))
}
if mt.Value != nil && mt.Value.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("value"), mt.Value, "must be positive"))
}
if mt.AverageValue != nil && mt.AverageValue.Sign() != 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("averageValue"), mt.AverageValue, "must be positive"))
}
if mt.AverageUtilization != nil && *mt.AverageUtilization < 1 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("averageUtilization"), mt.AverageUtilization, "must be greater than 0"))
}
return allErrs
}
func validateMetricIdentifier(id autoscaling.MetricIdentifier, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if len(id.Name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("name"), "must specify a metric name"))
} else {
for _, msg := range pathvalidation.IsValidPathSegmentName(id.Name) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("name"), id.Name, msg))
}
}
return allErrs
}
......@@ -21,7 +21,6 @@ limitations under the License.
package autoscaling
import (
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
......@@ -44,21 +43,8 @@ func (in *CrossVersionObjectReference) DeepCopy() *CrossVersionObjectReference {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExternalMetricSource) DeepCopyInto(out *ExternalMetricSource) {
*out = *in
if in.MetricSelector != nil {
in, out := &in.MetricSelector, &out.MetricSelector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
if in.TargetValue != nil {
in, out := &in.TargetValue, &out.TargetValue
x := (*in).DeepCopy()
*out = &x
}
if in.TargetAverageValue != nil {
in, out := &in.TargetAverageValue, &out.TargetAverageValue
x := (*in).DeepCopy()
*out = &x
}
out.Metric = in.Metric
in.Target.DeepCopyInto(&out.Target)
return
}
......@@ -75,17 +61,8 @@ func (in *ExternalMetricSource) DeepCopy() *ExternalMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExternalMetricStatus) DeepCopyInto(out *ExternalMetricStatus) {
*out = *in
if in.MetricSelector != nil {
in, out := &in.MetricSelector, &out.MetricSelector
*out = new(v1.LabelSelector)
(*in).DeepCopyInto(*out)
}
out.CurrentValue = in.CurrentValue.DeepCopy()
if in.CurrentAverageValue != nil {
in, out := &in.CurrentAverageValue, &out.CurrentAverageValue
x := (*in).DeepCopy()
*out = &x
}
out.Metric = in.Metric
in.Current.DeepCopyInto(&out.Current)
return
}
......@@ -246,6 +223,22 @@ func (in *HorizontalPodAutoscalerStatus) DeepCopy() *HorizontalPodAutoscalerStat
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricIdent) DeepCopyInto(out *MetricIdent) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricIdent.
func (in *MetricIdent) DeepCopy() *MetricIdent {
if in == nil {
return nil
}
out := new(MetricIdent)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricSpec) DeepCopyInto(out *MetricSpec) {
*out = *in
if in.Object != nil {
......@@ -318,10 +311,73 @@ func (in *MetricStatus) DeepCopy() *MetricStatus {
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricTarget) DeepCopyInto(out *MetricTarget) {
*out = *in
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
if in.AverageUtilization != nil {
in, out := &in.AverageUtilization, &out.AverageUtilization
*out = new(int32)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricTarget.
func (in *MetricTarget) DeepCopy() *MetricTarget {
if in == nil {
return nil
}
out := new(MetricTarget)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MetricValueStatus) DeepCopyInto(out *MetricValueStatus) {
*out = *in
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
if in.AverageUtilization != nil {
in, out := &in.AverageUtilization, &out.AverageUtilization
*out = new(int32)
**out = **in
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricValueStatus.
func (in *MetricValueStatus) DeepCopy() *MetricValueStatus {
if in == nil {
return nil
}
out := new(MetricValueStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) {
*out = *in
out.Target = in.Target
out.TargetValue = in.TargetValue.DeepCopy()
out.DescribedObject = in.DescribedObject
in.Target.DeepCopyInto(&out.Target)
out.Metric = in.Metric
return
}
......@@ -338,8 +394,9 @@ func (in *ObjectMetricSource) DeepCopy() *ObjectMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) {
*out = *in
out.Target = in.Target
out.CurrentValue = in.CurrentValue.DeepCopy()
out.Metric = in.Metric
in.Current.DeepCopyInto(&out.Current)
out.DescribedObject = in.DescribedObject
return
}
......@@ -356,7 +413,8 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) {
*out = *in
out.TargetAverageValue = in.TargetAverageValue.DeepCopy()
out.Metric = in.Metric
in.Target.DeepCopyInto(&out.Target)
return
}
......@@ -373,7 +431,8 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) {
*out = *in
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
out.Metric = in.Metric
in.Current.DeepCopyInto(&out.Current)
return
}
......@@ -390,16 +449,7 @@ func (in *PodsMetricStatus) DeepCopy() *PodsMetricStatus {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceMetricSource) DeepCopyInto(out *ResourceMetricSource) {
*out = *in
if in.TargetAverageUtilization != nil {
in, out := &in.TargetAverageUtilization, &out.TargetAverageUtilization
*out = new(int32)
**out = **in
}
if in.TargetAverageValue != nil {
in, out := &in.TargetAverageValue, &out.TargetAverageValue
x := (*in).DeepCopy()
*out = &x
}
in.Target.DeepCopyInto(&out.Target)
return
}
......@@ -416,12 +466,7 @@ func (in *ResourceMetricSource) DeepCopy() *ResourceMetricSource {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceMetricStatus) DeepCopyInto(out *ResourceMetricStatus) {
*out = *in
if in.CurrentAverageUtilization != nil {
in, out := &in.CurrentAverageUtilization, &out.CurrentAverageUtilization
*out = new(int32)
**out = **in
}
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
in.Current.DeepCopyInto(&out.Current)
return
}
......
......@@ -257,6 +257,16 @@ message ObjectMetricSource {
// targetValue is the target value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetValue = 3;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 4;
// 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 = 5;
}
// ObjectMetricStatus indicates the current value of a metric describing a
......@@ -270,6 +280,16 @@ message ObjectMetricStatus {
// currentValue is the current value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentValue = 3;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 4;
// 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 = 5;
}
// PodsMetricSource indicates how to scale on a metric describing each pod in
......@@ -283,6 +303,15 @@ message PodsMetricSource {
// targetAverageValue is the target value of the average of the
// metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetAverageValue = 2;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 3;
// value is the target value of the metric (as a quantity).
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity value = 4;
}
// PodsMetricStatus indicates the current value of a metric describing each pod in
......@@ -294,6 +323,15 @@ message PodsMetricStatus {
// currentAverageValue is the current value of the average of the
// metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentAverageValue = 2;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 3;
// value is the current value of the metric (as a quantity)
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity value = 4;
}
// ResourceMetricSource indicates how to scale on a resource metric known to
......
......@@ -148,10 +148,12 @@ func (MetricStatus) SwaggerDoc() map[string]string {
}
var map_ObjectMetricSource = map[string]string{
"": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).",
"target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.",
"targetValue": "targetValue is the target value of the metric (as a quantity).",
"": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).",
"target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.",
"targetValue": "targetValue is the target value of the metric (as a quantity).",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"averageValue": "averageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
}
func (ObjectMetricSource) SwaggerDoc() map[string]string {
......@@ -163,6 +165,8 @@ var map_ObjectMetricStatus = map[string]string{
"target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.",
"currentValue": "currentValue is the current value of the metric (as a quantity).",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"averageValue": "averageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
}
func (ObjectMetricStatus) SwaggerDoc() map[string]string {
......@@ -173,6 +177,8 @@ var map_PodsMetricSource = map[string]string{
"": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.",
"metricName": "metricName is the name of the metric in question",
"targetAverageValue": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"value": "value is the target value of the metric (as a quantity).",
}
func (PodsMetricSource) SwaggerDoc() map[string]string {
......@@ -183,6 +189,8 @@ var map_PodsMetricStatus = map[string]string{
"": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).",
"metricName": "metricName is the name of the metric in question",
"currentAverageValue": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"value": "value is the current value of the metric (as a quantity)",
}
func (PodsMetricStatus) SwaggerDoc() map[string]string {
......
......@@ -311,6 +311,11 @@ func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) {
*out = *in
out.Target = in.Target
out.TargetValue = in.TargetValue.DeepCopy()
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return
}
......@@ -329,6 +334,11 @@ func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) {
*out = *in
out.Target = in.Target
out.CurrentValue = in.CurrentValue.DeepCopy()
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return
}
......@@ -346,6 +356,11 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus {
func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) {
*out = *in
out.TargetAverageValue = in.TargetAverageValue.DeepCopy()
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
return
}
......@@ -363,6 +378,11 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource {
func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) {
*out = *in
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
return
}
......
......@@ -186,6 +186,7 @@ message HorizontalPodAutoscalerStatus {
optional int32 desiredReplicas = 4;
// currentMetrics is the last read state of the metrics used by this autoscaler.
// +optional
repeated MetricStatus currentMetrics = 5;
// conditions is the set of conditions required for this autoscaler to scale its target,
......@@ -273,6 +274,16 @@ message ObjectMetricSource {
// targetValue is the target value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetValue = 3;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 4;
// 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 = 5;
}
// ObjectMetricStatus indicates the current value of a metric describing a
......@@ -286,6 +297,16 @@ message ObjectMetricStatus {
// currentValue is the current value of the metric (as a quantity).
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentValue = 3;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 4;
// 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 = 5;
}
// PodsMetricSource indicates how to scale on a metric describing each pod in
......@@ -299,6 +320,15 @@ message PodsMetricSource {
// targetAverageValue is the target value of the average of the
// metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity targetAverageValue = 2;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 3;
// value is the target value of the metric (as a quantity).
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity value = 4;
}
// PodsMetricStatus indicates the current value of a metric describing each pod in
......@@ -310,6 +340,15 @@ message PodsMetricStatus {
// currentAverageValue is the current value of the average of the
// metric across all relevant pods (as a quantity)
optional k8s.io.apimachinery.pkg.api.resource.Quantity currentAverageValue = 2;
// selector is the selector for the given metric
// it is the string-encoded form of a standard kubernetes label selector
// +optional
optional string selector = 3;
// value is the current value of the metric (as a quantity)
// +optional
optional k8s.io.apimachinery.pkg.api.resource.Quantity value = 4;
}
// ResourceMetricSource indicates how to scale on a resource metric known to
......
......@@ -216,6 +216,7 @@ type HorizontalPodAutoscalerStatus struct {
DesiredReplicas int32 `json:"desiredReplicas" protobuf:"varint,4,opt,name=desiredReplicas"`
// currentMetrics is the last read state of the metrics used by this autoscaler.
// +optional
CurrentMetrics []MetricStatus `json:"currentMetrics" protobuf:"bytes,5,rep,name=currentMetrics"`
// conditions is the set of conditions required for this autoscaler to scale its target,
......
......@@ -149,10 +149,12 @@ func (MetricStatus) SwaggerDoc() map[string]string {
}
var map_ObjectMetricSource = map[string]string{
"": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).",
"target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.",
"targetValue": "targetValue is the target value of the metric (as a quantity).",
"": "ObjectMetricSource indicates how to scale on a metric describing a kubernetes object (for example, hits-per-second on an Ingress object).",
"target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.",
"targetValue": "targetValue is the target value of the metric (as a quantity).",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"averageValue": "averageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
}
func (ObjectMetricSource) SwaggerDoc() map[string]string {
......@@ -164,6 +166,8 @@ var map_ObjectMetricStatus = map[string]string{
"target": "target is the described Kubernetes object.",
"metricName": "metricName is the name of the metric in question.",
"currentValue": "currentValue is the current value of the metric (as a quantity).",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"averageValue": "averageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
}
func (ObjectMetricStatus) SwaggerDoc() map[string]string {
......@@ -174,6 +178,8 @@ var map_PodsMetricSource = map[string]string{
"": "PodsMetricSource indicates how to scale on a metric describing each pod in the current scale target (for example, transactions-processed-per-second). The values will be averaged together before being compared to the target value.",
"metricName": "metricName is the name of the metric in question",
"targetAverageValue": "targetAverageValue is the target value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"value": "value is the target value of the metric (as a quantity).",
}
func (PodsMetricSource) SwaggerDoc() map[string]string {
......@@ -184,6 +190,8 @@ var map_PodsMetricStatus = map[string]string{
"": "PodsMetricStatus indicates the current value of a metric describing each pod in the current scale target (for example, transactions-processed-per-second).",
"metricName": "metricName is the name of the metric in question",
"currentAverageValue": "currentAverageValue is the current value of the average of the metric across all relevant pods (as a quantity)",
"selector": "selector is the selector for the given metric it is the string-encoded form of a standard kubernetes label selector",
"value": "value is the current value of the metric (as a quantity)",
}
func (PodsMetricStatus) SwaggerDoc() map[string]string {
......
......@@ -322,6 +322,11 @@ func (in *ObjectMetricSource) DeepCopyInto(out *ObjectMetricSource) {
*out = *in
out.Target = in.Target
out.TargetValue = in.TargetValue.DeepCopy()
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return
}
......@@ -340,6 +345,11 @@ func (in *ObjectMetricStatus) DeepCopyInto(out *ObjectMetricStatus) {
*out = *in
out.Target = in.Target
out.CurrentValue = in.CurrentValue.DeepCopy()
if in.AverageValue != nil {
in, out := &in.AverageValue, &out.AverageValue
x := (*in).DeepCopy()
*out = &x
}
return
}
......@@ -357,6 +367,11 @@ func (in *ObjectMetricStatus) DeepCopy() *ObjectMetricStatus {
func (in *PodsMetricSource) DeepCopyInto(out *PodsMetricSource) {
*out = *in
out.TargetAverageValue = in.TargetAverageValue.DeepCopy()
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
return
}
......@@ -374,6 +389,11 @@ func (in *PodsMetricSource) DeepCopy() *PodsMetricSource {
func (in *PodsMetricStatus) DeepCopyInto(out *PodsMetricStatus) {
*out = *in
out.CurrentAverageValue = in.CurrentAverageValue.DeepCopy()
if in.Value != nil {
in, out := &in.Value, &out.Value
x := (*in).DeepCopy()
*out = &x
}
return
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment