Skip to content

Commit 7dcf67b

Browse files
Merge remote-tracking branch 'upstream/main' into rashmi/ksm-cfg
2 parents d53f865 + 9add5df commit 7dcf67b

File tree

8 files changed

+46
-14
lines changed

8 files changed

+46
-14
lines changed

SECURITY_CONTACTS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
dgrisonnet
1414
mrueg
1515
rexagod
16+
CatherineF-dev

docs/metrics/workload/pod-metrics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
| kube_pod_status_reason | Gauge | The pod status reasons | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `reason`=&lt;Evicted\|NodeAffinity\|NodeLost\|Shutdown\|UnexpectedAdmissionError&gt; <br> `uid`=&lt;pod-uid&gt; | EXPERIMENTAL | - |
5454
| kube_pod_status_scheduled_time | Gauge | Unix timestamp when pod moved into scheduled status | seconds | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
5555
| kube_pod_status_unschedulable | Gauge | Describes the unschedulable status for the pod | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; | STABLE | - |
56+
| kube_pod_status_unscheduled_time | Gauge | Unix timestamp when pod moved into unscheduled status | seconds | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; | EXPERIMENTAL | - |
5657
| kube_pod_tolerations | Gauge | Information about the pod tolerations | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; <br> `key`=&lt;toleration-key&gt; <br> `operator`=&lt;toleration-operator&gt; <br> `value`=&lt;toleration-value&gt; <br> `effect`=&lt;toleration-effect&gt; `toleration_seconds`=&lt;toleration-seconds&gt; | EXPERIMENTAL | - |
5758
| kube_pod_service_account | Gauge | The service account for a pod | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; <br> `service_account`=&lt;service_account&gt; | EXPERIMENTAL | - |
5859
| kube_pod_scheduler | Gauge | The scheduler for a pod | | `pod`=&lt;pod-name&gt; <br> `namespace`=&lt;pod-namespace&gt; <br> `uid`=&lt;pod-uid&gt; <br> `name`=&lt;scheduler-name&gt; | EXPERIMENTAL | - |

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ module k8s.io/kube-state-metrics/v2
33
go 1.24.0
44

