28 Commits

Author SHA1 Message Date
Mikkel Oscar Lyderik Larsen
5bd527b698 Update client-go
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2020-06-26 18:22:38 +02:00
Mikkel Oscar Lyderik Larsen
ef24244074 Add support for networking.k8s.io
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2020-05-26 14:47:46 +02:00
Arjun
c9fa15c7d4 Updated the tests (#103)
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
2020-02-04 09:48:50 +01:00
Tomás Pinho
8e4662b26c Permit disregarding incompatible HPAs (#95)
* This commit adds a --disregard-incompatible-hpas that makes the HPA
provider stop erroring out when a collector cannot be created for a
metric in a HPA. Useful when kube-metrics-adapter runs alongside another
metrics provider. Fixes issue #94.

Signed-off-by: Tomás Pinho <me@tomaspinho.com>

* Make tests pass

Signed-off-by: Tomás Pinho <me@tomaspinho.com>

* Wraps the Plugin Not Found error in a new type that can be checked by the caller of a function to determine if its contents should be logged or added as an event to the HPA, when this HPA is incompatible.
The disregardIncompatibleHPAs is now targetting only the log or addition of the same event.

Signed-off-by: Tomás Pinho <me@tomaspinho.com>

* Invert if expression to select when we should log
CreateNewMetricsCollector errors: don't log when both conditions are true - it's not a PluginNotFoundError
and disregardIncompatibleHPAs flag is set to true. This way, if an error
is NOT PluginNotFoundError it will always be logged, and when it IS
PluginNotFoundError it will only be logged when
disregardIncompatibleHPAs is false.

Signed-off-by: Tomás Pinho <me@tomaspinho.com>

* Remove redundant "whether to"

Signed-off-by: Tomás Pinho <me@tomaspinho.com>

* Add test case for updating HPAs via HPA Provider while disregarding
incompatible HPAs.

Signed-off-by: Tomás Pinho <me@tomaspinho.com>
2020-01-30 11:33:15 +01:00
Mikkel Oscar Lyderik Larsen
9d78fff1b5 Only support autoscaling/v2beta2
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2020-01-29 15:59:20 +01:00
Mikkel Oscar Lyderik Larsen
0de5042d3d Update dependencies (#80)
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2019-10-08 16:20:47 +02:00
Mikkel Oscar Lyderik Larsen
461869c69b Fix response on no metrics found (#67)
Fixes the response from `GetMetricsBySelector` in case no metrics are
found. This issue caused a panic in kube-controller-manager:
https://github.com/kubernetes/kubernetes/pull/80392

Fix #40

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2019-07-26 20:35:17 +02:00
Mikkel Oscar Lyderik Larsen
d85fee795e Don't import v2beta2 twice
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2019-07-21 12:36:32 +02:00
Mikkel Oscar Lyderik Larsen
9a396bde68 Support autoscaling v2beta1
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2019-07-21 11:22:55 +02:00
Mikkel Oscar Lyderik Larsen
ffff8c2040 Prevent leaking collectors when HPA gets updated (#54)
* Prevent leaking collectors when HPA gets updated

This fixes an issue where collectors would be leaking when HPAs are
getting updated.

Fix this by stopping the collector started for the previous version of
the HPA.

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>

* Add tests to verify old collector is removed

Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2019-05-08 10:34:49 +02:00
Arjun Naik
888e76b748 Fix all errors from golangci-lint command
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
2019-04-27 15:54:15 +02:00
Arjun
8db22f38a3 Fixed metric labels so that metric are tagged correct. Also added nil check (#44)
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
2019-04-05 16:05:37 +02:00
Arjun
dfeae82cae Upgrade all pacakges to autoscalingv2beta2 (#39)
Signed-off-by: Arjun Naik <arjun.rn@gmail.com>
2019-04-03 10:23:52 +02:00
Muhammad Muaaz Saleem
e3ee745777 Testing multiple metrics inserts with different Group/Resources/Namesapces
Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-22 16:36:51 +01:00
Muhammad Muaaz Saleem
28b3b3b2b7 Testing inserting multiple external metric values
Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-21 18:04:55 +01:00
Muhammad Muaaz Saleem
be9b85c3cc Test errors in metric_store.go
Adding tests for error cases in metric_store.go. This will primarily
protect against regression.

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-21 17:28:00 +01:00
Muhammad Muaaz Saleem
d50771094a Making metrics TTL configurable per instance of metric store
Avoiding the global var and making metrics TTL configurable per
metric store

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-20 16:34:17 +01:00
Muhammad Muaaz Saleem
553f8b5993 Testing that metrics with TTL > now are not removed
This test mostly serves as protection against regression

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-20 11:00:13 +01:00
Muhammad Muaaz Saleem
b1745c5eed Making TTL configurable, at least globally
Making metrics expiration TTL configurable globally configurable.
This is so RemoveExpired can be tested. Not making the TTL configurable
per metric yet because it could change behaviour in production.

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-20 10:34:44 +01:00
Muhammad Muaaz Saleem
49cdca4c68 Testing expired metrics' removal
Testing that metrics get removed once expired. Tests are failing
because metric.TTL isn't configurable at the moment

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-19 23:28:06 +01:00
Muhammad Muaaz Saleem
7c8c239d18 Testing External Metrics Storage
Added a testcase for insert/list/get an external metric

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-19 15:57:51 +01:00
Muhammad Muaaz Saleem
fb1a08195d Testing GetMetricsBySelector
Adding test cases to get metrics by label selector

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-19 14:55:35 +01:00
Muhammad Muaaz Saleem
669eb2b441 Making the tests table driven
Adding test cases to insert/list/get a namespaced and a non-namespaced
resource metric

Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-19 14:10:21 +01:00
Muhammad Muaaz Saleem
7e247ce0d4 Adding a basic test for the metricStore
Signed-off-by: Muhammad Muaaz Saleem <muhammad.muaaz.saleem@zalando.de>
2018-11-15 18:05:52 +01:00
Nick Jüttner
b18acf3ed0 Adding event recorder and replace glog (#12)
Signed-off-by: Nick Jüttner <nick@zalando.de>
2018-10-24 17:27:30 +02:00
Martin Linkhorst
3e7b8ba964 Expose basic go metrics via prometheus (#11)
* feat: expose basic go metrics via prometheus

Signed-off-by: Martin Linkhorst <martin.linkhorst@zalando.de>

* feat: expose basic counter of successful and failed collections and updates

Signed-off-by: Martin Linkhorst <martin.linkhorst@zalando.de>
2018-10-19 13:40:31 +02:00
Mikkel Oscar Lyderik Larsen
1daacb0873 Rename module path from mikkeloscar -> zalando-incubator
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
2018-10-14 11:37:58 +02:00
Per Ploug
3db0cc3135 Adding boilerplate files
Signed-off-by: Per Ploug <per.ploug@zalando.de>
2018-10-08 13:17:05 +02:00