Commit Graph

132 Commits (5e3f3b35e0b46bc3a3d35c4986220f36777431c2)

Author SHA1 Message Date
Kubernetes Prow Robot a4e3a5cb52
Merge pull request #71561 from anjensan/hpa-fix-current-metrics
Fix 'currentMetrics' field for HPA with 'AverageValue' target type
2019-02-04 03:34:52 -08:00
Kubernetes Prow Robot a3f74bd583
Merge pull request #72872 from arjunrn/object-average-value
Added functionality for specifying target average value for object me…
2019-02-01 06:31:50 -08:00
Arjun Naik c99d505001 Added functionality to use target average value for object metrics
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
2019-01-23 21:00:05 +01:00
Krzysztof Jastrzebski 7498c14218 Update comments in Horizontal Pod Autoscaler Controller. 2019-01-07 10:06:21 +01:00
Krzysztof Jastrzebski c6ebd126a7 Add request processing HPA into the queue after processing is finished.
This fixes a bug with skipping request inserted by resync because previous one hasn't processed yet.
2019-01-04 11:59:57 +01:00
danielqsj 3c055aa4b4 Fix typos like limitting 2018-12-04 11:01:40 +08:00
Andrei Zhlobich a8c58bcd24 Fix updating 'currentMetrics' field for HPA with 'AverageValue' target 2018-11-29 11:50:33 +01:00
Davanum Srinivas 954996e231
Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135
2018-11-10 07:50:31 -05:00
Christoph Blecker 97b2992dc1
Update gofmt for go1.11 2018-10-05 12:59:38 -07:00
Joachim Bartosik 7d7c48a647 HPA stabilizes initial recommendation
HPA will treat initial size of autoscalee to avoid hastily overriding
recomendations made by HPA (if HPA set size and then was restarted) or by user
(initial size should be treated as human-generated recommendation).
2018-09-19 14:54:55 +02:00
Krzysztof Jastrzebski 985ba931b1 Use informer cache instead of active pod gets in HPA controller. 2018-09-05 11:31:27 +02:00
Krzysztof Jastrzebski 958cba1c82 Replace scale down forbidden window
Replacement is scale down stabilization window. HPA will scale down only
    to max of recommendations it made during that window. More details in

    https://docs.google.com/document/d/1IdG3sqgCEaRV3urPLA29IDudCufD89RYCohfBPNeWIM
2018-08-31 20:24:38 +02:00
Mike Dame c7102ee5dc Implement autoscaling/v2beta2 features in HPA controller 2018-08-27 11:07:52 -04:00
liangwenguo 8f8a7bb83f make the log more readable 2018-08-07 10:00:31 +08:00
Joachim Bartosik 7681c284f5 Remove UpscaleForbiddenWindow
Instead discard metric values for pods that are unready and have never
been ready (they may report misleading values, the original reason for
introducing scale up forbidden window).

Use per pod metric when pod is:
- Ready, or
- Not ready but creation timestamp and last readiness change are more
  than 10s apart.

In the latter case we asume the pod was ready but later became unready.
We want to use metrics for such pods because sometimes such pods are
unready because they were getting too much load.
2018-08-01 17:47:23 +02:00
Joachim Bartosik 9b91a89f3d Chop computeReplicasForMetrics to smaller pieces 2018-07-18 17:09:20 +02:00
David Eads 9a48066749 update restmapping to indicate fully qualified resource 2018-05-01 16:34:49 -04:00
Mikhail Mazurskiy 468655b76a
Use typed events client directly 2018-04-01 18:57:29 +10:00
mattjmcnaughton d33494d459 `GetExternalMetricReplicas` ignores unready pods
Similar to the change we made for `GetObjectMetricReplicas` in the
previous commit. Ensure that `GetExternalMetricReplicas` does not
include unready pods when its determining how many replica it desires.
Including unready pods can lead to over-scaling.

We did not change the behavior of `GetExternalPerPodMetricReplicas`, as
it is slightly less clear what is the desired behavior. We did make some
small naming refactorings to this method, which will make it easier to
ignore unready pods if we decide we want to.
2018-03-13 22:27:28 -04:00
mattjmcnaughton 7e3bce7b3e `GetObjectMetricReplicas` ignores unready pods
Previously, when `GetObjectMetricReplicas` calculated the desired
replica count, it multiplied the usage ratio by the current number of replicas.
This method caused over-scaling when there were pods that were not ready
for a long period of time. For example, if there were pods A, B, and C,
and only pod A was ready, and the usage ratio was 500%, we would
previously specify 15 pods as the desired replicas (even though really
only one pod was handling the load).

After this change, we now multiple the usage
ratio by the number of ready pods for `GetObjectMetricReplicas`.
In the example above, we'd only desire 5 replica pods.

