Skip to content

Commit b0c55e3

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operator into feature/3149
2 parents 9e4e9d4 + 934c1d8 commit b0c55e3

Some content is hidden

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

41 files changed

+458
-53
lines changed

.chloggen/add-ip-families.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. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: 'collector'
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: "Enabling ipFamilies and ipFamilyPolicy to be configured via OpenTelemetryCollector"
9+
10+
# One or more tracking issues related to the change
11+
issues: [2958]
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:

Makefile

+14-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ TARGETALLOCATOR_IMG ?= ${IMG_PREFIX}/${TARGETALLOCATOR_IMG_REPO}:$(addprefix v,$
3535
OPERATOROPAMPBRIDGE_IMG_REPO ?= operator-opamp-bridge
3636
OPERATOROPAMPBRIDGE_IMG ?= ${IMG_PREFIX}/${OPERATOROPAMPBRIDGE_IMG_REPO}:$(addprefix v,${VERSION})
3737

38+
BRIDGETESTSERVER_IMG_REPO ?= e2e-test-app-bridge-server
39+
BRIDGETESTSERVER_IMG ?= ${IMG_PREFIX}/${BRIDGETESTSERVER_IMG_REPO}:ve2e
40+
3841
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
3942
ifeq (,$(shell go env GOBIN))
4043
GOBIN=$(shell go env GOPATH)/bin
@@ -319,7 +322,7 @@ e2e-upgrade: undeploy chainsaw
319322
$(CHAINSAW) test --test-dir ./tests/e2e-upgrade
320323

321324
.PHONY: prepare-e2e
322-
prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-opampbridge container container-target-allocator container-operator-opamp-bridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
325+
prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-opampbridge container container-target-allocator container-operator-opamp-bridge container-bridge-test-server start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
323326

324327
.PHONY: scorecard-tests
325328
scorecard-tests: operator-sdk
@@ -357,6 +360,11 @@ container-operator-opamp-bridge: GOOS = linux
357360
container-operator-opamp-bridge: operator-opamp-bridge
358361
docker build -t ${OPERATOROPAMPBRIDGE_IMG} cmd/operator-opamp-bridge
359362

363+
.PHONY: container-bridge-test-server
364+
container-bridge-test-server: GOOS = linux
365+
container-bridge-test-server:
366+
docker build -t ${BRIDGETESTSERVER_IMG} tests/test-e2e-apps/bridge-server
367+
360368
.PHONY: start-kind
361369
start-kind: kind
362370
ifeq (true,$(START_KIND_CLUSTER))
@@ -373,7 +381,7 @@ install-targetallocator-prometheus-crds:
373381
./hack/install-targetallocator-prometheus-crds.sh
374382

375383
.PHONY: load-image-all
376-
load-image-all: load-image-operator load-image-target-allocator load-image-operator-opamp-bridge
384+
load-image-all: load-image-operator load-image-target-allocator load-image-operator-opamp-bridge load-image-bridge-test-server
377385

378386
.PHONY: load-image-operator
379387
load-image-operator: container kind
@@ -392,6 +400,9 @@ else
392400
$(MAKE) container-target-allocator-push
393401
endif
394402

403+
.PHONY: load-image-bridge-test-server
404+
load-image-bridge-test-server: container-bridge-test-server kind
405+
$(KIND) load --name $(KIND_CLUSTER_NAME) docker-image ${BRIDGETESTSERVER_IMG}
395406

396407
.PHONY: load-image-operator-opamp-bridge
397408
load-image-operator-opamp-bridge: container-operator-opamp-bridge kind
@@ -499,7 +510,7 @@ operator-sdk: $(LOCALBIN)
499510
# Generate bundle manifests and metadata, then validate generated files.
500511
.PHONY: generate-bundle
501512
generate-bundle: kustomize operator-sdk manifests set-image-controller api-docs
502-
sed -i 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
513+
sed -e 's/minKubeVersion: .*/minKubeVersion: $(MIN_KUBERNETES_VERSION)/' config/manifests/$(BUNDLE_VARIANT)/bases/opentelemetry-operator.clusterserviceversion.yaml
503514

504515
$(OPERATOR_SDK) generate kustomize manifests -q --input-dir $(MANIFESTS_DIR) --output-dir $(MANIFESTS_DIR)
505516
cd $(BUNDLE_DIR) && cp ../../PROJECT . && $(KUSTOMIZE) build ../../$(MANIFESTS_DIR) | $(OPERATOR_SDK) generate bundle $(BUNDLE_BUILD_GEN_FLAGS) && rm PROJECT

apis/v1alpha1/opampbridge_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ type OpAMPBridgeSpec struct {
107107
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
108108
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
109109
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
110+
// IPFamily represents the IP Family (IPv4 or IPv6). This type is used
111+
// to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).
112+
// +optional
113+
IpFamilies []v1.IPFamily `json:"ipFamilies,omitempty"`
114+
// IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
115+
IpFamilyPolicy *v1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"`
110116
}
111117

112118
// OpAMPBridgeStatus defines the observed state of OpAMPBridge.

apis/v1alpha1/zz_generated.deepcopy.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1beta1/common.go

+8
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ type OpenTelemetryCommonFields struct {
226226
AdditionalContainers []v1.Container `json:"additionalContainers,omitempty"`
227227
// PodDNSConfig defines the DNS parameters of a pod in addition to those generated from DNSPolicy.
228228
PodDNSConfig v1.PodDNSConfig `json:"podDnsConfig,omitempty"`
229+
// IPFamily represents the IP Family (IPv4 or IPv6). This type is used
230+
// to express the family of an IP expressed by a type (e.g. service.spec.ipFamilies).
231+
// +optional
232+
IpFamilies []v1.IPFamily `json:"ipFamilies,omitempty"`
233+
// IPFamilyPolicy represents the dual-stack-ness requested or required by a Service
234+
// +kubebuilder:default:=SingleStack
235+
// +optional
236+
IpFamilyPolicy *v1.IPFamilyPolicy `json:"ipFamilyPolicy,omitempty"`
229237
}
230238

231239
type StatefulSetCommonFields struct {

apis/v1beta1/zz_generated.deepcopy.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/community/manifests/opentelemetry.io_opampbridges.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ spec:
592592
type: string
593593
imagePullPolicy:
594594
type: string
595+
ipFamilies:
596+
items:
597+
type: string
598+
type: array
599+
ipFamilyPolicy:
600+
type: string
595601
nodeSelector:
596602
additionalProperties:
597603
type: string

bundle/community/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6739,6 +6739,13 @@ spec:
67396739
- name
67406740
type: object
67416741
type: array
6742+
ipFamilies:
6743+
items:
6744+
type: string
6745+
type: array
6746+
ipFamilyPolicy:
6747+
default: SingleStack
6748+
type: string
67426749
lifecycle:
67436750
properties:
67446751
postStart:

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

+2-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-07-18T14:09:56Z"
102+
createdAt: "2024-07-20T18:51:11Z"
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
@@ -501,6 +501,7 @@ spec:
501501
- --enable-nginx-instrumentation=true
502502
- --enable-go-instrumentation=true
503503
- --enable-multi-instrumentation=true
504+
- --openshift-create-dashboard=true
504505
- --feature-gates=+operator.observability.prometheus
505506
env:
506507
- name: SERVICE_ACCOUNT_NAME

bundle/openshift/manifests/opentelemetry.io_opampbridges.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ spec:
592592
type: string
593593
imagePullPolicy:
594594
type: string
595+
ipFamilies:
596+
items:
597+
type: string
598+
type: array
599+
ipFamilyPolicy:
600+
type: string
595601
nodeSelector:
596602
additionalProperties:
597603
type: string

bundle/openshift/manifests/opentelemetry.io_opentelemetrycollectors.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6739,6 +6739,13 @@ spec:
67396739
- name
67406740
type: object
67416741
type: array
6742+
ipFamilies:
6743+
items:
6744+
type: string
6745+
type: array
6746+
ipFamilyPolicy:
6747+
default: SingleStack
6748+
type: string
67426749
lifecycle:
67436750
properties:
67446751
postStart:

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"time"
2323

2424
"github.com/go-logr/logr"
25-
"github.com/oklog/ulid/v2"
25+
"github.com/google/uuid"
2626
"github.com/open-telemetry/opamp-go/client"
2727
"github.com/open-telemetry/opamp-go/client/types"
2828
"github.com/open-telemetry/opamp-go/protobufs"
@@ -44,7 +44,7 @@ type Agent struct {
4444
startTime uint64
4545
lastHash []byte
4646

47-
instanceId ulid.ULID
47+
instanceId uuid.UUID
4848
agentDescription *protobufs.AgentDescription
4949
remoteConfigStatus *protobufs.RemoteConfigStatus
5050

@@ -211,7 +211,7 @@ func (agent *Agent) Start() error {
211211
settings := types.StartSettings{
212212
OpAMPServerURL: agent.config.Endpoint,
213213
Header: agent.config.Headers.ToHTTPHeader(),
214-
InstanceUid: agent.instanceId.String(),
214+
InstanceUid: types.InstanceUid(agent.instanceId),
215215
Callbacks: types.CallbacksStruct{
216216
OnConnectFunc: agent.onConnect,
217217
OnConnectFailedFunc: agent.onConnectFailed,
@@ -274,7 +274,7 @@ func (agent *Agent) runHeartbeat() {
274274

275275
// updateAgentIdentity receives a new instanced Id from the remote server and updates the agent's instanceID field.
276276
// The meter will be reinitialized by the onMessage function.
277-
func (agent *Agent) updateAgentIdentity(instanceId ulid.ULID) {
277+
func (agent *Agent) updateAgentIdentity(instanceId uuid.UUID) {
278278
agent.logger.V(3).Info("Agent identity is being changed",
279279
"old instanceId", agent.instanceId.String(),
280280
"new instanceid", instanceId.String())
@@ -416,12 +416,12 @@ func (agent *Agent) onMessage(ctx context.Context, msg *types.MessageData) {
416416
// The instance id is updated prior to the meter initialization so that the new meter will report using the updated
417417
// instanceId.
418418
if msg.AgentIdentification != nil {
419-
newInstanceId, err := ulid.Parse(msg.AgentIdentification.NewInstanceUid)
419+
uid, err := uuid.FromBytes(msg.AgentIdentification.NewInstanceUid)
420420
if err != nil {
421421
agent.logger.Error(err, "couldn't parse instance UID")
422422
return
423423
}
424-
agent.updateAgentIdentity(newInstanceId)
424+
agent.updateAgentIdentity(uid)
425425
}
426426

427427
if msg.OwnMetricsConnSettings != nil {

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ package agent
1616

1717
import (
1818
"context"
19-
"crypto/rand"
2019
"fmt"
2120
"os"
2221
"sort"
2322
"testing"
2423
"time"
2524

2625
"github.com/go-logr/logr"
27-
"github.com/oklog/ulid/v2"
26+
"github.com/google/uuid"
2827
"github.com/open-telemetry/opamp-go/client"
2928
"github.com/open-telemetry/opamp-go/client/types"
3029
"github.com/open-telemetry/opamp-go/protobufs"
@@ -883,15 +882,20 @@ func Test_CanUpdateIdentity(t *testing.T) {
883882
defer agent.Shutdown()
884883
require.NoError(t, err, "should be able to start agent")
885884
previousInstanceId := agent.instanceId.String()
886-
entropy := ulid.Monotonic(rand.Reader, 0)
887-
newId := ulid.MustNew(ulid.MaxTime(), entropy)
885+
newId, err := uuid.NewV7()
886+
require.NoError(t, err)
887+
marshalledId, err := newId.MarshalBinary()
888+
require.NoError(t, err)
888889
agent.onMessage(context.Background(), &types.MessageData{
889890
AgentIdentification: &protobufs.AgentIdentification{
890-
NewInstanceUid: newId.String(),
891+
NewInstanceUid: marshalledId,
891892
},
892893
})
893894
assert.NotEqual(t, previousInstanceId, newId.String())
894895
assert.Equal(t, agent.instanceId, newId)
896+
parsedUUID, err := uuid.FromBytes(marshalledId)
897+
require.NoError(t, err)
898+
assert.Equal(t, newId, parsedUUID)
895899
}
896900

897901
func getMessageDataFromConfigFile(filemap map[string]string) (*types.MessageData, error) {

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package config
1616

1717
import (
18-
"crypto/rand"
1918
"errors"
2019
"fmt"
2120
"io/fs"
@@ -25,7 +24,7 @@ import (
2524
"time"
2625

2726
"github.com/go-logr/logr"
28-
"github.com/oklog/ulid/v2"
27+
"github.com/google/uuid"
2928
opampclient "github.com/open-telemetry/opamp-go/client"
3029
"github.com/open-telemetry/opamp-go/protobufs"
3130
"github.com/spf13/pflag"
@@ -186,9 +185,13 @@ func keyValuePair(key string, value string) *protobufs.KeyValue {
186185
}
187186
}
188187

189-
func (c *Config) GetNewInstanceId() ulid.ULID {
190-
entropy := ulid.Monotonic(rand.Reader, 0)
191-
return ulid.MustNew(ulid.Timestamp(time.Now()), entropy)
188+
func (c *Config) GetNewInstanceId() uuid.UUID {
189+
u, err := uuid.NewV7()
190+
if err != nil {
191+
// This really should never happen and if it does we should fail.
192+
panic(err)
193+
}
194+
return u
192195
}
193196

194197
func (c *Config) RemoteConfigEnabled() bool {

cmd/operator-opamp-bridge/metrics/reporter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"time"
2323

2424
"github.com/go-logr/logr"
25-
"github.com/oklog/ulid/v2"
25+
"github.com/google/uuid"
2626
"github.com/open-telemetry/opamp-go/protobufs"
2727
"github.com/shirou/gopsutil/process"
2828
"go.opentelemetry.io/otel/attribute"
@@ -53,7 +53,7 @@ type MetricReporter struct {
5353
// NewMetricReporter creates an OTLP/HTTP client to the destination address supplied by the server.
5454
// TODO: do more validation on the endpoint, allow for gRPC.
5555
// TODO: set global provider and add more metrics to be reported.
56-
func NewMetricReporter(logger logr.Logger, dest *protobufs.TelemetryConnectionSettings, agentType string, agentVersion string, instanceId ulid.ULID) (*MetricReporter, error) {
56+
func NewMetricReporter(logger logr.Logger, dest *protobufs.TelemetryConnectionSettings, agentType string, agentVersion string, instanceId uuid.UUID) (*MetricReporter, error) {
5757

5858
if dest.DestinationEndpoint == "" {
5959
return nil, fmt.Errorf("metric destination must specify DestinationEndpoint")

config/crd/bases/opentelemetry.io_opampbridges.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,12 @@ spec:
589589
type: string
590590
imagePullPolicy:
591591
type: string
592+
ipFamilies:
593+
items:
594+
type: string
595+
type: array
596+
ipFamilyPolicy:
597+
type: string
592598
nodeSelector:
593599
additionalProperties:
594600
type: string

config/crd/bases/opentelemetry.io_opentelemetrycollectors.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6725,6 +6725,13 @@ spec:
67256725
- name
67266726
type: object
67276727
type: array
6728+
ipFamilies:
6729+
items:
6730+
type: string
6731+
type: array
6732+
ipFamilyPolicy:
6733+
default: SingleStack
6734+
type: string
67286735
lifecycle:
67296736
properties:
67306737
postStart:

config/crd/bases/opentelemetry.io_targetallocators.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,13 @@ spec:
19291929
- name
19301930
type: object
19311931
type: array
1932+
ipFamilies:
1933+
items:
1934+
type: string
1935+
type: array
1936+
ipFamilyPolicy:
1937+
default: SingleStack
1938+
type: string
19321939
lifecycle:
19331940
properties:
19341941
postStart:

config/overlays/openshift/manager-patch.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
- --enable-nginx-instrumentation=true
99
- '--enable-go-instrumentation=true'
1010
- '--enable-multi-instrumentation=true'
11+
- '--openshift-create-dashboard=true'
1112
- '--feature-gates=+operator.observability.prometheus'

0 commit comments

Comments
 (0)