Skip to content

Commit b452e80

Browse files
authored
Merge branch 'main' into operator32
2 parents 136382f + ea0da98 commit b452e80

Some content is hidden

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

46 files changed

+1517
-412
lines changed

.github/workflows/publish-autoinstrumentation-java.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java
3838
tags: |
3939
type=match,pattern=v(.*),group=1,value=v${{ env.VERSION }}
40+
type=semver,pattern={{major}},value=v${{ env.VERSION }}
4041
4142
- name: Set up QEMU
4243
uses: docker/setup-qemu-action@v3

CHANGELOG.md

+33
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,39 @@
22

33
<!-- next version -->
44

5+
## 0.116.0
6+
7+
### 💡 Enhancements 💡
8+
9+
- `target allocator`: Process discovered targets asyncchronously (#1842)
10+
This change enables the target allocator to process discovered targets asynchronously.
11+
This is a significant performance improvement for the target allocator, as it allows it to process targets in parallel, rather than sequentially.
12+
This change also introduces new metrics to track the performance of the target allocator.
13+
- opentelemetry_allocator_process_targets_duration_seconds: The duration of the process targets operation.
14+
- opentelemetry_allocator_process_target_groups_duration_seconds: The duration of the process target groups operation.
15+
16+
17+
### 🧰 Bug fixes 🧰
18+
19+
- `operator`: Fix the admission webhook to when metrics service address host uses env var expansion (#3513)
20+
This should allow the metrics service address to have the host portion expanded from an environment variable,
21+
like `$(env:POD_IP)` instead of using `0.0.0.0`, which is the [recommended by the Collector](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks).
22+
23+
- `auto-instrumentation`: Apache instrumentation sidecar fails to start if target container define lifecycle (#3547)
24+
- `collector`: Fix deletion of optional resources for OpenTelemetryCollector CRs (#3454)
25+
26+
### Components
27+
28+
* [OpenTelemetry Collector - v0.116.1](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.116.1)
29+
* [OpenTelemetry Contrib - v0.116.1](https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/tag/v0.116.1)
30+
* [Java auto-instrumentation - v1.33.5](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v1.33.5)
31+
* [.NET auto-instrumentation - v1.2.0](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/tag/v1.2.0)
32+
* [Node.JS - v0.53.0](https://github.com/open-telemetry/opentelemetry-js/releases/tag/experimental%2Fv0.53.0)
33+
* [Python - v0.50b0](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.50b0)
34+
* [Go - v0.19.0-alpha](https://github.com/open-telemetry/opentelemetry-go-instrumentation/releases/tag/v0.19.0-alpha)
35+
* [ApacheHTTPD - 1.1.0](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.1.0)
36+
* [Nginx - 1.1.0](https://github.com/open-telemetry/opentelemetry-cpp-contrib/releases/tag/webserver%2Fv1.1.0)
37+
538
## 0.115.0
639

740
### 💡 Enhancements 💡

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,9 @@ KUSTOMIZE_VERSION ?= v5.5.0
496496
# renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen
497497
CONTROLLER_TOOLS_VERSION ?= v0.16.5
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.62.2
500500
# renovate: datasource=go depName=sigs.k8s.io/kind
501-
KIND_VERSION ?= v0.25.0
501+
KIND_VERSION ?= v0.26.0
502502
# renovate: datasource=go depName=github.com/kyverno/chainsaw
503503
CHAINSAW_VERSION ?= v0.2.12
504504

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ This will create an OpenTelemetry Collector instance named `simplest`, exposing
7272

7373
The `config` node holds the `YAML` that should be passed down as-is to the underlying OpenTelemetry Collector instances. Refer to the [OpenTelemetry Collector](https://github.com/open-telemetry/opentelemetry-collector) documentation for a reference of the possible entries.
7474

75-
> 🚨 **NOTE:** At this point, the Operator does _not_ validate the contents of the configuration file: if the configuration is invalid, the instance will still be created but the underlying OpenTelemetry Collector might crash.
75+
> 🚨 **NOTE:** At this point, the Operator does _not_ validate the whole contents of the configuration file: if the configuration is invalid, the instance might still be created but the underlying OpenTelemetry Collector might crash.
7676
7777
> 🚨 **Note:** For private GKE clusters, you will need to either add a firewall rule that allows master nodes access to port `9443/tcp` on worker nodes, or change the existing rule that allows access to port `80/tcp`, `443/tcp` and `10254/tcp` to also allow access to port `9443/tcp`. More information can be found in the [Official GCP Documentation](https://cloud.google.com/load-balancing/docs/tcp/setting-up-tcp#config-hc-firewall). See the [GKE documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/private-clusters#add_firewall_rules) on adding rules and the [Kubernetes issue](https://github.com/kubernetes/kubernetes/issues/79739) for more detail.
7878
79-
The Operator does examine the configuration file to discover configured receivers and their ports. If it finds receivers with ports, it creates a pair of kubernetes services, one headless, exposing those ports within the cluster. The headless service contains a `service.beta.openshift.io/serving-cert-secret-name` annotation that will cause OpenShift to create a secret containing a certificate and key. This secret can be mounted as a volume and the certificate and key used in those receivers' TLS configurations.
79+
The Operator does examine the configuration file for a few purposes:
8080

81+
- To discover configured receivers and their ports. If it finds receivers with ports, it creates a pair of kubernetes services, one headless, exposing those ports within the cluster. If the port is using environment variable expansion or cannot be parsed, an error will be returned. The headless service contains a `service.beta.openshift.io/serving-cert-secret-name` annotation that will cause OpenShift to create a secret containing a certificate and key. This secret can be mounted as a volume and the certificate and key used in those receivers' TLS configurations.
82+
83+
- To check if Collector observability is enabled (controlled by `spec.observability.metrics.enableMetrics`). In this case, a Service and ServiceMonitor/PodMonitor are created for the Collector instance. As a consequence, if the metrics service address contains an invalid port or uses environment variable expansion for the port, an error will be returned. A workaround for the environment variable case is to set `enableMetrics` to `false` and manually create the previously mentioned objects with the correct port if you need them.
84+
8185
### Upgrades
8286

8387
As noted above, the OpenTelemetry Collector format is continuing to evolve. However, a best-effort attempt is made to upgrade all managed `OpenTelemetryCollector` resources.
@@ -534,9 +538,10 @@ apiVersion: opentelemetry.io/v1alpha1
534538
kind: Instrumentation
535539
metadata:
536540
name: my-instrumentation
537-
apache:
541+
spec:
542+
apacheHttpd:
538543
image: your-customized-auto-instrumentation-image:apache-httpd
539-
version: 2.2
544+
version: "2.2"
540545
configPath: /your-custom-config-path
541546
attrs:
542547
- name: ApacheModuleOtelMaxQueueSize
@@ -556,6 +561,7 @@ apiVersion: opentelemetry.io/v1alpha1
556561
kind: Instrumentation
557562
metadata:
558563
name: my-instrumentation
564+
spec:
559565
nginx:
560566
image: your-customized-auto-instrumentation-image:nginx # if custom instrumentation image is needed
561567
configFile: /my/custom-dir/custom-nginx.conf
@@ -836,7 +842,6 @@ In addition to the [core responsibilities](https://github.com/open-telemetry/com
836842

837843
Approvers ([@open-telemetry/operator-approvers](https://github.com/orgs/open-telemetry/teams/operator-approvers)):
838844

839-
- [Benedikt Bongartz](https://github.com/frzifus), Red Hat
840845
- [Tyler Helmuth](https://github.com/TylerHelmuth), Honeycomb
841846
- [Yuri Oliveira Sa](https://github.com/yuriolisa), Red Hat
842847
- [Israel Blancas](https://github.com/iblancasa), Red Hat
@@ -852,6 +857,7 @@ Emeritus Approvers:
852857

853858
Maintainers ([@open-telemetry/operator-maintainers](https://github.com/orgs/open-telemetry/teams/operator-maintainers)):
854859

860+
- [Benedikt Bongartz](https://github.com/frzifus), Red Hat
855861
- [Jacob Aronoff](https://github.com/jaronoff97), Lightstep
856862
- [Mikołaj Świątek](https://github.com/swiatekm), Elastic
857863
- [Pavol Loffay](https://github.com/pavolloffay), Red Hat

RELEASE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ The operator should be released within a week after the [OpenTelemetry collector
4444

4545
| Version | Release manager |
4646
|----------|-----------------|
47-
| v0.116.0 | @jaronoff97 |
4847
| v0.117.0 | @iblancasa |
4948
| v0.118.0 | @frzifus |
5049
| v0.119.0 | @yuriolisa |
5150
| v0.120.0 | @pavolloffay |
5251
| v0.121.0 | @swiatekm |
5352
| v0.122.0 | @TylerHelmuth |
53+
| v0.123.0 | @jaronoff97 |

apis/v1beta1/collector_webhook_test.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
555555
ctx := context.Background()
556556
err := cvw.Default(ctx, &test.otelcol)
557557
if test.expected.Spec.Config.Service.Telemetry == nil {
558-
assert.NoError(t, test.expected.Spec.Config.Service.ApplyDefaults(), "could not apply defaults")
558+
assert.NoError(t, test.expected.Spec.Config.Service.ApplyDefaults(logr.Discard()), "could not apply defaults")
559559
}
560560
assert.NoError(t, err)
561561
assert.Equal(t, test.expected, test.otelcol)
@@ -588,7 +588,17 @@ func TestOTELColValidatingWebhook(t *testing.T) {
588588
five := int32(5)
589589
maxInt := int32(math.MaxInt32)
590590

591-
cfg := v1beta1.Config{}
591+
cfg := v1beta1.Config{
592+
Service: v1beta1.Service{
593+
Telemetry: &v1beta1.AnyConfig{
594+
Object: map[string]interface{}{
595+
"metrics": map[string]interface{}{
596+
"address": "${env:POD_ID}:8888",
597+
},
598+
},
599+
},
600+
},
601+
}
592602
err := yaml.Unmarshal([]byte(cfgYaml), &cfg)
593603
require.NoError(t, err)
594604

apis/v1beta1/config.go

+47-23
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ package v1beta1
1717
import (
1818
"bytes"
1919
"encoding/json"
20+
"errors"
2021
"fmt"
21-
"net"
2222
"reflect"
23+
"regexp"
2324
"sort"
2425
"strconv"
2526
"strings"
@@ -269,7 +270,7 @@ func (c *Config) getEnvironmentVariablesForComponentKinds(logger logr.Logger, co
269270

270271
// applyDefaultForComponentKinds applies defaults to the endpoints for the given ComponentKind(s).
271272
func (c *Config) applyDefaultForComponentKinds(logger logr.Logger, componentKinds ...ComponentKind) error {
272-
if err := c.Service.ApplyDefaults(); err != nil {
273+
if err := c.Service.ApplyDefaults(logger); err != nil {
273274
return err
274275
}
275276
enabledComponents := c.GetEnabledComponents()
@@ -427,37 +428,60 @@ type Service struct {
427428
Pipelines map[string]*Pipeline `json:"pipelines" yaml:"pipelines"`
428429
}
429430

430-
// MetricsEndpoint gets the port number and host address for the metrics endpoint from the collector config if it has been set.
431-
func (s *Service) MetricsEndpoint() (string, int32, error) {
432-
defaultAddr := "0.0.0.0"
433-
if s.GetTelemetry() == nil {
434-
// telemetry isn't set, use the default
435-
return defaultAddr, 8888, nil
436-
}
437-
host, port, netErr := net.SplitHostPort(s.GetTelemetry().Metrics.Address)
438-
if netErr != nil && strings.Contains(netErr.Error(), "missing port in address") {
439-
return defaultAddr, 8888, nil
440-
} else if netErr != nil {
441-
return "", 0, netErr
442-
}
443-
i64, err := strconv.ParseInt(port, 10, 32)
431+
const (
432+
defaultServicePort int32 = 8888
433+
defaultServiceHost = "0.0.0.0"
434+
)
435+
436+
// MetricsEndpoint attempts gets the host and port number from the host address without doing any validation regarding the
437+
// address itself.
438+
// It works even before env var expansion happens, when a simple `net.SplitHostPort` would fail because of the extra colon
439+
// from the env var, i.e. the address looks like "${env:POD_IP}:4317", "${env:POD_IP}", or "${POD_IP}".
440+
// In cases which the port itself is a variable, i.e. "${env:POD_IP}:${env:PORT}", this returns an error. This happens
441+
// because the port is used to generate Service objects and mappings.
442+
func (s *Service) MetricsEndpoint(logger logr.Logger) (string, int32, error) {
443+
telemetry := s.GetTelemetry()
444+
if telemetry == nil || telemetry.Metrics.Address == "" {
445+
return defaultServiceHost, defaultServicePort, nil
446+
}
447+
448+
// The regex below matches on strings that end with a colon followed by the environment variable expansion syntax.
449+
// So it should match on strings ending with: ":${env:POD_IP}" or ":${POD_IP}".
450+
const portEnvVarRegex = `:\${[env:]?.*}$`
451+
isPortEnvVar := regexp.MustCompile(portEnvVarRegex).MatchString(telemetry.Metrics.Address)
452+
if isPortEnvVar {
453+
errMsg := fmt.Sprintf("couldn't determine metrics port from configuration: %s",
454+
telemetry.Metrics.Address)
455+
logger.Info(errMsg)
456+
return "", 0, errors.New(errMsg)
457+
}
458+
459+
// The regex below matches on strings that end with a colon followed by 1 or more numbers (representing the port).
460+
const explicitPortRegex = `:(\d+$)`
461+
explicitPortMatches := regexp.MustCompile(explicitPortRegex).FindStringSubmatch(telemetry.Metrics.Address)
462+
if len(explicitPortMatches) <= 1 {
463+
return telemetry.Metrics.Address, defaultServicePort, nil
464+
}
465+
466+
port, err := strconv.ParseInt(explicitPortMatches[1], 10, 32)
444467
if err != nil {
468+
errMsg := fmt.Sprintf("couldn't determine metrics port from configuration: %s",
469+
telemetry.Metrics.Address)
470+
logger.Info(errMsg, "error", err)
445471
return "", 0, err
446472
}
447473

448-
if host == "" {
449-
host = defaultAddr
450-
}
451-
452-
return host, int32(i64), nil
474+
host, _, _ := strings.Cut(telemetry.Metrics.Address, explicitPortMatches[0])
475+
return host, int32(port), nil
453476
}
454477

455478
// ApplyDefaults inserts configuration defaults if it has not been set.
456-
func (s *Service) ApplyDefaults() error {
457-
telemetryAddr, telemetryPort, err := s.MetricsEndpoint()
479+
func (s *Service) ApplyDefaults(logger logr.Logger) error {
480+
telemetryAddr, telemetryPort, err := s.MetricsEndpoint(logger)
458481
if err != nil {
459482
return err
460483
}
484+
461485
tm := &AnyConfig{
462486
Object: map[string]interface{}{
463487
"metrics": map[string]interface{}{

0 commit comments

Comments
 (0)