Skip to content

Commit 9ce60cd

Browse files
committed
Merge branch 'main' into feat/3086-allow-configuration-prometheus-cr
# Conflicts: # bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml # bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml
2 parents 636b801 + 51f6888 commit 9ce60cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+304
-174
lines changed

.chloggen/fix-allocator-metric.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: breaking
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: target allocator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: "change metric `opentelemetry_allocator_targets_remaining` type from counter to gauge"
9+
10+
# One or more tracking issues related to the change
11+
issues: [3578]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

.chloggen/operator32.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: 'enhancement'
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. operator, target allocator, github action)
5+
component: operator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Add support for Kubernetes `1.32`
9+
10+
# One or more tracking issues related to the change
11+
issues: [3544]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

.github/workflows/changelog.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup Go
3434
uses: actions/setup-go@v5
3535
with:
36-
go-version: "~1.22.4"
36+
go-version: "~1.23.4"
3737

3838
- name: Ensure no changes to the CHANGELOG
3939
run: |

.github/workflows/continuous-integration.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
uses: actions/setup-go@v5
2323
id: setup-go
2424
with:
25-
go-version: "~1.22.4"
25+
go-version: "~1.23.4"
2626

2727
- name: Cache tools
2828
uses: actions/cache@v4
@@ -46,7 +46,7 @@ jobs:
4646
- name: Set up Go
4747
uses: actions/setup-go@v5
4848
with:
49-
go-version: "~1.22.4"
49+
go-version: "~1.23.4"
5050

5151
- name: Cache tools
5252
uses: actions/cache@v4
@@ -79,7 +79,7 @@ jobs:
7979
- name: Set up Go
8080
uses: actions/setup-go@v5
8181
with:
82-
go-version: "~1.22.4"
82+
go-version: "~1.23.4"
8383

8484
- name: Initialize CodeQL
8585
uses: github/codeql-action/init@v3

.github/workflows/e2e.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
# should be compatible with them.
2222
kube-version:
2323
- "1.23"
24-
- "1.31"
24+
- "1.32"
2525
group:
2626
- e2e
2727
- e2e-automatic-rbac
@@ -61,7 +61,7 @@ jobs:
6161
uses: actions/setup-go@v5
6262
id: setup-go
6363
with:
64-
go-version: "~1.22.4"
64+
go-version: "~1.23.4"
6565
- name: Cache tools
6666
uses: actions/cache@v4
6767
with:

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Set up Go
3737
uses: actions/setup-go@v5
3838
with:
39-
go-version: "~1.22.4"
39+
go-version: "~1.23.4"
4040

4141
- name: "generate release resources"
4242
run: make release-artifacts IMG_PREFIX="ghcr.io/open-telemetry/opentelemetry-operator" VERSION=${DESIRED_VERSION}

.github/workflows/scorecard.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818
matrix:
1919
kube-version:
2020
- "1.23"
21-
- "1.31"
21+
- "1.32"
2222

2323
steps:
2424

2525
- name: Set up Go
2626
uses: actions/setup-go@v5
2727
id: setup-go
2828
with:
29-
go-version: "~1.22.4"
29+
go-version: "~1.23.4"
3030

3131
- name: Check out code into the Go module directory
3232
uses: actions/checkout@v4

.golangci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
concurrency: 4
2+
concurrency: 3
33
timeout: 5m
44
issues-exit-code: 1
55
tests: true

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ endif
5959

6060
START_KIND_CLUSTER ?= true
6161

62-
KUBE_VERSION ?= 1.31
62+
KUBE_VERSION ?= 1.32
6363
KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml
6464
KIND_CLUSTER_NAME ?= "otel-operator"
6565

@@ -494,9 +494,9 @@ CHAINSAW ?= $(LOCALBIN)/chainsaw
494494
# renovate: datasource=go depName=sigs.k8s.io/kustomize/kustomize/v5
495495
KUSTOMIZE_VERSION ?= v5.5.0
496496
# renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen
497-
CONTROLLER_TOOLS_VERSION ?= v0.16.5
497+
CONTROLLER_TOOLS_VERSION ?= v0.17.0
498498
# renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint
499-
GOLANGCI_LINT_VERSION ?= v1.57.2
499+
GOLANGCI_LINT_VERSION ?= v1.63.4
500500
# renovate: datasource=go depName=sigs.k8s.io/kind
501501
KIND_VERSION ?= v0.26.0
502502
# renovate: datasource=go depName=github.com/kyverno/chainsaw