55
require (
6-
github.com/KimMachineGun/automemlimit v0.7.3
6+
github.com/KimMachineGun/automemlimit v0.7.4
77
github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0
88
github.com/dlclark/regexp2 v1.11.5
99
github.com/fsnotify/fsnotify v1.9.0
1010
github.com/go-logr/logr v1.4.3
1111
github.com/gobuffalo/flect v1.0.3
1212
github.com/google/go-cmp v0.7.0
1313
github.com/oklog/run v1.2.0
14-
github.com/prometheus/client_golang v1.22.0
14+
github.com/prometheus/client_golang v1.23.0
1515
github.com/prometheus/client_model v0.6.2
1616
github.com/prometheus/common v0.65.0
1717
github.com/prometheus/exporter-toolkit v0.14.0
@@ -27,7 +27,7 @@ require (
2727
k8s.io/sample-controller v0.32.6
2828
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
2929
sigs.k8s.io/controller-runtime v0.20.4
30-
sigs.k8s.io/yaml v1.5.0
30+
sigs.k8s.io/yaml v1.6.0
3131
)
3232

3333
require (
@@ -189,7 +189,7 @@ require (
189189
github.com/pkg/errors v0.9.1 // indirect
190190
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
191191
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
192-
github.com/prometheus/procfs v0.15.1 // indirect
192+
github.com/prometheus/procfs v0.16.1 // indirect
193193
github.com/ryanuber/go-glob v1.0.0 // indirect
194194
github.com/sagikazarmark/locafero v0.7.0 // indirect
195195
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0
5959
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/cloudmock v0.48.1/go.mod h1:0wEl7vrAD8mehJyohS9HZy+WyEOaQO2mJx86Cvh93kM=
6060
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.48.1 h1:8nn+rsCvTq9axyEh382S0PFLBeaFwNsT43IrPWzctRU=
6161
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.48.1/go.mod h1:viRWSEhtMZqz1rhwmOVKkWl6SwmVowfL9O2YR5gI2PE=
62-
github.com/KimMachineGun/automemlimit v0.7.3 h1:oPgMp0bsWez+4fvgSa11Rd9nUDrd8RLtDjBoT3ro+/A=
63-
github.com/KimMachineGun/automemlimit v0.7.3/go.mod h1:QZxpHaGOQoYvFhv/r4u3U0JTC2ZcOwbSr11UZF46UBM=
62+
github.com/KimMachineGun/automemlimit v0.7.4 h1:UY7QYOIfrr3wjjOAqahFmC3IaQCLWvur9nmfIn6LnWk=
63+
github.com/KimMachineGun/automemlimit v0.7.4/go.mod h1:QZxpHaGOQoYvFhv/r4u3U0JTC2ZcOwbSr11UZF46UBM=
6464
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
6565
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
6666
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
@@ -560,8 +560,8 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg
560560
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
561561
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
562562
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
563-
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
564-
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
563+
github.com/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
564+
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
565565
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
566566
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
567567
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -577,8 +577,8 @@ github.com/prometheus/exporter-toolkit v0.14.0/go.mod h1:Gu5LnVvt7Nr/oqTBUC23WIL
577577
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
578578
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
579579
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
580-
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
581-
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
580+
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
581+
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
582582
github.com/protocolbuffers/txtpbfmt v0.0.0-20240823084532-8e6b51fa9bef h1:ej+64jiny5VETZTqcc1GFVAPEtaSk6U1D0kKC2MS5Yc=
583583
github.com/protocolbuffers/txtpbfmt v0.0.0-20240823084532-8e6b51fa9bef/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c=
584584
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
@@ -954,5 +954,5 @@ sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8
954954
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA=
955955
sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4=
956956
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
957-
sigs.k8s.io/yaml v1.5.0 h1:M10b2U7aEUY6hRtU870n2VTPgR5RZiL/I6Lcc2F4NUQ=
958-
sigs.k8s.io/yaml v1.5.0/go.mod h1:wZs27Rbxoai4C0f8/9urLZtZtF3avA3gKvGyPdDqTO4=
957+
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
958+
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=

internal/store/pod.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func podMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
9292
createPodStatusScheduledFamilyGenerator(),
9393
createPodStatusScheduledTimeFamilyGenerator(),
9494
createPodStatusUnschedulableFamilyGenerator(),
95+
createPodStatusUnscheduledTimeFamilyGenerator(),
9596
createPodTolerationsFamilyGenerator(),
9697
createPodNodeSelectorsFamilyGenerator(),
9798
createPodServiceAccountFamilyGenerator(),
@@ -1656,6 +1657,33 @@ func createPodStatusUnschedulableFamilyGenerator() generator.FamilyGenerator {
16561657
)
16571658
}
16581659

1660+
func createPodStatusUnscheduledTimeFamilyGenerator() generator.FamilyGenerator {
1661+
return *generator.NewFamilyGeneratorWithStability(
1662+
"kube_pod_status_unscheduled_time",
1663+
"Unix timestamp when pod moved into unscheduled status",
1664+
metric.Gauge,
1665+
basemetrics.ALPHA,
1666+
"",
1667+
wrapPodFunc(func(p *v1.Pod) *metric.Family {
1668+
ms := []*metric.Metric{}
1669+
1670+
for _, c := range p.Status.Conditions {
1671+
if c.Type == v1.PodScheduled && c.Status == v1.ConditionFalse {
1672+
ms = append(ms, &metric.Metric{
1673+
LabelKeys: []string{},
1674+
LabelValues: []string{},
1675+
Value: float64(c.LastTransitionTime.Unix()),
1676+
})
1677+
}
1678+
}
1679+
1680+
return &metric.Family{
1681+
Metrics: ms,
1682+
}
1683+
}),
1684+
)
1685+
}
1686+
16591687
// getUniqueTolerations takes an array
16601688
func getUniqueTolerations(tolerations []v1.Toleration) []v1.Toleration {
16611689
uniqueTolerationsMap := make(map[v1.Toleration]struct{})

internal/store/pod_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ func BenchmarkPodStore(b *testing.B) {
22822282
},
22832283
}
22842284

2285-
expectedFamilies := 54
2285+
expectedFamilies := 55
22862286
for n := 0; n < b.N; n++ {
22872287
families := f(pod)
22882288
if len(families) != expectedFamilies {

pkg/app/server_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ func TestFullScrapeCycle(t *testing.T) {
259259
# HELP kube_pod_status_scheduled [STABLE] Describes the status of the scheduling process for the pod.
260260
# HELP kube_pod_status_scheduled_time [STABLE] Unix timestamp when pod moved into scheduled status
261261
# HELP kube_pod_status_unschedulable [STABLE] Describes the unschedulable status for the pod.
262+
# HELP kube_pod_status_unscheduled_time Unix timestamp when pod moved into unscheduled status
262263
# HELP kube_pod_tolerations Information about the pod tolerations
263264
# TYPE kube_pod_annotations gauge
264265
# TYPE kube_pod_completion_time gauge
@@ -312,6 +313,7 @@ func TestFullScrapeCycle(t *testing.T) {
312313
# TYPE kube_pod_status_scheduled gauge
313314
# TYPE kube_pod_status_scheduled_time gauge
314315
# TYPE kube_pod_status_unschedulable gauge
316+
# TYPE kube_pod_status_unscheduled_time gauge
315317
# TYPE kube_pod_tolerations gauge
316318
kube_pod_container_info{namespace="default",pod="pod0",uid="abc-0",container="pod1_con1",image_spec="k8s.gcr.io/hyperkube2_spec",image="k8s.gcr.io/hyperkube2",image_id="docker://sha256:bbb",container_id="docker://cd456"} 1
317319
kube_pod_container_info{namespace="default",pod="pod0",uid="abc-0",container="pod1_con2",image_spec="k8s.gcr.io/hyperkube3_spec",image="k8s.gcr.io/hyperkube3",image_id="docker://sha256:ccc",container_id="docker://ef789"} 1

pkg/customresourcestate/registry_factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ func compilePath(path []string) (out valuePath, _ error) {
652652
// negative index
653653
i += len(s)
654654
}
655-
if i < 0 || i > len(s) {
655+
if i < 0 || i >= len(s) {
656656
return fmt.Errorf("list index out of range: %s", part)
657657
}
658658
return s[i]

0 commit comments

Comments
 (0)