This change gives `GetObjectMetricReplicas` the same behavior as the
other replica calculator methods. Only `GetExternalMetricReplicas` and
`GetExternalPerPodMetricRepliacs` still allow unready pods to impact the
number of desired replicas. I will fix this issue in the following
commit.
2018-03-07 08:13:01 -05:00
Aleksandra Malinowska e58411c600 Implement external metrics in HPA 2018-02-27 14:10:29 +01:00
Matt Brown 151a7d2731 correct typo in HorizontalPodAutoscaler status condition
"succesfully" => "successfully"
2018-01-29 13:01:43 -05:00
mattjmcnaughton e74838b6ab Refactor `reconcileAutoscaler` method in hpa
There have been a couple of recent bugs in the "normalizing" part of the
`reconcileAutoscaler` method. This part of the code base is responsible
for, among other things, taking the suggested desired replicas based on
the metrics, ensuring it conforms to certain conditions, and updating it
if it does not. Isolate the part that converts the desired replicas
based on a given set of rules into its own function.

We are refactoring this part of the code base to make the logic simpler
and to make it easier to write unit tests.
2017-11-16 09:42:49 -05:00
Dr. Stefan Schimanski 2b201ead11 Fix and update comment with api.Scheme 2017-10-30 19:54:02 +01:00
Kubernetes Submit Queue ca8d97d673 Merge pull request #53743 from DirectXMan12/feature/polymorphic-scale-client
Automatic merge from submit-queue (batch tested with PRs 53743, 53564). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Polymorphic Scale Client

This PR introduces a polymorphic scale client based on discovery information that's able to scale scalable resources in arbitrary group-versions, as long as they present the scale subresource in their discovery information.

Currently, it supports `extensions/v1beta1.Scale` and `autoscaling/v1.Scale`, but supporting other versions of scale if/when we produce them should be fairly trivial.

It also updates the HPA to use this client, meaning the HPA will now work on any scalable resource, not just things in the `extensions/v1beta1` API group.

**Release note**:
```release-note
Introduces a polymorphic scale client, allowing HorizontalPodAutoscalers to properly function on scalable resources in any API group.
```

Unblocks #29698
Unblocks #38756
Unblocks #49504 
Fixes #38810
2017-10-23 13:39:07 -07:00
Solly Ross d2b41120ea Make HPA controller use polymorphic scale client
This updates the HPA controller to use the polymorphic scale client from
client-go.  This should enable HPAs to work with arbitrary scalable
resources, instead of just those in the extensions API group (meaning we
can deprecate the copy of ReplicationController in extensions/v1beta1).
It also means that the HPA controller now pays attention to the
APIVersion field in `scaleTargetRef` (more specifically, the group part
of it).

Note that currently, discovery information on which resources are
available where is only fetched once (the first time that it's
requested).  In the future, we may want a refreshing discovery REST
mapper.
2017-10-19 13:21:02 -04:00
hzxuzhonghu 96b48d4386 add event broadcaster logging for all contoller managers 2017-10-19 09:18:43 +08:00
Dr. Stefan Schimanski 7773a30f67 pkg/api/legacyscheme: fixup imports 2017-10-18 17:23:55 +02:00
Kubernetes Submit Queue 03cb11f020 Merge pull request #52275 from mattjmcnaughton/mattjmcnaughton/18155-hpa-tolerance-should-be-flag
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Make HPA tolerance a flag

**What this PR does / why we need it**:
Make HPA tolerance configurable as a flag. This change allows us to use
different tolerance values in production/testing.

**Which issue this PR fixes**: 
Fixes #18155

**Release note:**
```release-note
Control HPA tolerance through the `horizontal-pod-autoscaler-tolerance` flag.
```

Signed-off-by: mattjmcnaughton <mattjmcnaughton@gmail.com>
2017-10-16 16:47:43 -07:00
mattjmcnaughton 75c38777ad Fix hpa scaling above max replicas w/ scaleUpLimit
Fix #53670

Fix a bug where `desiredReplicas` could be greater than `maxReplicas`
if the original value for `desiredReplicas > scaleUpLimit` and
`scaleUpLimit > maxReplicas`. Previously, when that happened, we would
scale up to `scaleUpLimit`, and then in the next auto-scaling run, scale
down to `maxReplicas`. Address this issue and introduce a regression
test.
2017-10-11 08:35:31 -04:00
mattjmcnaughton dd5be2a882 Make unnecessary hpa public funcs private
Previously
`pkg.controller.podautoscaler.UnsafeConvertToVersion` was
exported. However, it was never used outside of the `podautoscaler`
package. Make it private to prevent confusion.

Additionally, move the two private functions in `horizontal.go` to be
with the other private functions at the bottom of the file - imho its
more readable than having them directly at the top of the file, before
the public type and function definitions.
2017-10-10 08:03:25 -04:00
mattjmcnaughton abd46684d4 Make HPA tolerance a flag
Fix #18155

Make HPA tolerance configurable as a flag. This change allows us to use
different tolerance values in production/testing.

