Skip to content

Commit

Permalink
HorizontalPodAutoscaler API: removal of ResourceConsumption target, i…
Browse files Browse the repository at this point in the history
…ntroduction of CPU request utilization & other cleanups.
  • Loading branch information
jszczepkowski authored and fgrzadkowski committed Oct 16, 2015
1 parent 3e5f792 commit df732f0
Show file tree
Hide file tree
Showing 19 changed files with 614 additions and 587 deletions.
76 changes: 39 additions & 37 deletions api/swagger-spec/v1beta1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,7 @@
"models": {
"v1beta1.HorizontalPodAutoscalerList": {
"id": "v1beta1.HorizontalPodAutoscalerList",
"description": "HorizontalPodAutoscalerList is a list of HorizontalPodAutoscalers.",
"description": "list of horizontal pod autoscaler objects.",
"required": [
"items"
],
Expand All @@ -2098,7 +2098,7 @@
"items": {
"$ref": "v1beta1.HorizontalPodAutoscaler"
},
"description": "Items is the list of HorizontalPodAutoscalers."
"description": "list of horizontal pod autoscaler objects."
}
}
},
Expand All @@ -2118,7 +2118,7 @@
},
"v1beta1.HorizontalPodAutoscaler": {
"id": "v1beta1.HorizontalPodAutoscaler",
"description": "HorizontalPodAutoscaler represents the configuration of a horizontal pod autoscaler.",
"description": "configuration of a horizontal pod autoscaler.",
"properties": {
"kind": {
"type": "string",
Expand All @@ -2134,11 +2134,11 @@
},
"spec": {
"$ref": "v1beta1.HorizontalPodAutoscalerSpec",
"description": "Spec defines the behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status."
"description": "behaviour of autoscaler. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status."
},
"status": {
"$ref": "v1beta1.HorizontalPodAutoscalerStatus",
"description": "Status represents the current information about the autoscaler."
"description": "current information about the autoscaler."
}
}
},
Expand Down Expand Up @@ -2200,31 +2200,29 @@
},
"v1beta1.HorizontalPodAutoscalerSpec": {
"id": "v1beta1.HorizontalPodAutoscalerSpec",
"description": "HorizontalPodAutoscalerSpec is the specification of a horizontal pod autoscaler.",
"description": "specification of a horizontal pod autoscaler.",
"required": [
"scaleRef",
"minReplicas",
"maxReplicas",
"target"
"maxReplicas"
],
"properties": {
"scaleRef": {
"$ref": "v1beta1.SubresourceReference",
"description": "ScaleRef is a reference to Scale subresource. HorizontalPodAutoscaler will learn the current resource consumption from its status, and will set the desired number of pods by modyfying its spec."
"description": "reference to Scale subresource; horizontal pod autoscaler will learn the current resource consumption from its status, and will set the desired number of pods by modifying its spec."
},
"minReplicas": {
"type": "integer",
"format": "int32",
"description": "MinReplicas is the lower limit for the number of pods that can be set by the autoscaler."
"description": "lower limit for the number of pods that can be set by the autoscaler, default 1."
},
"maxReplicas": {
"type": "integer",
"format": "int32",
"description": "MaxReplicas is the upper limit for the number of pods that can be set by the autoscaler. It cannot be smaller than MinReplicas."
"description": "upper limit for the number of pods that can be set by the autoscaler; cannot be smaller than MinReplicas."
},
"target": {
"$ref": "v1beta1.ResourceConsumption",
"description": "Target is the target average consumption of the given resource that the autoscaler will try to maintain by adjusting the desired number of pods. Currently two types of resources are supported: \"cpu\" and \"memory\"."
"cpuUtilization": {
"$ref": "v1beta1.CPUTargetUtilization",
"description": "target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified it defaults to the target CPU utilization at 80% of the requested resources."
}
}
},
Expand Down Expand Up @@ -2254,46 +2252,50 @@
}
}
},
"v1beta1.ResourceConsumption": {
"id": "v1beta1.ResourceConsumption",
"description": "ResourceConsumption is an object for specifying average resource consumption of a particular resource.",
"v1beta1.CPUTargetUtilization": {
"id": "v1beta1.CPUTargetUtilization",
"required": [
"targetPercentage"
],
"properties": {
"resource": {
"type": "string",
"description": "Resource specifies either the name of the target resource when present in the spec, or the name of the observed resource when present in the status."
},
"quantity": {
"type": "string",
"description": "Quantity specifies either the target average consumption of the resource when present in the spec, or the observed average consumption when present in the status."
"targetPercentage": {
"type": "integer",
"format": "int32",
"description": "fraction of the requested CPU that should be utilized/used, e.g. 70 means that 70% of the requested CPU should be in use."
}
}
},
"v1beta1.HorizontalPodAutoscalerStatus": {
"id": "v1beta1.HorizontalPodAutoscalerStatus",
"description": "HorizontalPodAutoscalerStatus contains the current status of a horizontal pod autoscaler",
"description": "current status of a horizontal pod autoscaler",
"required": [
"currentReplicas",
"desiredReplicas",
"currentConsumption"
"desiredReplicas"
],
"properties": {
"observedGeneration": {
"type": "integer",
"format": "int64",
"description": "most recent generation observed by this autoscaler."
},
"lastScaleTime": {
"type": "string",
"description": "last time the HorizontalPodAutoscaler scaled the number of pods; used by the autoscaler to control how often the number of pods is changed."
},
"currentReplicas": {
"type": "integer",
"format": "int32",
"description": "CurrentReplicas is the number of replicas of pods managed by this autoscaler."
"description": "current number of replicas of pods managed by this autoscaler."
},
"desiredReplicas": {
"type": "integer",
"format": "int32",
"description": "DesiredReplicas is the desired number of replicas of pods managed by this autoscaler."
"description": "desired number of replicas of pods managed by this autoscaler."
},
"currentConsumption": {
"$ref": "v1beta1.ResourceConsumption",
"description": "CurrentConsumption is the current average consumption of the given resource that the autoscaler will try to maintain by adjusting the desired number of pods. Two types of resources are supported: \"cpu\" and \"memory\"."
},
"lastScaleTimestamp": {
"type": "string",
"description": "LastScaleTimestamp is the last time the HorizontalPodAutoscaler scaled the number of pods. This is used by the autoscaler to controll how often the number of pods is changed."
"currentCPUUtilizationPercentage": {
"type": "integer",
"format": "int32",
"description": "current average CPU utilization over all pods, represented as a percentage of requested CPU, e.g. 70 means that an average pod is using now 70% of its requested CPU."
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/api/testing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
// string, which will cause tests failure.
s.APIGroup = "something"
},
func(s *extensions.HorizontalPodAutoscalerSpec, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
minReplicas := c.Rand.Int()
s.MinReplicas = &minReplicas
s.CPUUtilization = &extensions.CPUTargetUtilization{TargetPercentage: int(c.RandUint64())}
},
)
return f
}
66 changes: 36 additions & 30 deletions pkg/apis/extensions/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,11 @@ func deepCopy_extensions_APIVersion(in APIVersion, out *APIVersion, c *conversio
return nil
}

func deepCopy_extensions_CPUTargetUtilization(in CPUTargetUtilization, out *CPUTargetUtilization, c *conversion.Cloner) error {
out.TargetPercentage = in.TargetPercentage
return nil
}

func deepCopy_extensions_ClusterAutoscaler(in ClusterAutoscaler, out *ClusterAutoscaler, c *conversion.Cloner) error {
if err := deepCopy_unversioned_TypeMeta(in.TypeMeta, &out.TypeMeta, c); err != nil {
return err
Expand Down Expand Up @@ -1099,40 +1104,49 @@ func deepCopy_extensions_HorizontalPodAutoscalerList(in HorizontalPodAutoscalerL
}

func deepCopy_extensions_HorizontalPodAutoscalerSpec(in HorizontalPodAutoscalerSpec, out *HorizontalPodAutoscalerSpec, c *conversion.Cloner) error {
if in.ScaleRef != nil {
out.ScaleRef = new(SubresourceReference)
if err := deepCopy_extensions_SubresourceReference(*in.ScaleRef, out.ScaleRef, c); err != nil {
return err
}
if err := deepCopy_extensions_SubresourceReference(in.ScaleRef, &out.ScaleRef, c); err != nil {
return err
}
if in.MinReplicas != nil {
out.MinReplicas = new(int)
*out.MinReplicas = *in.MinReplicas
} else {
out.ScaleRef = nil
out.MinReplicas = nil
}
out.MinReplicas = in.MinReplicas
out.MaxReplicas = in.MaxReplicas
if err := deepCopy_extensions_ResourceConsumption(in.Target, &out.Target, c); err != nil {
return err
if in.CPUUtilization != nil {
out.CPUUtilization = new(CPUTargetUtilization)
if err := deepCopy_extensions_CPUTargetUtilization(*in.CPUUtilization, out.CPUUtilization, c); err != nil {
return err
}
} else {
out.CPUUtilization = nil
}
return nil
}

func deepCopy_extensions_HorizontalPodAutoscalerStatus(in HorizontalPodAutoscalerStatus, out *HorizontalPodAutoscalerStatus, c *conversion.Cloner) error {
out.CurrentReplicas = in.CurrentReplicas
out.DesiredReplicas = in.DesiredReplicas
if in.CurrentConsumption != nil {
out.CurrentConsumption = new(ResourceConsumption)
if err := deepCopy_extensions_ResourceConsumption(*in.CurrentConsumption, out.CurrentConsumption, c); err != nil {
return err
}
if in.ObservedGeneration != nil {
out.ObservedGeneration = new(int64)
*out.ObservedGeneration = *in.ObservedGeneration
} else {
out.CurrentConsumption = nil
out.ObservedGeneration = nil
}
if in.LastScaleTimestamp != nil {
out.LastScaleTimestamp = new(unversioned.Time)
if err := deepCopy_unversioned_Time(*in.LastScaleTimestamp, out.LastScaleTimestamp, c); err != nil {
if in.LastScaleTime != nil {
out.LastScaleTime = new(unversioned.Time)
if err := deepCopy_unversioned_Time(*in.LastScaleTime, out.LastScaleTime, c); err != nil {
return err
}
} else {
out.LastScaleTimestamp = nil
out.LastScaleTime = nil
}
out.CurrentReplicas = in.CurrentReplicas
out.DesiredReplicas = in.DesiredReplicas
if in.CurrentCPUUtilizationPercentage != nil {
out.CurrentCPUUtilizationPercentage = new(int)
*out.CurrentCPUUtilizationPercentage = *in.CurrentCPUUtilizationPercentage
} else {
out.CurrentCPUUtilizationPercentage = nil
}
return nil
}
Expand Down Expand Up @@ -1389,14 +1403,6 @@ func deepCopy_extensions_ReplicationControllerDummy(in ReplicationControllerDumm
return nil
}

func deepCopy_extensions_ResourceConsumption(in ResourceConsumption, out *ResourceConsumption, c *conversion.Cloner) error {
out.Resource = in.Resource
if err := deepCopy_resource_Quantity(in.Quantity, &out.Quantity, c); err != nil {
return err
}
return nil
}

func deepCopy_extensions_RollingUpdateDeployment(in RollingUpdateDeployment, out *RollingUpdateDeployment, c *conversion.Cloner) error {
if err := deepCopy_util_IntOrString(in.MaxUnavailable, &out.MaxUnavailable, c); err != nil {
return err
Expand Down Expand Up @@ -1586,6 +1592,7 @@ func init() {
deepCopy_unversioned_Time,
deepCopy_unversioned_TypeMeta,
deepCopy_extensions_APIVersion,
deepCopy_extensions_CPUTargetUtilization,
deepCopy_extensions_ClusterAutoscaler,
deepCopy_extensions_ClusterAutoscalerList,
deepCopy_extensions_ClusterAutoscalerSpec,
Expand Down Expand Up @@ -1620,7 +1627,6 @@ func init() {
deepCopy_extensions_PodSelector,
deepCopy_extensions_PodSelectorRequirement,
deepCopy_extensions_ReplicationControllerDummy,
deepCopy_extensions_ResourceConsumption,
deepCopy_extensions_RollingUpdateDeployment,
deepCopy_extensions_Scale,
deepCopy_extensions_ScaleSpec,
Expand Down
Loading

0 comments on commit df732f0

Please sign in to comment.