Skip to content

Commit 230ce39

Browse files
authored
Merge branch 'main' into renovate/github.com-prometheus-common-0.x
2 parents 37967af + 545cfd9 commit 230ce39

File tree

12 files changed

+110
-60
lines changed

12 files changed

+110
-60
lines changed

.github/workflows/nightlyAndMainImage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
-t $DOCKER_IMAGE_NAME:ci-scan \
7878
.
7979
- name: Run Trivy vulnerability scanner
80-
uses: aquasecurity/trivy-action@0.29.0
80+
uses: aquasecurity/trivy-action@0.30.0
8181
with:
8282
image-ref: '${{ env.DOCKER_IMAGE_NAME }}:ci-scan'
8383
format: 'table'

.github/workflows/windows-infra-agent.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
env:
3030
AGENT_VERSION: 1.62.0 # hard-coded agent version for now
3131
steps:
32-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v4
3333
- uses: actions/setup-go@v5
3434
with:
3535
go-version-file: 'go.mod'

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## Unreleased
99

10+
## v3.35.1 - 2025-03-24
11+
12+
### ⛓️ Dependencies
13+
- Updated github.com/spf13/viper to v1.20.0 - [Changelog 🔗](https://github.com/spf13/viper/releases/tag/v1.20.0)
14+
- Updated go to v1.24.1
15+
- Updated golang.org/x/crypto to v0.36.0
16+
- Updated github.com/google/go-cmp to v0.7.0 - [Changelog 🔗](https://github.com/google/go-cmp/releases/tag/v0.7.0)
17+
18+
## v3.36.0 - 2025-03-24
19+
20+
### 🚀 Enhancements
21+
- Added support for last terminated exit code in metrics @danielstokes [#1173](https://github.com/newrelic/nri-kubernetes/pull/1173)
22+
1023
## v3.35.0 - 2025-03-17
1124

1225
### 🚀 Enhancements

charts/newrelic-infrastructure/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ sources:
77
- https://github.com/newrelic/nri-kubernetes/
88
- https://github.com/newrelic/nri-kubernetes/tree/main/charts/newrelic-infrastructure
99
- https://github.com/newrelic/infrastructure-agent/
10-
version: 3.40.0
11-
appVersion: 3.35.0
10+
version: 3.40.1
11+
appVersion: 3.35.1
1212
dependencies:
1313
- name: common-library
1414
version: 1.3.1

charts/newrelic-infrastructure/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ images:
3030
agent:
3131
registry: ""
3232
repository: newrelic/infrastructure-bundle
33-
tag: 3.2.68
33+
tag: 3.2.69
3434
pullPolicy: IfNotPresent
3535
# -- Image for the New Relic Kubernetes integration.
3636
# @default -- See `values.yaml`

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/sirupsen/logrus v1.9.3
1414
github.com/spf13/viper v1.20.0
1515
github.com/stretchr/testify v1.10.0
16-
google.golang.org/protobuf v1.36.5
16+
google.golang.org/protobuf v1.36.6
1717
k8s.io/api v0.32.1
1818
k8s.io/apimachinery v0.32.1
1919
k8s.io/client-go v0.32.1

go.sum

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6
3232
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
3333
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
3434
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
35-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
3635
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3736
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
3837
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
@@ -205,6 +204,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
205204
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
206205
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
207206
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
207+
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
208+
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
208209
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
209210
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
210211
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

src/kubelet/metric/pods.go

+22-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"strings"
99
"time"
1010

11-
log "github.com/sirupsen/logrus"
12-
v1 "k8s.io/api/core/v1"
13-
1411
"github.com/newrelic/nri-kubernetes/v3/src/client"
1512
"github.com/newrelic/nri-kubernetes/v3/src/definition"
13+
14+
log "github.com/sirupsen/logrus"
15+
v1 "k8s.io/api/core/v1"
1616
)
1717

1818
// KubeletPodsPath is the path where kubelet serves information about pods.
@@ -182,6 +182,16 @@ func fillContainerStatuses(pod *v1.Pod, dest map[string]definition.RawMetrics) {
182182
name := c.Name
183183
id := containerID(pod, name)
184184

185+
// Set the ExitCode. Zero if no terminated Exit Code.
186+
var lastTerminatedExitCode int32
187+
lastTerminatedExitReason := "None"
188+
var lastTerminatedFinishedAt string
189+
if c.LastTerminationState.Terminated != nil {
190+
lastTerminatedExitCode = c.LastTerminationState.Terminated.ExitCode
191+
lastTerminatedExitReason = c.LastTerminationState.Terminated.Reason
192+
lastTerminatedFinishedAt = c.LastTerminationState.Terminated.FinishedAt.Time.In(time.UTC).Format(time.RFC3339)
193+
}
194+
185195
dest[id] = make(definition.RawMetrics)
186196

187197
switch {
@@ -190,15 +200,23 @@ func fillContainerStatuses(pod *v1.Pod, dest map[string]definition.RawMetrics) {
190200
dest[id]["startedAt"] = c.State.Running.StartedAt.Time.In(time.UTC) // TODO WE DO NOT REPORT THAT METRIC
191201
dest[id]["restartCount"] = c.RestartCount
192202
dest[id]["isReady"] = c.Ready
203+
dest[id]["lastTerminatedExitCode"] = lastTerminatedExitCode
204+
dest[id]["lastTerminatedExitReason"] = lastTerminatedExitReason
205+
dest[id]["lastTerminatedTimestamp"] = lastTerminatedFinishedAt
193206
case c.State.Waiting != nil:
194207
dest[id]["status"] = "Waiting"
195208
dest[id]["reason"] = c.State.Waiting.Reason
196209
dest[id]["restartCount"] = c.RestartCount
210+
dest[id]["lastTerminatedExitCode"] = lastTerminatedExitCode
211+
dest[id]["lastTerminatedExitReason"] = lastTerminatedExitReason
212+
dest[id]["lastTerminatedTimestamp"] = lastTerminatedFinishedAt
197213
case c.State.Terminated != nil:
198214
dest[id]["status"] = "Terminated"
199215
dest[id]["reason"] = c.State.Terminated.Reason
200216
dest[id]["restartCount"] = c.RestartCount
201-
dest[id]["startedAt"] = c.State.Terminated.StartedAt.Time.In(time.UTC) // TODO WE DO NOT REPORT THAT METRIC
217+
dest[id]["lastTerminatedExitCode"] = lastTerminatedExitCode
218+
dest[id]["lastTerminatedExitReason"] = lastTerminatedExitReason
219+
dest[id]["lastTerminatedTimestamp"] = lastTerminatedFinishedAt
202220
default:
203221
dest[id]["status"] = "Unknown"
204222
}

src/kubelet/metric/testdata/kubelet_group_expected.go

+42-36
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,34 @@ var ExpectedGroupData = definition.RawGroups{
128128
},
129129
"container": {
130130
"kube-system_newrelic-infra-rz225_newrelic-infra": {
131-
"containerName": "newrelic-infra",
132-
"containerID": "69d7203a8f2d2d027ffa51d61002eac63357f22a17403363ef79e66d1c3146b2",
133-
"containerImage": "newrelic/ohaik:1.0.0-beta3",
134-
"containerImageID": "sha256:1a95d0df2997f93741fbe2a15d2c31a394e752fd942ec29bf16a44163342f6a1",
135-
"namespace": "kube-system",
136-
"podName": "newrelic-infra-rz225",
137-
"daemonsetName": "newrelic-infra",
138-
"nodeName": "minikube",
139-
"nodeIP": "192.168.99.100",
140-
"restartCount": int32(6),
141-
"isReady": true,
142-
"status": "Running",
143-
"startedAt": parseTime("2018-02-27T15:21:16Z"),
144-
"cpuRequestedCores": int64(100),
145-
"memoryRequestedBytes": int64(104857600),
146-
"memoryLimitBytes": int64(104857600),
147-
"usageBytes": uint64(18083840),
148-
"workingSetBytes": uint64(17113088),
149-
"usageNanoCores": uint64(17428240),
150-
"fsAvailableBytes": uint64(14924988416),
151-
"fsUsedBytes": uint64(126976),
152-
"fsCapacityBytes": uint64(17293533184),
153-
"fsInodesFree": uint64(9713372),
154-
"fsInodes": uint64(9732096),
155-
"fsInodesUsed": uint64(36),
131+
"containerName": "newrelic-infra",
132+
"containerID": "69d7203a8f2d2d027ffa51d61002eac63357f22a17403363ef79e66d1c3146b2",
133+
"containerImage": "newrelic/ohaik:1.0.0-beta3",
134+
"containerImageID": "sha256:1a95d0df2997f93741fbe2a15d2c31a394e752fd942ec29bf16a44163342f6a1",
135+
"namespace": "kube-system",
136+
"podName": "newrelic-infra-rz225",
137+
"daemonsetName": "newrelic-infra",
138+
"nodeName": "minikube",
139+
"nodeIP": "192.168.99.100",
140+
"restartCount": int32(6),
141+
"isReady": true,
142+
"status": "Running",
143+
"startedAt": parseTime("2018-02-27T15:21:16Z"),
144+
"lastTerminatedExitCode": int32(0),
145+
"lastTerminatedExitReason": "Completed",
146+
"lastTerminatedTimestamp": "2018-02-27T15:21:10Z",
147+
"cpuRequestedCores": int64(100),
148+
"memoryRequestedBytes": int64(104857600),
149+
"memoryLimitBytes": int64(104857600),
150+
"usageBytes": uint64(18083840),
151+
"workingSetBytes": uint64(17113088),
152+
"usageNanoCores": uint64(17428240),
153+
"fsAvailableBytes": uint64(14924988416),
154+
"fsUsedBytes": uint64(126976),
155+
"fsCapacityBytes": uint64(17293533184),
156+
"fsInodesFree": uint64(9713372),
157+
"fsInodes": uint64(9732096),
158+
"fsInodesUsed": uint64(36),
156159
"labels": map[string]string{
157160
"controller-revision-hash": "3887482659",
158161
"name": "newrelic-infra",
@@ -240,14 +243,17 @@ var ExpectedGroupData = definition.RawGroups{
240243
},
241244
},
242245
"kube-system_kube-controller-manager-minikube_kube-controller-manager": {
243-
"containerName": "kube-controller-manager",
244-
"containerImage": "k8s.gcr.io/kube-controller-manager:v1.16.0",
245-
"nodeIP": "192.168.99.100",
246-
"cpuRequestedCores": int64(200),
247-
"status": "Running",
248-
"startedAt": parseTime("2019-10-23T17:10:49Z"),
249-
"restartCount": int32(1),
250-
"isReady": bool(true),
246+
"containerName": "kube-controller-manager",
247+
"containerImage": "k8s.gcr.io/kube-controller-manager:v1.16.0",
248+
"nodeIP": "192.168.99.100",
249+
"cpuRequestedCores": int64(200),
250+
"status": "Running",
251+
"lastTerminatedExitCode": int32(255),
252+
"lastTerminatedExitReason": "Error",
253+
"lastTerminatedTimestamp": "2019-10-23T17:10:25Z",
254+
"startedAt": parseTime("2019-10-23T17:10:49Z"),
255+
"restartCount": int32(1),
256+
"isReady": bool(true),
251257
"labels": map[string]string{
252258
"k8s-app": "kube-controller-manager",
253259
"component": "kube-controller-manager",
@@ -287,9 +293,9 @@ var ExpectedGroupData = definition.RawGroups{
287293
"usageCoreNanoSeconds": uint64(22332102208229),
288294
"usageNanoCores": uint64(228759290),
289295
"labels": map[string]string{
290-
"kubernetes.io/arch": "amd64",
291-
"kubernetes.io/hostname": "minikube",
292-
"kubernetes.io/os": "linux",
296+
"kubernetes.io/arch": "amd64",
297+
"kubernetes.io/hostname": "minikube",
298+
"kubernetes.io/os": "linux",
293299
"node-role.kubernetes.io/control-plane": "",
294300
},
295301
"cpuRequestedCores": int64(501),

src/kubelet/metric/testdata/kubelet_pods_expected.go

+19-13
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,13 @@ var ExpectedRawData = definition.RawGroups{
9999
"isReady": true,
100100
"status": "Running",
101101
// "reason": "", // TODO
102-
"startedAt": parseTime("2018-02-27T15:21:16Z"),
103-
"cpuRequestedCores": int64(100),
104-
"memoryRequestedBytes": int64(104857600),
105-
"memoryLimitBytes": int64(104857600),
102+
"startedAt": parseTime("2018-02-27T15:21:16Z"),
103+
"lastTerminatedExitCode": int32(0),
104+
"lastTerminatedExitReason": "Completed",
105+
"lastTerminatedTimestamp": "2018-02-27T15:21:10Z",
106+
"cpuRequestedCores": int64(100),
107+
"memoryRequestedBytes": int64(104857600),
108+
"memoryLimitBytes": int64(104857600),
106109
"labels": map[string]string{
107110
"controller-revision-hash": "3887482659",
108111
"name": "newrelic-infra",
@@ -177,15 +180,18 @@ var ExpectedRawData = definition.RawGroups{
177180
"k8s-app": "kube-controller-manager",
178181
"component": "kube-controller-manager",
179182
},
180-
"podName": "kube-controller-manager-minikube",
181-
"containerImage": "k8s.gcr.io/kube-controller-manager:v1.16.0",
182-
"namespace": "kube-system",
183-
"nodeIP": "192.168.99.100",
184-
"cpuRequestedCores": int64(200),
185-
"status": "Running",
186-
"startedAt": parseTime("2019-10-23T17:10:49Z"),
187-
"restartCount": int32(1),
188-
"containerName": "kube-controller-manager",
183+
"podName": "kube-controller-manager-minikube",
184+
"containerImage": "k8s.gcr.io/kube-controller-manager:v1.16.0",
185+
"namespace": "kube-system",
186+
"nodeIP": "192.168.99.100",
187+
"cpuRequestedCores": int64(200),
188+
"status": "Running",
189+
"lastTerminatedExitCode": int32(255),
190+
"lastTerminatedExitReason": "Error",
191+
"lastTerminatedTimestamp": "2019-10-23T17:10:25Z",
192+
"startedAt": parseTime("2019-10-23T17:10:49Z"),
193+
"restartCount": int32(1),
194+
"containerName": "kube-controller-manager",
189195
},
190196
},
191197
}

src/metric/definition.go

+3
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,9 @@ var KubeletSpecs = definition.SpecGroups{
13121312
{Name: "status", ValueFunc: definition.FromRaw("status"), Type: sdkMetric.ATTRIBUTE},
13131313
{Name: "isReady", ValueFunc: definition.Transform(definition.FromRaw("isReady"), toNumericBoolean), Type: sdkMetric.GAUGE},
13141314
{Name: "reason", ValueFunc: definition.FromRaw("reason"), Type: sdkMetric.ATTRIBUTE, Optional: true}, // Previously called statusWaitingReason
1315+
{Name: "lastTerminatedExitCode", ValueFunc: definition.FromRaw("lastTerminatedExitCode"), Type: sdkMetric.GAUGE, Optional: true},
1316+
{Name: "lastTerminatedExitReason", ValueFunc: definition.FromRaw("lastTerminatedExitReason"), Type: sdkMetric.ATTRIBUTE, Optional: true},
1317+
{Name: "lastTerminatedTimestamp", ValueFunc: definition.FromRaw("lastTerminatedTimestamp"), Type: sdkMetric.ATTRIBUTE, Optional: true},
13151318

13161319
// Inherit from pod
13171320
{Name: "label.*", ValueFunc: definition.Transform(definition.FromRaw("labels"), kubeletMetric.OneMetricPerLabel), Type: sdkMetric.ATTRIBUTE},

src/scrape/scrape_job_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ var expectedEntities = []*integration.Entity{
131131
"status": "Running",
132132
"isReady": float64(1),
133133
//"reason": "", // TODO ?
134+
"lastTerminatedExitCode": float64(0),
135+
"lastTerminatedExitReason": "Completed",
136+
"lastTerminatedTimestamp": "2018-02-27T15:21:10Z",
134137
"displayName": "newrelic-infra", // From entity attributes
135138
"clusterName": "test-cluster", // From entity attributes
136139
"label.controller-revision-hash": "3887482659",

0 commit comments

Comments
 (0)