Signed-off-by: mattjmcnaughton <mattjmcnaughton@gmail.com>
2017-09-28 22:01:51 -04:00
mattjmcnaughton fa56e879c7 Improve `horizontal.go` documentation
Resolve the remaining `golint` errors in the
`pkg/controller/podautoscaler` package by improving the documentation
in `horizontal.go`. Now all public methods have comments.
2017-09-25 09:25:05 -04:00
mattjmcnaughton dc8df2701b Fix incorrect status msg in podautoscaler
Fix #49256

When `ScalingLimited = true` for the `hpa`, there is an accompanying
status message, describing why scaling is limited. Previously if the desired
replica count was 0, and spec.minReplicas > 0, the status message
indicated "the desired replica count was less than the min replica
count". This was particularly confusing when `spec.MinReplicas = 1`. If
there was no `spec.minReplicas`, then the status message indicated "the
desired replica count was zero" which is more informative.

Update the calculation of status message so that if the desired replica
count is 0, we always display the clearer "the desired replica count was
zero" status message, even if spec.minReplicas > 0.

Signed-off-by: mattjmcnaughton <mattjmcnaughton@gmail.com>
2017-09-13 09:27:38 -04:00
Solly Ross c8690f367b Move consumers of autoscaling/v2alpha1 to v2beta1
This commit updates consumers (mainly the HPA controller, but also the
kubectl printers) of autoscaling/v2alpha1 to autoscaling/v2beta1.
2017-09-05 17:49:30 -04:00
Dr. Stefan Schimanski 1d053c4f7c controllers: simplify deepcopy calls 2017-08-29 19:21:24 +02:00
supereagle adc0eef43e remove duplicated import and wrong alias name of api package 2017-07-25 10:04:25 +08:00
Jacob Simpson a765b8cfca Migrate api.Scheme to scheme.Scheme 2017-07-17 15:05:38 -07:00
Jacob Simpson 29c1b81d4c Scripted migration from clientset_generated to client-go. 2017-07-17 15:05:37 -07:00
Johannes Würbach a99d988e3b
hpa: Prevent scaling below MinReplicas if desiredReplicas is zero 2017-07-17 09:32:06 +02:00
Chao Xu 60604f8818 run hack/update-all 2017-06-22 11:31:03 -07:00
Chao Xu f2d3220a11 run root-rewrite-import-client-go-api-types 2017-06-22 11:30:59 -07:00
Chao Xu cde4772928 run ./root-rewrite-all-other-apis.sh, then run make all, pkg/... compiles 2017-06-22 11:30:52 -07:00
Chao Xu f4989a45a5 run root-rewrite-v1-..., compile 2017-06-22 10:25:57 -07:00
Solly Ross 00a19f1289 HPA: only send updates when the status has changed
This commit only sends updates if the status has actually changed.
Since the HPA runs at a regular interval, this should reduce the volume
of writes, especially on short HPA intervals with relatively constant
metrics.
2017-06-07 10:57:19 -04:00
Solly Ross 1334b81d20 Make HPA controller set HPA status conditions
This commit causes the HPA controller to set a variety of status
conditions using the new `Status.Conditions` field of
autoscaling/v2alpha1.  These provide insight into the current state
of the HPA, and generally correspond to similar events being emitted.
2017-06-05 11:21:30 -04:00
Kubernetes Submit Queue 6c8cb33fb3 Merge pull request #42101 from Dmitry1987/feature/hpa-upscale-downscale-delay-configurable
Automatic merge from submit-queue (batch tested with PRs 44862, 42241, 42101, 43181, 44147)

Feature/hpa upscale downscale delay configurable

**What this PR does / why we need it**:
Makes "upscale forbidden window" and "downscale forbidden window"  duration configurable in arguments of kube-controller-manager. Those are options of horizontal pod autoscaler.

**Special notes for your reviewer**:
Please have a look @DirectXMan12 , the PR as discussed in Slack.

**Release note**:
```
Make "upscale forbidden window" and "downscale forbidden window"  duration configurable in arguments of kube-controller-manager. Those are options of horizontal pod autoscaler. Right now are hardcoded 3 minutes for upscale, and 5 minutes to downscale.  But sometimes cluster administrator might want to change this for his own needs.
```
2017-04-24 19:39:42 -07:00
Andy Goldstein e63fcf708d Make controller Run methods consistent
- startup/shutdown logging
- wait for cache sync logging
- defer utilruntime.HandleCrash()
- wait for stop channel before exiting
2017-04-14 07:27:45 -04:00
Kubernetes Submit Queue ba349794ab Merge pull request #39139 from bruceauyeung/k8s-branch-small-code-improvements-and-fix-some-typos
Automatic merge from submit-queue

small code improvements and fix some typos

Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>

**What this PR does / why we need it**:

1. eliminate unnecessary extra scale up limit calculation
2. eliminate unnecessary extra pods length computation
3. fix some typos
2017-04-07 02:22:05 -07:00
Dmitry1987 965dab366b make hpa upscale and downscale delay window configurable 2017-03-24 18:01:04 +00:00