lib/promscrape/discovery/kubernetes: rename role: endpointslices to role: endpointslice to be consistent with Prometheus

See 2ec6c7dbb8/discovery/kubernetes/kubernetes.go (L99)
This commit is contained in:
Aliaksandr Valialkin 2021-08-29 11:23:06 +03:00
parent 327034b54f
commit ca61d7c82b
4 changed files with 14 additions and 13 deletions

View File

@ -17,6 +17,7 @@ sort: 15
* FEATURE: add `quantiles("quantileLabel", phi1, ..., phiN, q)` aggregate function to [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html), which calculates the given `phi*` quantiles over time series returned by `q`. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1573). * FEATURE: add `quantiles("quantileLabel", phi1, ..., phiN, q)` aggregate function to [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html), which calculates the given `phi*` quantiles over time series returned by `q`. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1573).
* BUGFIX: rename `sign` function to `sgn` in order to be consistent with PromQL. See [this pull request from Prometheus](https://github.com/prometheus/prometheus/pull/8457). * BUGFIX: rename `sign` function to `sgn` in order to be consistent with PromQL. See [this pull request from Prometheus](https://github.com/prometheus/prometheus/pull/8457).
* BUGFIX: vmagent: rename `role: endpointslices` to `role: endpointslice` in [kubernetes_sd_config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config) in order to be consistent with Prometheus. See [the corresponding code in Prometheus](https://github.com/prometheus/prometheus/blob/2ec6c7dbb82b72834021e01f1773eb90a67a371f/discovery/kubernetes/kubernetes.go#L99).
* BUGFIX: improve the detection of the needed free space for background merge operation. This should prevent from possible out of disk space crashes during big merges. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1560). * BUGFIX: improve the detection of the needed free space for background merge operation. This should prevent from possible out of disk space crashes during big merges. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1560).
* BUGFIX: vmauth: remove trailing slash from the full url before requesting it from the backend. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1554). * BUGFIX: vmauth: remove trailing slash from the full url before requesting it from the backend. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1554).
* BUGFIX: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): fix timeout error when snapshot takes longer than 10 seconds. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1571). * BUGFIX: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): fix timeout error when snapshot takes longer than 10 seconds. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1571).

View File

@ -16,9 +16,9 @@ type apiConfig struct {
func newAPIConfig(sdc *SDConfig, baseDir string, swcFunc ScrapeWorkConstructorFunc) (*apiConfig, error) { func newAPIConfig(sdc *SDConfig, baseDir string, swcFunc ScrapeWorkConstructorFunc) (*apiConfig, error) {
switch sdc.Role { switch sdc.Role {
case "node", "pod", "service", "endpoints", "endpointslices", "ingress": case "node", "pod", "service", "endpoints", "endpointslice", "ingress":
default: default:
return nil, fmt.Errorf("unexpected `role`: %q; must be one of `node`, `pod`, `service`, `endpoints`, `endpointslices` or `ingress`", sdc.Role) return nil, fmt.Errorf("unexpected `role`: %q; must be one of `node`, `pod`, `service`, `endpoints`, `endpointslice` or `ingress`", sdc.Role)
} }
ac, err := sdc.HTTPClientConfig.NewConfig(baseDir) ac, err := sdc.HTTPClientConfig.NewConfig(baseDir)
if err != nil { if err != nil {

View File

@ -263,8 +263,8 @@ func (gw *groupWatcher) getObjectByRoleLocked(role, namespace, name string) obje
} }
func (gw *groupWatcher) startWatchersForRole(role string, aw *apiWatcher) { func (gw *groupWatcher) startWatchersForRole(role string, aw *apiWatcher) {
if role == "endpoints" || role == "endpointslices" { if role == "endpoints" || role == "endpointslice" {
// endpoints and endpointslices watchers query pod and service objects. So start watchers for these roles as well. // endpoints and endpointslice watchers query pod and service objects. So start watchers for these roles as well.
gw.startWatchersForRole("pod", nil) gw.startWatchersForRole("pod", nil)
gw.startWatchersForRole("service", nil) gw.startWatchersForRole("service", nil)
} }
@ -285,7 +285,7 @@ func (gw *groupWatcher) startWatchersForRole(role string, aw *apiWatcher) {
if needStart { if needStart {
uw.reloadObjects() uw.reloadObjects()
go uw.watchForUpdates() go uw.watchForUpdates()
if role == "endpoints" || role == "endpointslices" { if role == "endpoints" || role == "endpointslice" {
// Refresh endpoints and enpointslices targets in background, since they depend on other object types such as pod and service. // Refresh endpoints and enpointslices targets in background, since they depend on other object types such as pod and service.
// This should fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1240 . // This should fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1240 .
go func() { go func() {
@ -754,7 +754,7 @@ func getObjectTypeByRole(role string) string {
return "services" return "services"
case "endpoints": case "endpoints":
return "endpoints" return "endpoints"
case "endpointslices": case "endpointslice":
return "endpointslices" return "endpointslices"
case "ingress": case "ingress":
return "ingresses" return "ingresses"
@ -774,7 +774,7 @@ func getObjectParsersForRole(role string) (parseObjectFunc, parseObjectListFunc)
return parseService, parseServiceList return parseService, parseServiceList
case "endpoints": case "endpoints":
return parseEndpoints, parseEndpointsList return parseEndpoints, parseEndpointsList
case "endpointslices": case "endpointslice":
return parseEndpointSlice, parseEndpointSliceList return parseEndpointSlice, parseEndpointSliceList
case "ingress": case "ingress":
return parseIngress, parseIngressList return parseIngress, parseIngressList

View File

@ -128,11 +128,11 @@ func TestGetAPIPathsWithNamespaces(t *testing.T) {
"/api/v1/namespaces/y/endpoints?labelSelector=bbb", "/api/v1/namespaces/y/endpoints?labelSelector=bbb",
}) })
// role=endpointslices // role=endpointslice
f("endpointslices", nil, nil, []string{"/apis/discovery.k8s.io/v1/endpointslices"}) f("endpointslice", nil, nil, []string{"/apis/discovery.k8s.io/v1/endpointslices"})
f("endpointslices", []string{"x", "y"}, []Selector{ f("endpointslice", []string{"x", "y"}, []Selector{
{ {
Role: "endpointslices", Role: "endpointslice",
Field: "field", Field: "field",
Label: "label", Label: "label",
}, },
@ -672,11 +672,11 @@ func TestGetScrapeWorkObjects(t *testing.T) {
{ {
name: "7 endpointslices slice with 1 service update", name: "7 endpointslices slice with 1 service update",
sdc: &SDConfig{ sdc: &SDConfig{
Role: "endpointslices", Role: "endpointslice",
}, },
expectedTargetsLen: 7, expectedTargetsLen: 7,
initAPIObjectsByRole: map[string][]byte{ initAPIObjectsByRole: map[string][]byte{
"endpointslices": []byte(`{ "endpointslice": []byte(`{
"kind": "EndpointSliceList", "kind": "EndpointSliceList",
"apiVersion": "discovery.k8s.io/v1", "apiVersion": "discovery.k8s.io/v1",
"metadata": { "metadata": {