mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2024-12-22 02:56:03 +00:00
Update dependencies
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
This commit is contained in:
parent
37969486fe
commit
55ce2d8c3d
6
.github/workflows/ci.yaml
vendored
6
.github/workflows/ci.yaml
vendored
@ -7,12 +7,10 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.18'
|
||||
go-version: '^1.19'
|
||||
- run: go version
|
||||
- run: go install github.com/mattn/goveralls@latest
|
||||
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_RELEASE}
|
||||
env:
|
||||
GOLANGCI_RELEASE: v1.46.2
|
||||
- run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||
- run: make build.docker
|
||||
- run: make test
|
||||
- run: make check
|
||||
|
@ -1,19 +1,15 @@
|
||||
run:
|
||||
linters-settings:
|
||||
golint:
|
||||
min-confidence: 0.9
|
||||
concurrency: 4
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- staticcheck
|
||||
- ineffassign
|
||||
- golint
|
||||
- goimports
|
||||
- errcheck
|
||||
issues:
|
||||
exclude-rules:
|
||||
# Exclude some staticcheck messages
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: "SA9003:"
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- varcheck
|
||||
|
76
go.mod
76
go.mod
@ -1,18 +1,17 @@
|
||||
module github.com/zalando-incubator/kube-metrics-adapter
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.44.25
|
||||
github.com/aws/aws-sdk-go v1.44.94
|
||||
github.com/influxdata/influxdb-client-go v0.2.0
|
||||
github.com/kubernetes-sigs/custom-metrics-apiserver v0.0.0-20201216091021-1b9fa998bbaa
|
||||
github.com/prometheus/client_golang v1.12.2
|
||||
github.com/prometheus/common v0.34.0
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/spf13/cobra v1.4.0
|
||||
github.com/prometheus/client_golang v1.13.0
|
||||
github.com/prometheus/common v0.37.0
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
github.com/spf13/cobra v1.5.0
|
||||
github.com/spyzhov/ajson v0.7.1
|
||||
github.com/stretchr/testify v1.7.1
|
||||
github.com/szuecs/routegroup-client v0.21.0
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/szuecs/routegroup-client v0.21.1
|
||||
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20220201095549-bbdeecaa4fc1
|
||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b
|
||||
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1
|
||||
k8s.io/api v0.23.0
|
||||
k8s.io/apimachinery v0.23.0
|
||||
k8s.io/apiserver v0.23.0
|
||||
@ -21,42 +20,41 @@ require (
|
||||
k8s.io/component-base v0.23.0
|
||||
k8s.io/klog v1.0.0
|
||||
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf
|
||||
k8s.io/metrics v0.21.9
|
||||
k8s.io/metrics v0.22.12
|
||||
sigs.k8s.io/controller-tools v0.8.0
|
||||
sigs.k8s.io/custom-metrics-apiserver v1.22.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/NYTimes/gziphandler v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/blang/semver v3.5.1+incompatible // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/emicklei/go-restful v2.14.3+incompatible // indirect
|
||||
github.com/emicklei/go-restful v2.15.0+incompatible // indirect
|
||||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.1 // indirect
|
||||
github.com/go-logr/logr v1.2.2 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.19.6 // indirect
|
||||
github.com/go-openapi/swag v0.21.1 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.0 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/gobuffalo/flect v0.2.3 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/go-cmp v0.5.7 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/googleapis/gnostic v0.5.5 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||
github.com/imdario/mergo v0.3.6 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
@ -71,11 +69,12 @@ require (
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/spf13/afero v1.8.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
|
||||
go.etcd.io/etcd/client/v2 v2.305.1 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.0 // indirect
|
||||
go.opentelemetry.io/contrib v0.20.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0 // indirect
|
||||
@ -91,33 +90,32 @@ require (
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.19.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 // indirect
|
||||
golang.org/x/mod v0.5.1 // indirect
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
|
||||
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 // indirect
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
|
||||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
|
||||
golang.org/x/tools v0.1.9 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
|
||||
golang.org/x/tools v0.1.10 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
|
||||
google.golang.org/grpc v1.43.0 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect
|
||||
google.golang.org/grpc v1.47.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/apiextensions-apiserver v0.23.0 // indirect
|
||||
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
|
||||
k8s.io/klog/v2 v2.40.1 // indirect
|
||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.27 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
||||
k8s.io/klog/v2 v2.80.0 // indirect
|
||||
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 // indirect
|
||||
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
// of clientsets, like in:
|
||||
//
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
//
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
//
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
|
@ -37,14 +37,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
// AddToScheme adds all types of this clientset into the given scheme. This allows composition
|
||||
// of clientsets, like in:
|
||||
//
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
// import (
|
||||
// "k8s.io/client-go/kubernetes"
|
||||
// clientsetscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme"
|
||||
// )
|
||||
//
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
// kclientset, _ := kubernetes.NewForConfig(c)
|
||||
// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme)
|
||||
//
|
||||
// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types
|
||||
// correctly.
|
||||
|
@ -39,7 +39,6 @@ func (c *AWSCollectorPlugin) NewCollector(hpa *autoscalingv2.HorizontalPodAutosc
|
||||
type AWSSQSCollector struct {
|
||||
sqs sqsiface.SQSAPI
|
||||
interval time.Duration
|
||||
region string
|
||||
queueURL string
|
||||
queueName string
|
||||
namespace string
|
||||
|
@ -2,7 +2,7 @@ package httpmetrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -130,7 +130,7 @@ func (g *JSONPathMetricsGetter) fetchMetrics(metricsURL url.URL) ([]byte, error)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package collector
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -42,7 +41,6 @@ type PodCollector struct {
|
||||
minPodReadyAge time.Duration
|
||||
interval time.Duration
|
||||
logger *log.Entry
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
func NewPodCollector(client kubernetes.Interface, hpa *autoscalingv2.HorizontalPodAutoscaler, config *MetricConfig, interval time.Duration) (*PodCollector, error) {
|
||||
|
@ -16,16 +16,14 @@ import (
|
||||
const (
|
||||
// ZMONMetricType defines the metric type for metrics based on ZMON
|
||||
// checks.
|
||||
ZMONMetricType = "zmon"
|
||||
ZMONCheckMetricLegacy = "zmon-check"
|
||||
zmonCheckIDLabelKey = "check-id"
|
||||
zmonKeyLabelKey = "key"
|
||||
zmonDurationLabelKey = "duration"
|
||||
zmonAggregatorsLabelKey = "aggregators"
|
||||
zmonTagPrefixLabelKey = "tag-"
|
||||
defaultQueryDuration = 10 * time.Minute
|
||||
zmonKeyAnnotationKey = "metric-config.external.zmon-check.zmon/key"
|
||||
zmonTagPrefixAnnotationKey = "metric-config.external.zmon-check.zmon/tag-"
|
||||
ZMONMetricType = "zmon"
|
||||
ZMONCheckMetricLegacy = "zmon-check"
|
||||
zmonCheckIDLabelKey = "check-id"
|
||||
zmonKeyLabelKey = "key"
|
||||
zmonDurationLabelKey = "duration"
|
||||
zmonAggregatorsLabelKey = "aggregators"
|
||||
zmonTagPrefixLabelKey = "tag-"
|
||||
defaultQueryDuration = 10 * time.Minute
|
||||
)
|
||||
|
||||
// ZMONCollectorPlugin defines a plugin for creating collectors that can get
|
||||
|
@ -14,7 +14,6 @@ import (
|
||||
|
||||
type zmonMock struct {
|
||||
dataPoints []zmon.DataPoint
|
||||
entities []zmon.Entity
|
||||
}
|
||||
|
||||
func (m zmonMock) Query(checkID int, key string, tags map[string]string, aggregators []string, duration time.Duration) ([]zmon.DataPoint, error) {
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/kubernetes-sigs/custom-metrics-apiserver/pkg/provider"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -20,6 +19,7 @@ import (
|
||||
kube_record "k8s.io/client-go/tools/record"
|
||||
"k8s.io/metrics/pkg/apis/custom_metrics"
|
||||
"k8s.io/metrics/pkg/apis/external_metrics"
|
||||
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"
|
||||
|
||||
"github.com/zalando-incubator/kube-metrics-adapter/pkg/collector"
|
||||
"github.com/zalando-incubator/kube-metrics-adapter/pkg/recorder"
|
||||
@ -268,8 +268,8 @@ func (p *HPAProvider) collectMetrics(ctx context.Context) {
|
||||
}
|
||||
|
||||
// GetMetricByName gets a single metric by name.
|
||||
func (p *HPAProvider) GetMetricByName(name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error) {
|
||||
metric := p.metricStore.GetMetricsByName(name, info, metricSelector)
|
||||
func (p *HPAProvider) GetMetricByName(ctx context.Context, name types.NamespacedName, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValue, error) {
|
||||
metric := p.metricStore.GetMetricsByName(ctx, name, info, metricSelector)
|
||||
if metric == nil {
|
||||
return nil, provider.NewMetricNotFoundForError(info.GroupResource, info.Metric, name.Name)
|
||||
}
|
||||
@ -278,8 +278,8 @@ func (p *HPAProvider) GetMetricByName(name types.NamespacedName, info provider.C
|
||||
|
||||
// GetMetricBySelector returns metrics for namespaced resources by
|
||||
// label selector.
|
||||
func (p *HPAProvider) GetMetricBySelector(namespace string, selector labels.Selector, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error) {
|
||||
return p.metricStore.GetMetricsBySelector(objectNamespace(namespace), selector, info), nil
|
||||
func (p *HPAProvider) GetMetricBySelector(ctx context.Context, namespace string, selector labels.Selector, info provider.CustomMetricInfo, metricSelector labels.Selector) (*custom_metrics.MetricValueList, error) {
|
||||
return p.metricStore.GetMetricsBySelector(ctx, objectNamespace(namespace), selector, info), nil
|
||||
}
|
||||
|
||||
// ListAllMetrics list all available metrics from the provicer.
|
||||
@ -287,8 +287,8 @@ func (p *HPAProvider) ListAllMetrics() []provider.CustomMetricInfo {
|
||||
return p.metricStore.ListAllMetrics()
|
||||
}
|
||||
|
||||
func (p *HPAProvider) GetExternalMetric(namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error) {
|
||||
return p.metricStore.GetExternalMetric(objectNamespace(namespace), metricSelector, info)
|
||||
func (p *HPAProvider) GetExternalMetric(ctx context.Context, namespace string, metricSelector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error) {
|
||||
return p.metricStore.GetExternalMetric(ctx, objectNamespace(namespace), metricSelector, info)
|
||||
}
|
||||
|
||||
func (p *HPAProvider) ListAllExternalMetrics() []provider.ExternalMetricInfo {
|
||||
|
@ -1,13 +1,13 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/kubernetes-sigs/custom-metrics-apiserver/pkg/provider"
|
||||
"github.com/zalando-incubator/kube-metrics-adapter/pkg/collector"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@ -15,6 +15,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/metrics/pkg/apis/custom_metrics"
|
||||
"k8s.io/metrics/pkg/apis/external_metrics"
|
||||
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"
|
||||
)
|
||||
|
||||
// customMetricsStoredMetric is a wrapper around custom_metrics.MetricValue with a metricsTTL used
|
||||
@ -252,7 +253,7 @@ func parseHashLabelMap(s labelsHash) labels.Set {
|
||||
|
||||
// GetMetricsBySelector gets metric from the customMetricsStore using a label selector to
|
||||
// find metrics for matching resources.
|
||||
func (s *MetricStore) GetMetricsBySelector(namespace objectNamespace, selector labels.Selector, info provider.CustomMetricInfo) *custom_metrics.MetricValueList {
|
||||
func (s *MetricStore) GetMetricsBySelector(_ context.Context, namespace objectNamespace, selector labels.Selector, info provider.CustomMetricInfo) *custom_metrics.MetricValueList {
|
||||
matchedMetrics := make([]custom_metrics.MetricValue, 0)
|
||||
|
||||
s.RLock()
|
||||
@ -292,7 +293,7 @@ func (s *MetricStore) GetMetricsBySelector(namespace objectNamespace, selector l
|
||||
}
|
||||
|
||||
// GetMetricsByName looks up metrics in the customMetricsStore by resource name.
|
||||
func (s *MetricStore) GetMetricsByName(object types.NamespacedName, info provider.CustomMetricInfo, selector labels.Selector) *custom_metrics.MetricValue {
|
||||
func (s *MetricStore) GetMetricsByName(_ context.Context, object types.NamespacedName, info provider.CustomMetricInfo, selector labels.Selector) *custom_metrics.MetricValue {
|
||||
name := objectName(object.Name)
|
||||
namespace := objectNamespace(object.Namespace)
|
||||
|
||||
@ -360,7 +361,7 @@ func (s *MetricStore) ListAllMetrics() []provider.CustomMetricInfo {
|
||||
|
||||
// GetExternalMetric gets external metric from the store by metric name and
|
||||
// selector.
|
||||
func (s *MetricStore) GetExternalMetric(namespace objectNamespace, selector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error) {
|
||||
func (s *MetricStore) GetExternalMetric(_ context.Context, namespace objectNamespace, selector labels.Selector, info provider.ExternalMetricInfo) (*external_metrics.ExternalMetricValueList, error) {
|
||||
matchedMetrics := make([]external_metrics.ExternalMetricValue, 0)
|
||||
|
||||
s.RLock()
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/kubernetes-sigs/custom-metrics-apiserver/pkg/provider"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zalando-incubator/kube-metrics-adapter/pkg/collector"
|
||||
"golang.org/x/net/context"
|
||||
autoscalingv2 "k8s.io/api/autoscaling/v2beta2"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -16,6 +16,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/metrics/pkg/apis/custom_metrics"
|
||||
"k8s.io/metrics/pkg/apis/external_metrics"
|
||||
"sigs.k8s.io/custom-metrics-apiserver/pkg/provider"
|
||||
)
|
||||
|
||||
func newMetricIdentifier(metricName string, selector metav1.LabelSelector) custom_metrics.MetricIdentifier {
|
||||
@ -495,13 +496,13 @@ func TestInternalMetricStorage(t *testing.T) {
|
||||
require.Equal(t, tc.list, metricInfos)
|
||||
|
||||
// Get the metric by name
|
||||
metric := metricsStore.GetMetricsByName(tc.byName.name, tc.byName.info, tc.byLabel.selector)
|
||||
metric := metricsStore.GetMetricsByName(context.Background(), tc.byName.name, tc.byName.info, tc.byLabel.selector)
|
||||
if tc.expectedFound {
|
||||
require.Equal(t, tc.insert.Custom, *metric)
|
||||
metrics := metricsStore.GetMetricsBySelector(objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
metrics := metricsStore.GetMetricsBySelector(context.Background(), objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
require.Equal(t, tc.insert.Custom, metrics.Items[0])
|
||||
} else {
|
||||
metrics := metricsStore.GetMetricsBySelector(objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
metrics := metricsStore.GetMetricsBySelector(context.Background(), objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
require.Len(t, metrics.Items, 0)
|
||||
}
|
||||
})
|
||||
@ -668,11 +669,11 @@ func TestMultipleMetricValues(t *testing.T) {
|
||||
metricsStore.Insert(insert)
|
||||
|
||||
// Get the metric by name
|
||||
metric := metricsStore.GetMetricsByName(tc.byName.name, tc.byName.info, tc.byLabel.selector)
|
||||
metric := metricsStore.GetMetricsByName(context.Background(), tc.byName.name, tc.byName.info, tc.byLabel.selector)
|
||||
require.Equal(t, insert.Custom, *metric)
|
||||
|
||||
// Get the metric by label
|
||||
metrics := metricsStore.GetMetricsBySelector(objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
metrics := metricsStore.GetMetricsBySelector(context.Background(), objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
require.Equal(t, insert.Custom, metrics.Items[0])
|
||||
}
|
||||
|
||||
@ -797,10 +798,10 @@ func TestCustomMetricsStorageErrors(t *testing.T) {
|
||||
require.Equal(t, tc.list, metricInfos)
|
||||
|
||||
// Get the metric by name
|
||||
metric := metricsStore.GetMetricsByName(tc.byName.name, tc.byName.info, tc.byLabel.selector)
|
||||
metric := metricsStore.GetMetricsByName(context.Background(), tc.byName.name, tc.byName.info, tc.byLabel.selector)
|
||||
require.Nil(t, metric)
|
||||
|
||||
metrics := metricsStore.GetMetricsBySelector(objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
metrics := metricsStore.GetMetricsBySelector(context.Background(), objectNamespace(tc.byLabel.namespace), tc.byLabel.selector, tc.byLabel.info)
|
||||
require.Equal(t, &custom_metrics.MetricValueList{}, metrics)
|
||||
|
||||
})
|
||||
@ -1053,7 +1054,7 @@ func TestExternalMetricStorage(t *testing.T) {
|
||||
require.Equal(t, tc.list, metricInfos[0])
|
||||
|
||||
// Get the metric by name
|
||||
metrics, err := metricsStore.GetExternalMetric(objectNamespace(tc.get.namespace), tc.get.selector, tc.get.info)
|
||||
metrics, err := metricsStore.GetExternalMetric(context.Background(), objectNamespace(tc.get.namespace), tc.get.selector, tc.get.info)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.insert.External, metrics.Items[0])
|
||||
|
||||
@ -1221,7 +1222,7 @@ func TestMultipleExternalMetricStorage(t *testing.T) {
|
||||
}
|
||||
|
||||
// Get the metric by name
|
||||
metrics, err := metricsStore.GetExternalMetric(objectNamespace(tc.get.namespace), tc.get.selector, tc.get.info)
|
||||
metrics, err := metricsStore.GetExternalMetric(context.Background(), objectNamespace(tc.get.namespace), tc.get.selector, tc.get.info)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, metrics.Items, 1)
|
||||
require.Contains(t, metrics.Items, tc.insert[tc.expectedIdx].External)
|
||||
|
@ -26,8 +26,6 @@ import (
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/kubernetes-sigs/custom-metrics-apiserver/pkg/apiserver"
|
||||
"github.com/kubernetes-sigs/custom-metrics-apiserver/pkg/cmd/server"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/spf13/cobra"
|
||||
rg "github.com/szuecs/routegroup-client/client/clientset/versioned"
|
||||
@ -48,6 +46,8 @@ import (
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/klog"
|
||||
"sigs.k8s.io/custom-metrics-apiserver/pkg/apiserver"
|
||||
"sigs.k8s.io/custom-metrics-apiserver/pkg/cmd/server"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
@ -14,13 +14,13 @@ var (
|
||||
// set of valid aggregators that can be used in queries
|
||||
// https://kairosdb.github.io/docs/build/html/restapi/Aggregators.html
|
||||
validAggregators = map[string]struct{}{
|
||||
"avg": struct{}{},
|
||||
"count": struct{}{},
|
||||
"last": struct{}{},
|
||||
"max": struct{}{},
|
||||
"min": struct{}{},
|
||||
"sum": struct{}{},
|
||||
"diff": struct{}{},
|
||||
"avg": {},
|
||||
"count": {},
|
||||
"last": {},
|
||||
"max": {},
|
||||
"min": {},
|
||||
"sum": {},
|
||||
"diff": {},
|
||||
}
|
||||
)
|
||||
|
||||
@ -161,7 +161,7 @@ func (c *Client) Query(checkID int, key string, tags map[string]string, aggregat
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
d, err := ioutil.ReadAll(resp.Body)
|
||||
d, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user