apis/v1beta1/config.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package v1beta1
1717
import (
1818
"bytes"
1919
"encoding/json"
20+
"errors"
2021
"fmt"
2122
"reflect"
2223
"regexp"
@@ -452,7 +453,7 @@ func (s *Service) MetricsEndpoint(logger logr.Logger) (string, int32, error) {
452453
errMsg := fmt.Sprintf("couldn't determine metrics port from configuration: %s",
453454
telemetry.Metrics.Address)
454455
logger.Info(errMsg)
455-
return "", 0, fmt.Errorf(errMsg)
456+
return "", 0, errors.New(errMsg)
456457
}
457458

458459
// The regex below matches on strings that end with a colon followed by 1 or more numbers (representing the port).

bundle/community/manifests/opentelemetry-operator.clusterserviceversion.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ metadata:
9999
categories: Logging & Tracing,Monitoring
100100
certified: "false"
101101
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
102-
createdAt: "2024-12-28T16:14:39Z"
102+
createdAt: "2024-12-31T13:16:02Z"
103103
description: Provides the OpenTelemetry components, including the Collector
104104
operators.operatorframework.io/builder: operator-sdk-v1.29.0
105105
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

bundle/community/manifests/opentelemetry.io_instrumentations.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.16.5
5+
controller-gen.kubebuilder.io/version: v0.17.0
66
creationTimestamp: null
77
labels:
88
app.kubernetes.io/name: opentelemetry-operator

bundle/community/manifests/opentelemetry.io_opampbridges.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: CustomResourceDefinition
33
metadata:
44
annotations:
55
cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert
6-
controller-gen.kubebuilder.io/version: v0.16.5
6+
controller-gen.kubebuilder.io/version: v0.17.0
77
creationTimestamp: null
88
labels:
99
app.kubernetes.io/name: opentelemetry-operator

bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: CustomResourceDefinition
33
metadata:
44
annotations:
55
cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert
6-
controller-gen.kubebuilder.io/version: v0.16.5
6+
controller-gen.kubebuilder.io/version: v0.17.0
77
creationTimestamp: null
88
labels:
99
app.kubernetes.io/name: opentelemetry-operator

bundle/openshift/manifests/opentelemetry-operator.clusterserviceversion.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ metadata:
9999
categories: Logging & Tracing,Monitoring
100100
certified: "false"
101101
containerImage: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator
102-
createdAt: "2024-12-28T16:14:44Z"
102+
createdAt: "2024-12-31T13:16:02Z"
103103
description: Provides the OpenTelemetry components, including the Collector
104104
operators.operatorframework.io/builder: operator-sdk-v1.29.0
105105
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3

bundle/openshift/manifests/opentelemetry.io_instrumentations.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.16.5
5+
controller-gen.kubebuilder.io/version: v0.17.0
66
creationTimestamp: null
77
labels:
88
app.kubernetes.io/name: opentelemetry-operator

bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: CustomResourceDefinition
33
metadata:
44
annotations:
55
cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert
6-
controller-gen.kubebuilder.io/version: v0.16.5
6+
controller-gen.kubebuilder.io/version: v0.17.0
77
creationTimestamp: null
88
labels:
99
app.kubernetes.io/name: opentelemetry-operator

bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: CustomResourceDefinition
33
metadata:
44
annotations:
55
cert-manager.io/inject-ca-from: opentelemetry-operator-system/opentelemetry-operator-serving-cert
6-
controller-gen.kubebuilder.io/version: v0.16.5
6+
controller-gen.kubebuilder.io/version: v0.17.0
77
creationTimestamp: null
88
labels:
99
app.kubernetes.io/name: opentelemetry-operator

cmd/operator-opamp-bridge/agent/agent.go

+55-10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package agent
1717
import (
1818
"bytes"
1919
"context"
20+
"errors"
2021
"fmt"
2122
"strings"
2223
"time"
@@ -95,10 +96,18 @@ func (agent *Agent) getHealth() *protobufs.ComponentHealth {
9596
LastError: err.Error(),
9697
}
9798
}
99+
statusTime, err := agent.getCurrentTimeUnixNano()
100+
if err != nil {
101+
return &protobufs.ComponentHealth{
102+
Healthy: false,
103+
StartTimeUnixNano: agent.startTime,
104+
LastError: err.Error(),
105+
}
106+
}
98107
return &protobufs.ComponentHealth{
99108
Healthy: true,
100109
StartTimeUnixNano: agent.startTime,
101-
StatusTimeUnixNano: uint64(agent.clock.Now().UnixNano()),
110+
StatusTimeUnixNano: statusTime,
102111
LastError: "",
103112
ComponentHealthMap: healthMap,
104113
}
@@ -124,9 +133,17 @@ func (agent *Agent) generateCollectorPoolHealth() (map[string]*protobufs.Compone
124133
for _, pod := range podMap {
125134
isPoolHealthy = isPoolHealthy && pod.Healthy
126135
}
136+
podStartTime, err := timeToUnixNanoUnsigned(col.ObjectMeta.GetCreationTimestamp().Time)
137+
if err != nil {
138+
return nil, err
139+
}
140+
statusTime, err := agent.getCurrentTimeUnixNano()
141+
if err != nil {
142+
return nil, err
143+
}
127144
healthMap[key.String()] = &protobufs.ComponentHealth{
128-
StartTimeUnixNano: uint64(col.ObjectMeta.GetCreationTimestamp().UnixNano()),
129-
StatusTimeUnixNano: uint64(agent.clock.Now().UnixNano()),
145+
StartTimeUnixNano: podStartTime,
146+
StatusTimeUnixNano: statusTime,
130147
Status: col.Status.Scale.StatusReplicas,
131148
ComponentHealthMap: podMap,
132149
Healthy: isPoolHealthy,
@@ -158,6 +175,10 @@ func (agent *Agent) getCollectorSelector(col v1beta1.OpenTelemetryCollector) map
158175
}
159176

160177
func (agent *Agent) generateCollectorHealth(selectorLabels map[string]string, namespace string) (map[string]*protobufs.ComponentHealth, error) {
178+
statusTime, err := agent.getCurrentTimeUnixNano()
179+
if err != nil {
180+
return nil, err
181+
}
161182
pods, err := agent.applier.GetCollectorPods(selectorLabels, namespace)
162183
if err != nil {
163184
return nil, err
@@ -169,15 +190,18 @@ func (agent *Agent) generateCollectorHealth(selectorLabels map[string]string, na
169190
if item.Status.Phase != "Running" {
170191
healthy = false
171192
}
172-
var startTime int64
193+
var startTime uint64
173194
if item.Status.StartTime != nil {
174-
startTime = item.Status.StartTime.UnixNano()
195+
startTime, err = timeToUnixNanoUnsigned(item.Status.StartTime.Time)
196+
if err != nil {
197+
return nil, err
198+
}
175199
} else {
176200
healthy = false
177201
}
178202
healthMap[key.String()] = &protobufs.ComponentHealth{
179-
StartTimeUnixNano: uint64(startTime),
180-
StatusTimeUnixNano: uint64(agent.clock.Now().UnixNano()),
203+
StartTimeUnixNano: startTime,
204+
StatusTimeUnixNano: statusTime,
181205
Status: string(item.Status.Phase),
182206
Healthy: healthy,
183207
}
@@ -197,7 +221,7 @@ func (agent *Agent) onConnectFailed(ctx context.Context, err error) {
197221

198222
// onError is called when an agent receives an error response from the server.
199223
func (agent *Agent) onError(ctx context.Context, err *protobufs.ServerErrorResponse) {
200-
agent.logger.Error(fmt.Errorf(err.GetErrorMessage()), "server returned an error response")
224+
agent.logger.Error(errors.New(err.GetErrorMessage()), "server returned an error response")
201225
}
202226

203227
// saveRemoteConfigStatus receives a status from the server when the server sets a remote configuration.
@@ -207,7 +231,11 @@ func (agent *Agent) saveRemoteConfigStatus(_ context.Context, status *protobufs.
207231

208232
// Start sets up the callbacks for the OpAMP client and begins the client's connection to the server.
209233
func (agent *Agent) Start() error {
210-
agent.startTime = uint64(agent.clock.Now().UnixNano())
234+
startTime, err := agent.getCurrentTimeUnixNano()
235+
if err != nil {
236+
return err
237+
}
238+
agent.startTime = startTime
211239
settings := types.StartSettings{
212240
OpAMPServerURL: agent.config.Endpoint,
213241
Header: agent.config.Headers.ToHTTPHeader(),
@@ -224,7 +252,7 @@ func (agent *Agent) Start() error {
224252
PackagesStateProvider: nil,
225253
Capabilities: agent.config.GetCapabilities(),
226254
}
227-
err := agent.opampClient.SetAgentDescription(agent.agentDescription)
255+
err = agent.opampClient.SetAgentDescription(agent.agentDescription)
228256
if err != nil {
229257
return err
230258
}
@@ -429,3 +457,20 @@ func (agent *Agent) onMessage(ctx context.Context, msg *types.MessageData) {
429457
agent.initMeter(msg.OwnMetricsConnSettings)
430458
}
431459
}
460+
461+
// getCurrentTimeUnixNano returns the current time as a uint64, which the protocol expects.
462+
func (agent *Agent) getCurrentTimeUnixNano() (uint64, error) {
463+
// technically this could be negative if the system time is set to before 1970-01-1
464+
// the proto demands this to be a nonnegative number, so in that case, just return 0
465+
return timeToUnixNanoUnsigned(agent.clock.Now())
466+
}
467+
468+
// timeToUnixNanoUnsigned returns the number of nanoseconds elapsed from 1970-01-01 to the given time, but returns an
469+
// error if the value is negative. OpAMP expects these values to be non-negative.
470+
func timeToUnixNanoUnsigned(t time.Time) (uint64, error) {
471+
signedUnixNano := t.UnixNano()
472+
if signedUnixNano < 0 {
473+
return 0, fmt.Errorf("invalid system time, must be after 01-01-1970 due to OpAMP requirements: %v", t)
474+
}
475+
return uint64(signedUnixNano), nil
476+
}

0 commit comments

Comments
 (0)