Compare commits

...

9 Commits

Author SHA1 Message Date
Martin Linkhorst 70641827ce Merge pull request #869 from zalando-incubator/fix-nil-pointer
fix: Nil check Metric.Selector in MetricTypeName
2026-02-19 17:55:39 +01:00
Markus Wyrsch 99ca95588e fix: Nil check Metric.Selector in MetricTypeName
Signed-off-by: Markus Wyrsch <markus.wyrsch@zalando.de>
2026-02-19 16:11:46 +01:00
Markus cc9952d66e fix: Only format if there is actual an error (#868)
* fix: Only format if there is actual an error

Signed-off-by: Markus Wyrsch <markus.wyrsch@zalando.de>

* small styling fixes

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

---------

Signed-off-by: Markus Wyrsch <markus.wyrsch@zalando.de>
Signed-off-by: Martin Linkhorst <martin.linkhorst@zalando.de>
Co-authored-by: Markus Wyrsch <markus.wyrsch@zalando.de>
Co-authored-by: Martin Linkhorst <martin.linkhorst@zalando.de>
2026-02-18 20:52:18 +01:00
Katyanna Moura 58c6a56cbf Merge pull request #861 from zalando-incubator/dependabot/github_actions/github-actions-5b791d3f7c
Bump the github-actions group with 3 updates
2026-02-18 13:18:26 +01:00
Katyanna Moura 9e3a1760f1 Merge pull request #866 from zalando-incubator/dependabot/go_modules/all-go-mod-patch-and-minor-cd0c2694b7
Bump the all-go-mod-patch-and-minor group with 7 updates
2026-02-18 13:18:14 +01:00
Jens Hausherr 0e52e076c1 Enable adding annotations to apiservice resources (#865)
Signed-off-by: Jens Hausherr <jens.hausherr@pflege.de>
2026-02-16 09:06:54 +01:00
dependabot[bot] 18faf9c076 Bump the all-go-mod-patch-and-minor group with 7 updates
Bumps the all-go-mod-patch-and-minor group with 7 updates:

| Package | From | To |
| --- | --- | --- |
| [github.com/argoproj/argo-rollouts](https://github.com/argoproj/argo-rollouts) | `1.8.3` | `1.8.4` |
| [k8s.io/api](https://github.com/kubernetes/api) | `0.34.3` | `0.34.4` |
| [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) | `0.34.3` | `0.34.4` |
| [k8s.io/apiserver](https://github.com/kubernetes/apiserver) | `0.34.3` | `0.34.4` |
| [k8s.io/client-go](https://github.com/kubernetes/client-go) | `0.34.3` | `0.34.4` |
| [k8s.io/component-base](https://github.com/kubernetes/component-base) | `0.34.3` | `0.34.4` |
| [k8s.io/metrics](https://github.com/kubernetes/metrics) | `0.34.3` | `0.34.4` |


Updates `github.com/argoproj/argo-rollouts` from 1.8.3 to 1.8.4
- [Release notes](https://github.com/argoproj/argo-rollouts/releases)
- [Changelog](https://github.com/argoproj/argo-rollouts/blob/master/CHANGELOG.md)
- [Commits](https://github.com/argoproj/argo-rollouts/compare/v1.8.3...v1.8.4)

Updates `k8s.io/api` from 0.34.3 to 0.34.4
- [Commits](https://github.com/kubernetes/api/compare/v0.34.3...v0.34.4)

Updates `k8s.io/apimachinery` from 0.34.3 to 0.34.4
- [Commits](https://github.com/kubernetes/apimachinery/compare/v0.34.3...v0.34.4)

Updates `k8s.io/apiserver` from 0.34.3 to 0.34.4
- [Commits](https://github.com/kubernetes/apiserver/compare/v0.34.3...v0.34.4)

Updates `k8s.io/client-go` from 0.34.3 to 0.34.4
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/kubernetes/client-go/compare/v0.34.3...v0.34.4)

Updates `k8s.io/component-base` from 0.34.3 to 0.34.4
- [Commits](https://github.com/kubernetes/component-base/compare/v0.34.3...v0.34.4)

Updates `k8s.io/metrics` from 0.34.3 to 0.34.4
- [Commits](https://github.com/kubernetes/metrics/compare/v0.34.3...v0.34.4)

---
updated-dependencies:
- dependency-name: github.com/argoproj/argo-rollouts
  dependency-version: 1.8.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-mod-patch-and-minor
- dependency-name: k8s.io/api
  dependency-version: 0.34.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-mod-patch-and-minor
- dependency-name: k8s.io/apimachinery
  dependency-version: 0.34.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-mod-patch-and-minor
- dependency-name: k8s.io/apiserver
  dependency-version: 0.34.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-mod-patch-and-minor
- dependency-name: k8s.io/client-go
  dependency-version: 0.34.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-mod-patch-and-minor
- dependency-name: k8s.io/component-base
  dependency-version: 0.34.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-mod-patch-and-minor
- dependency-name: k8s.io/metrics
  dependency-version: 0.34.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-go-mod-patch-and-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-16 06:32:11 +00:00
dependabot[bot] 170faf8809 Bump golang.org/x/oauth2 in the all-go-mod-patch-and-minor group (#863)
Bumps the all-go-mod-patch-and-minor group with 1 update: [golang.org/x/oauth2](https://github.com/golang/oauth2).


Updates `golang.org/x/oauth2` from 0.34.0 to 0.35.0
- [Commits](https://github.com/golang/oauth2/compare/v0.34.0...v0.35.0)

---
updated-dependencies:
- dependency-name: golang.org/x/oauth2
  dependency-version: 0.35.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-go-mod-patch-and-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-12 16:09:31 +01:00
dependabot[bot] 419f75cf18 Bump the github-actions group with 3 updates
Bumps the github-actions group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [actions/setup-go](https://github.com/actions/setup-go) and [docker/login-action](https://github.com/docker/login-action).


Updates `actions/checkout` from 6.0.1 to 6.0.2
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v6.0.1...v6.0.2)

Updates `actions/setup-go` from 6.1.0 to 6.2.0
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v6.1.0...v6.2.0)

Updates `docker/login-action` from 3.6.0 to 3.7.0
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/5e57cd118135c172c3672efd75eb46360885c0ef...c94ce9fb468520275223c153574b00df6fe4bcc9)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 6.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: actions/setup-go
  dependency-version: 6.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: docker/login-action
  dependency-version: 3.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-01 06:28:13 +00:00
12 changed files with 154 additions and 42 deletions
+2 -2
View File
@@ -10,8 +10,8 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.1
- uses: actions/setup-go@v6.1.0
- uses: actions/checkout@v6.0.2
- uses: actions/setup-go@v6.2.0
with:
go-version: '^1.25'
- run: go version
+2 -2
View File
@@ -38,10 +38,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.1
uses: actions/checkout@v6.0.2
- name: setup go
uses: actions/setup-go@v6.1.0
uses: actions/setup-go@v6.2.0
with:
go-version: '1.25'
+4 -4
View File
@@ -25,15 +25,15 @@ jobs:
packages: write # to push packages
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c
- uses: actions/setup-go@a5f9b05d2d216f63e13859e0d847461041025775
with:
# https://www.npmjs.com/package/semver#caret-ranges-123-025-004
go-version: '^1.25'
- name: Login to Github Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
@@ -54,7 +54,7 @@ jobs:
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
with:
registry: ghcr.io
username: ${{ github.actor }}
+1 -1
View File
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6.0.1
uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
@@ -3,6 +3,13 @@ apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1beta1.custom.metrics.k8s.io
{{- with .Values.customMetricsApi.annotations }}
annotations:
{{- range $k, $v := . }}
{{- $value := $v | quote }}
{{- printf "%s: %s" (tpl $k $) (tpl $value $) | nindent 4 }}
{{- end }}
{{- end }}
spec:
service:
name: kube-metrics-adapter
@@ -13,3 +20,4 @@ spec:
groupPriorityMinimum: 100
versionPriority: 100
{{- end}}
""
@@ -3,6 +3,13 @@ apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1beta1.external.metrics.k8s.io
{{- with .Values.externalMetricsApi.annotations }}
annotations:
{{- range $k, $v := . }}
{{- $value := $v | quote }}
{{- printf "%s: %s" (tpl $k $) (tpl $value $) | nindent 4 }}
{{- end }}
{{- end }}
spec:
service:
name: kube-metrics-adapter
+12
View File
@@ -15,7 +15,19 @@ addDirectoryHeader:
contentionProfiling:
profiling:
enableCustomMetricsApi: true
# -- add annotations to the custom metrics apiservice resource, e.g.
# cert-manager.io/inject-ca-from: {{.Release.Namespace}}/kube-metrics-adapter to inject the CA certificate form a cert-manager-issued cert used for the deployment
customMetricsApi:
annotations: {}
enableExternalMetricsApi: true
# -- add annotations to the custom metrics apiservice resource, e.g.
# cert-manager.io/inject-ca-from: {{.Release.Namespace}}/kube-metrics-adapter to inject the CA certificate form a cert-manager-issued cert used for the deployment
externalMetricsApi:
annotations: {}
credentialsDirectory:
disregardIncompatibleHPAs:
http2MaxStreamsPerConnection:
+10 -10
View File
@@ -1,7 +1,7 @@
module github.com/zalando-incubator/kube-metrics-adapter
require (
github.com/argoproj/argo-rollouts v1.8.3
github.com/argoproj/argo-rollouts v1.8.4
github.com/aws/aws-sdk-go-v2 v1.41.1
github.com/aws/aws-sdk-go-v2/config v1.32.7
github.com/aws/aws-sdk-go-v2/service/sqs v1.42.21
@@ -14,16 +14,16 @@ require (
github.com/stretchr/testify v1.11.1
github.com/szuecs/routegroup-client v0.34.1
github.com/zalando-incubator/cluster-lifecycle-manager v0.0.0-20250912104308-4489de744ee3
golang.org/x/oauth2 v0.34.0
golang.org/x/oauth2 v0.35.0
golang.org/x/sync v0.19.0
k8s.io/api v0.34.3
k8s.io/apimachinery v0.34.3
k8s.io/apiserver v0.34.3
k8s.io/client-go v0.34.3
k8s.io/component-base v0.34.3
k8s.io/api v0.34.4
k8s.io/apimachinery v0.34.4
k8s.io/apiserver v0.34.4
k8s.io/client-go v0.34.4
k8s.io/component-base v0.34.4
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912
k8s.io/metrics v0.34.3
k8s.io/metrics v0.34.4
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
sigs.k8s.io/custom-metrics-apiserver v1.34.0
)
@@ -194,10 +194,10 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.34.0 // indirect
k8s.io/code-generator v0.34.3 // indirect
k8s.io/code-generator v0.34.4 // indirect
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kms v0.34.3 // indirect
k8s.io/kms v0.34.4 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect
sigs.k8s.io/controller-tools v0.19.0 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
+20 -20
View File
@@ -25,8 +25,8 @@ github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
github.com/argoproj/argo-rollouts v1.8.3 h1:blbtQva4IK9r6gFh+dWkCrLnFdPOWiv9ubQYu36qeaA=
github.com/argoproj/argo-rollouts v1.8.3/go.mod h1:kCAUvIfMGfOyVf3lvQbBt0nqQn4Pd+zB5/YwKv+UBa8=
github.com/argoproj/argo-rollouts v1.8.4 h1:yRoN6/mNtb9H2VHhL09ZvF3ZfajerOrKB3EhgIGoz6c=
github.com/argoproj/argo-rollouts v1.8.4/go.mod h1:/J99JlgiXreVVjJUIXTsguvubJRNBtYKAhIrx0UdaS8=
github.com/aws/aws-sdk-go-v2 v1.41.1 h1:ABlyEARCDLN034NhxlRUSZr4l71mh+T5KAeGh6cerhU=
github.com/aws/aws-sdk-go-v2 v1.41.1/go.mod h1:MayyLB8y+buD9hZqkCW3kX1AKq07Y5pXxtgB+rRFhz0=
github.com/aws/aws-sdk-go-v2/config v1.32.7 h1:vxUyWGUwmkQ2g19n7JY/9YL8MfAIl7bTesIUykECXmY=
@@ -480,8 +480,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ=
golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -562,32 +562,32 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.34.3 h1:D12sTP257/jSH2vHV2EDYrb16bS7ULlHpdNdNhEw2S4=
k8s.io/api v0.34.3/go.mod h1:PyVQBF886Q5RSQZOim7DybQjAbVs8g7gwJNhGtY5MBk=
k8s.io/api v0.34.4 h1:Z5hsoQcZ2yBjelb9j5JKzCVo9qv9XLkVm5llnqS4h+0=
k8s.io/api v0.34.4/go.mod h1:6SaGYuGPkMqqCgg8rPG/OQoCrhgSEV+wWn9v21fDP3o=
k8s.io/apiextensions-apiserver v0.34.0 h1:B3hiB32jV7BcyKcMU5fDaDxk882YrJ1KU+ZSkA9Qxoc=
k8s.io/apiextensions-apiserver v0.34.0/go.mod h1:hLI4GxE1BDBy9adJKxUxCEHBGZtGfIg98Q+JmTD7+g0=
k8s.io/apimachinery v0.34.3 h1:/TB+SFEiQvN9HPldtlWOTp0hWbJ+fjU+wkxysf/aQnE=
k8s.io/apimachinery v0.34.3/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/apiserver v0.34.3 h1:uGH1qpDvSiYG4HVFqc6A3L4CKiX+aBWDrrsxHYK0Bdo=
k8s.io/apiserver v0.34.3/go.mod h1:QPnnahMO5C2m3lm6fPW3+JmyQbvHZQ8uudAu/493P2w=
k8s.io/client-go v0.34.3 h1:wtYtpzy/OPNYf7WyNBTj3iUA0XaBHVqhv4Iv3tbrF5A=
k8s.io/client-go v0.34.3/go.mod h1:OxxeYagaP9Kdf78UrKLa3YZixMCfP6bgPwPwNBQBzpM=
k8s.io/code-generator v0.34.3 h1:6ipJKsJZZ9q21BO8I2jEj4OLN3y8/1n4aihKN0xKmQk=
k8s.io/code-generator v0.34.3/go.mod h1:oW73UPYpGLsbRN8Ozkhd6ZzkF8hzFCiYmvEuWZDroI4=
k8s.io/component-base v0.34.3 h1:zsEgw6ELqK0XncCQomgO9DpUIzlrYuZYA0Cgo+JWpVk=
k8s.io/component-base v0.34.3/go.mod h1:5iIlD8wPfWE/xSHTRfbjuvUul2WZbI2nOUK65XL0E/c=
k8s.io/apimachinery v0.34.4 h1:C5SiSzLEMyWIk53sSbnk0WlOOyqv/MFnWvuc/d6M+xc=
k8s.io/apimachinery v0.34.4/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/apiserver v0.34.4 h1:QmMakuCjlFBJpsXKIUom8OUE7+PhZk7hyNiLqlyDH58=
k8s.io/apiserver v0.34.4/go.mod h1:4dM2Pfd+VQQA/4pLVPorZJbIadaTLcvgQn2GYYcA6Ic=
k8s.io/client-go v0.34.4 h1:IXhvzFdm0e897kXtLbeyMpAGzontcShJ/gi/XCCsOLc=
k8s.io/client-go v0.34.4/go.mod h1:tXIVJTQabT5QRGlFdxZQFxrIhcGUPpKL5DAc4gSWTE8=
k8s.io/code-generator v0.34.4 h1:ri/HSQ1eCQ40pqTQ4HeEiC8UR/SaftH/syav9RL4b+c=
k8s.io/code-generator v0.34.4/go.mod h1:JbvI8dtG5KB5HJSFzExSbvigBSG8gCncyMtdwg/NVbw=
k8s.io/component-base v0.34.4 h1:jP4XqR48YelfXIlRpOHQgms5GebU23zSE6xcvTwpXDE=
k8s.io/component-base v0.34.4/go.mod h1:uujRfLNOwNiFWz47eBjNZEj/Swn2cdhqI7lW2MeFdrU=
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f h1:SLb+kxmzfA87x4E4brQzB33VBbT2+x7Zq9ROIHmGn9Q=
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kms v0.34.3 h1:QzBOD0sk1bGQVMcZQAHGjtbP1iKZJUyhC6D0I+BTxIE=
k8s.io/kms v0.34.3/go.mod h1:s1CFkLG7w9eaTYvctOxosx88fl4spqmixnNpys0JAtM=
k8s.io/kms v0.34.4 h1:jF1s1e0CZsM8UXtzqz8JYIBhI4EQIvZHQ15K28StUJA=
k8s.io/kms v0.34.4/go.mod h1:s1CFkLG7w9eaTYvctOxosx88fl4spqmixnNpys0JAtM=
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE=
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ=
k8s.io/metrics v0.34.3 h1:zKco9A0q7Ibl3alcO1kqRandTt4GKwKGOBflYJTIBHc=
k8s.io/metrics v0.34.3/go.mod h1:BWmkYCQ9x4I120OmCtMUeuXn0VTGkJLwBErneDL5aSQ=
k8s.io/metrics v0.34.4 h1:u/0EwE8M1BHwlfDUjyAlDInm8Y545lQ6lU2bZTvq/tE=
k8s.io/metrics v0.34.4/go.mod h1:rH8Uul1TDHXdbBwuRh9ilZpUOfPiUJu99GhbYSE2X90=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
moul.io/http2curl/v2 v2.3.0 h1:9r3JfDzWPcbIklMOs2TnIFzDYvfAZvjeavG6EzP7jYs=
+1 -1
View File
@@ -185,7 +185,7 @@ type MetricTypeName struct {
func (m MetricTypeName) String() string {
str := fmt.Sprintf("%s/%s", m.Type, m.Metric.Name)
if len(m.Metric.Selector.MatchLabels) > 0 {
if m.Metric.Selector != nil && len(m.Metric.Selector.MatchLabels) > 0 {
str += " " + mapToString(m.Metric.Selector.MatchLabels)
}
return str
+82
View File
@@ -30,6 +30,88 @@ func (c *mockCollector) Interval() time.Duration {
return 0
}
func TestMetricTypeName_String(t *testing.T) {
for _, tc := range []struct {
name string
metricType autoscalingv2.MetricSourceType
metricName string
selector *metav1.LabelSelector
expectedStr string
shouldContain []string
}{
{
name: "nil selector with PodsMetricSourceType",
metricType: autoscalingv2.PodsMetricSourceType,
metricName: "metric-name",
selector: nil,
expectedStr: "Pods/metric-name",
},
{
name: "nil selector with ObjectMetricSourceType",
metricType: autoscalingv2.ObjectMetricSourceType,
metricName: "metric-name",
selector: nil,
expectedStr: "Object/metric-name",
},
{
name: "nil selector with ExternalMetricSourceType",
metricType: autoscalingv2.ExternalMetricSourceType,
metricName: "metric-name",
selector: nil,
expectedStr: "External/metric-name",
},
{
name: "empty selector (non-nil but empty MatchLabels)",
metricType: autoscalingv2.ExternalMetricSourceType,
metricName: "metric-name",
selector: &metav1.LabelSelector{
MatchLabels: map[string]string{},
},
expectedStr: "External/metric-name",
},
{
name: "selector with single MatchLabel",
metricType: autoscalingv2.ExternalMetricSourceType,
metricName: "metric-name",
selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"key": "value"},
},
shouldContain: []string{"External/metric-name", "key=value"},
},
{
name: "selector with multiple MatchLabels",
metricType: autoscalingv2.ExternalMetricSourceType,
metricName: "metric-name",
selector: &metav1.LabelSelector{
MatchLabels: map[string]string{"key1": "val1", "key2": "val2"},
},
shouldContain: []string{"External/metric-name", "key1=val1", "key2=val2"},
},
} {
t.Run(tc.name, func(t *testing.T) {
mtn := MetricTypeName{
Type: tc.metricType,
Metric: autoscalingv2.MetricIdentifier{
Name: tc.metricName,
Selector: tc.selector,
},
}
result := mtn.String()
if tc.expectedStr != "" {
require.Equal(t, tc.expectedStr, result)
}
if len(tc.shouldContain) > 0 {
for _, substring := range tc.shouldContain {
require.Contains(t, result, substring, "result should contain %q", substring)
}
}
})
}
}
func TestNewCollector(t *testing.T) {
for _, tc := range []struct {
msg string
+5 -2
View File
@@ -346,7 +346,7 @@ type CollectorScheduler struct {
sync.RWMutex
}
// NewCollectorScheudler initializes a new CollectorScheduler.
// NewCollectorScheduler initializes a new CollectorScheduler.
func NewCollectorScheduler(ctx context.Context, metricsc chan<- metricCollection) *CollectorScheduler {
return &CollectorScheduler{
ctx: ctx,
@@ -384,10 +384,13 @@ func (t *CollectorScheduler) Add(resourceRef resourceReference, typeName collect
func collectorRunner(ctx context.Context, typeName collector.MetricTypeName, collector collector.Collector, metricsc chan<- metricCollection) {
for {
values, err := collector.GetMetrics(ctx)
if err != nil {
err = fmt.Errorf("getting metrics for %s failed: %w", typeName, err)
}
metricsc <- metricCollection{
Values: values,
Error: fmt.Errorf("getting metrics for %s failed: %w", typeName, err),
Error: err,
}
select {