kubernetes/pkg/controller/podautoscaler
Kubernetes Submit Queue 663551bebd
Merge pull request #67252 from jbartosik/metric-sanitization
Automatic merge from submit-queue (batch tested with PRs 66916, 67252, 67794, 67619, 67328). 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>.

Fix HPA sample sanitization

**What this PR does / why we need it**: @mwielgus pointed out a case when HPA fails as a result of my changes to HPA algorithm:
- Have pods that use a lot of CPU during initilization, become ready right after they initialize,
- Trigger a scale up,
- When new pods become ready will will count their usage (even though it's not related to any work that needs doing),
- This triggers another scale up, even though existing pods can handle work, no problem.

The fix is:
- Use all samples for non-cpu metrics.
- Only use CPU samples if:
  - Pod is ready and was started more than 2 minutes ago, or
  - Pod is unready and last readiness change happened more than 10s after it was started.

Reasoning behind this in: https://docs.google.com/document/d/1UdtYedhmCxjaJIQi6hwJMY0eHQQKxlVD8lSHZC1BPOA/edit

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:

**Special notes for your reviewer**:

**Release note**:
```release-note
Replace scale up forbidden window with disregarding CPU samples collected when pod was initializing.
```
2018-08-24 15:25:07 -07:00
..
metrics Update external k8s.io/metrics imports 2018-07-02 10:44:18 +02:00
BUILD Improve HPA sample sanitization 2018-08-21 16:22:06 +02:00
doc.go Use Go canonical import paths 2016-07-16 13:48:21 -04:00
horizontal_test.go Make HPA more configurable 2018-08-24 13:13:02 +02:00
horizontal.go make the log more readable 2018-08-07 10:00:31 +08:00
legacy_horizontal_test.go Make HPA more configurable 2018-08-24 13:13:02 +02:00
legacy_replica_calculator_test.go Make HPA more configurable 2018-08-24 13:13:02 +02:00
OWNERS Add Labels to various OWNERS files 2018-08-21 13:59:08 -04:00
rate_limitters.go Fix golint errors in pkg/controller/podautoscaler 2017-09-09 14:53:34 -04:00
replica_calculator_test.go Make HPA more configurable 2018-08-24 13:13:02 +02:00
replica_calculator.go Make HPA more configurable 2018-08-24 13:13:02 +02:00