* 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>
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/80392Fix#40
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
* 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>
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>
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>
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>
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>
* 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>