Sharding and autosharding introduced a number of manifests that are
very similar, but not identical to the standard manifests. This
introduces generating all manifests using jsonnet and moves them to
the explicit `/examples` directory.
main_test.go: Add model based test for sharding
In order to ensure a sharded system behaves equal to an unsharded
system, a model based test has been introduced. It scrapes an unsharded
setup and compares its output with the union of a sharded setup
therefore ensuring semantic equality.
kube-state-metrics does not terminate the pod on errors, so to actually
detect the errors in CI, we are adding this check by grepping for errors
in the kube-state-metrics logs.
This makes the assumption that any errors that are present in logs start
wtih the string 'E<MONTHDAY>' (e.g.: 'E0711') as this is how klog starts
all error log lines.
Since the removal of collector, this introduces both the concept of the
store and the resources instead of collectors that the user passes in.
The user facing logs and flags were not changed as that would be a
regression.
When converting a string to a byte slice, in Golang would do a full copy
which introduces memory allocations. On an HTTP scrape request WriteAll
in the metrics store component is called, which writes all cached
metrics into the given io.Writer. io.Writer takes a byte slice, whereas
metrics are cached as strings. The connect the two, the metrics store
component converts the metric strings to byte slices. This results in
`runtime.stringtoslicebyte` [1] being a prominent CPU user.
Instead of caching metrics as strings, cache them as byte slices,
removing the additional translation from the hot-path.
[1] https://golang.org/src/runtime/string.go?s=4063:4115#L145
Instead of defining the metric name both in the metric family generator
as well as the metric itself, with this patch the metric name is
injected into the metric family by the metric family generator.
This makes the rest of the packages useful to be used in a standalone
library without importing the kube-state-metrics specific collectors.
* Rename collectors -> collector package
* Rename metrics -> metric package
* Add metricFamily mocking in tests to prevent cyclic dependency.
With the different pieces being exposed, this test ensures that k-s-m
can be used as a standalone library.
Co-authored-by: Max Leonard Inden <IndenML@gmail.com>
This patch introduces a custom client go store, MetricsStore. It is
updated by a corresponding reflector. Instead of generating the
Prometheus custom metrics on demand, metrics are generated on new
Kubernetes object arrival.
In addition this patch replaces most of the logic of the Prometheus
client_golang package by its optimized custom logic to render metrics in
text format.
Next to these main changes this patch also includes:
- Documentation/design: Add performance optimization proposal
- tests/e2e.sh: Ignore "no help text" warnings by promtool
- .travis.yml: Run tests in parallel
As non of the Travis tests depend on each other, there is no reason to
run them in sequence. Instead this patch makes them run in parallel.
* Refactored kube_job_status_start_time & kube_job_status_completion_time to Gauge.
* e2e script moved to tests directory.
* Added options for e2e testsuite.
* Cleanun function in e2e.