Skip to content

Commit

Permalink
apis/v1beta1: remove ComponentUseLocalHostAsDefaultHost feature gate (#…
Browse files Browse the repository at this point in the history
…3334)

* apis/v1beta1: remove ComponentUseLocalHostAsDefaultHost feature gate

Signed-off-by: Benedikt Bongartz <[email protected]>

* update changelog

Signed-off-by: Benedikt Bongartz <[email protected]>

* fix

Signed-off-by: Benedikt Bongartz <[email protected]>

---------

Signed-off-by: Benedikt Bongartz <[email protected]>
  • Loading branch information
frzifus authored Oct 8, 2024
1 parent 20a320c commit 098afda
Show file tree
Hide file tree
Showing 42 changed files with 94 additions and 76 deletions.
36 changes: 36 additions & 0 deletions .chloggen/remove_localhost_fg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: collector

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove ComponentUseLocalHostAsDefaultHost collector feature gate.

# One or more tracking issues related to the change
issues: [3306]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
This change may break setups where receiver endpoints are not explicitly configured to listen on e.g. 0.0.0.0.
Change \#3333 attempts to address this issue for a known set of components.
The operator performs the adjustment for the following receivers:
- otlp
- skywalking
- jaeger
- loki
- opencensus
- zipkin
- tcplog
- udplog
- fluentforward
- statsd
- awsxray/UDP
- carbon
- collectd
- sapm
- signalfx
- splunk_hec
- wavefront
22 changes: 0 additions & 22 deletions apis/v1beta1/collector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ func (c CollectorWebhook) Default(_ context.Context, obj runtime.Object) error {
otelcol.Spec.TargetAllocator.Replicas = &one
}

ComponentUseLocalHostAsDefaultHost(otelcol)

if otelcol.Spec.Autoscaler != nil && otelcol.Spec.Autoscaler.MaxReplicas != nil {
if otelcol.Spec.Autoscaler.MinReplicas == nil {
otelcol.Spec.Autoscaler.MinReplicas = otelcol.Spec.Replicas
Expand Down Expand Up @@ -453,23 +451,3 @@ func SetupCollectorWebhook(mgr ctrl.Manager, cfg config.Config, reviewer *rbac.R
WithDefaulter(cvw).
Complete()
}

// ComponentUseLocalHostAsDefaultHost enables component.UseLocalHostAsDefaultHost
// featuregate on the given collector instance.
// NOTE: For more details, visit:
// https://github.com/open-telemetry/opentelemetry-collector/issues/8510
func ComponentUseLocalHostAsDefaultHost(otelcol *OpenTelemetryCollector) {
const (
baseFlag = "feature-gates"
fgFlag = "component.UseLocalHostAsDefaultHost"
)
if otelcol.Spec.Args == nil {
otelcol.Spec.Args = make(map[string]string)
}
args, ok := otelcol.Spec.Args[baseFlag]
if !ok || len(args) == 0 {
otelcol.Spec.Args[baseFlag] = "-" + fgFlag
} else if !strings.Contains(otelcol.Spec.Args[baseFlag], fgFlag) {
otelcol.Spec.Args[baseFlag] += ",-" + fgFlag
}
}
12 changes: 0 additions & 12 deletions apis/v1beta1/collector_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
ManagementState: v1beta1.ManagementStateManaged,
Replicas: &one,
},
Expand Down Expand Up @@ -195,7 +194,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
ManagementState: v1beta1.ManagementStateManaged,
Replicas: &one,
},
Expand All @@ -219,7 +217,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
},
Spec: v1beta1.OpenTelemetryCollectorSpec{
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
ManagementState: v1beta1.ManagementStateManaged,
Replicas: &one,
},
Expand Down Expand Up @@ -247,7 +244,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Mode: v1beta1.ModeSidecar,
UpgradeStrategy: "adhoc",
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &five,
ManagementState: v1beta1.ManagementStateManaged,
},
Expand All @@ -274,7 +270,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Mode: v1beta1.ModeSidecar,
UpgradeStrategy: "adhoc",
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &five,
ManagementState: v1beta1.ManagementStateUnmanaged,
},
Expand All @@ -299,7 +294,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Mode: v1beta1.ModeDeployment,
UpgradeStrategy: v1beta1.UpgradeStrategyAutomatic,
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &one,
ManagementState: v1beta1.ManagementStateManaged,
},
Expand Down Expand Up @@ -328,7 +322,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: v1beta1.OpenTelemetryCollectorSpec{
Mode: v1beta1.ModeDeployment,
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
ManagementState: v1beta1.ManagementStateManaged,
Replicas: &one,
},
Expand Down Expand Up @@ -364,7 +357,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: v1beta1.OpenTelemetryCollectorSpec{
Mode: v1beta1.ModeDeployment,
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &one,
ManagementState: v1beta1.ManagementStateManaged,
PodDisruptionBudget: &v1beta1.PodDisruptionBudgetSpec{
Expand Down Expand Up @@ -402,7 +394,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: v1beta1.OpenTelemetryCollectorSpec{
Mode: v1beta1.ModeDeployment,
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &one,
ManagementState: v1beta1.ManagementStateManaged,
},
Expand Down Expand Up @@ -445,7 +436,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: v1beta1.OpenTelemetryCollectorSpec{
Mode: v1beta1.ModeDeployment,
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &one,
ManagementState: v1beta1.ManagementStateManaged,
},
Expand Down Expand Up @@ -483,7 +473,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: v1beta1.OpenTelemetryCollectorSpec{
Mode: v1beta1.ModeDeployment,
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &one,
ManagementState: v1beta1.ManagementStateManaged,
},
Expand Down Expand Up @@ -514,7 +503,6 @@ func TestCollectorDefaultingWebhook(t *testing.T) {
Spec: v1beta1.OpenTelemetryCollectorSpec{
Mode: v1beta1.ModeDeployment,
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
Args: map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
Replicas: &one,
ManagementState: v1beta1.ManagementStateManaged,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/collector/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestEnvVarUpdates(t *testing.T) {
require.Equal(t, collectorInstance.Status.Version, persisted.Status.Version)

currentV := version.Get()
currentV.OpenTelemetryCollector = "0.105.0"
currentV.OpenTelemetryCollector = "0.110.0"
up := &upgrade.VersionUpgrade{
Log: logger,
Version: currentV,
Expand Down
22 changes: 21 additions & 1 deletion pkg/collector/upgrade/v0_104_0.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func upgrade0_104_0_TA(_ VersionUpgrade, otelcol *v1beta1.OpenTelemetryCollector
}

func upgrade0_104_0(u VersionUpgrade, otelcol *v1beta1.OpenTelemetryCollector) (*v1beta1.OpenTelemetryCollector, error) {
v1beta1.ComponentUseLocalHostAsDefaultHost(otelcol)
ComponentUseLocalHostAsDefaultHost(otelcol)

const issueID = "https://github.com/open-telemetry/opentelemetry-collector/issues/8510"
warnStr := fmt.Sprintf(
Expand Down Expand Up @@ -69,3 +69,23 @@ func TAUnifyEnvVarExpansion(otelcol *v1beta1.OpenTelemetryCollector) {
otelcol.Spec.Args[baseFlag] += ",-" + fgFlag
}
}

// ComponentUseLocalHostAsDefaultHost enables component.UseLocalHostAsDefaultHost
// featuregate on the given collector instance.
// NOTE: For more details, visit:
// https://github.com/open-telemetry/opentelemetry-collector/issues/8510
func ComponentUseLocalHostAsDefaultHost(otelcol *v1beta1.OpenTelemetryCollector) {
const (
baseFlag = "feature-gates"
fgFlag = "component.UseLocalHostAsDefaultHost"
)
if otelcol.Spec.Args == nil {
otelcol.Spec.Args = make(map[string]string)
}
args, ok := otelcol.Spec.Args[baseFlag]
if !ok || len(args) == 0 {
otelcol.Spec.Args[baseFlag] = "-" + fgFlag
} else if !strings.Contains(otelcol.Spec.Args[baseFlag], fgFlag) {
otelcol.Spec.Args[baseFlag] += ",-" + fgFlag
}
}
2 changes: 1 addition & 1 deletion pkg/collector/upgrade/v0_104_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Test0_104_0Upgrade(t *testing.T) {
t.Errorf("expect err: nil but got: %v", err)
}
assert.EqualValues(t,
map[string]string{"feature-gates": "-component.UseLocalHostAsDefaultHost"},
map[string]string{},
col.Spec.Args, "missing featuregate")
}

Expand Down
25 changes: 25 additions & 0 deletions pkg/collector/upgrade/v0_110_0.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package upgrade

import (
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
)

func upgrade0_110_0(_ VersionUpgrade, otelcol *v1beta1.OpenTelemetryCollector) (*v1beta1.OpenTelemetryCollector, error) { //nolint:unparam
envVarExpansionFeatureFlag := "-component.UseLocalHostAsDefaultHost"
otelcol.Spec.OpenTelemetryCommonFields.Args = RemoveFeatureGate(otelcol.Spec.OpenTelemetryCommonFields.Args, envVarExpansionFeatureFlag)
return otelcol, nil
}
10 changes: 4 additions & 6 deletions pkg/collector/upgrade/v0_38_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ service:

// verify
assert.Equal(t, map[string]string{
"--hii": "hello",
"--arg1": "",
"feature-gates": "-component.UseLocalHostAsDefaultHost",
"--hii": "hello",
"--arg1": "",
}, res.Spec.Args)

// verify
Expand Down Expand Up @@ -149,8 +148,7 @@ service:
// verify
assert.YAMLEq(t, configWithLogging, res.Spec.Config)
assert.Equal(t, map[string]string{
"--hii": "hello",
"--arg1": "",
"feature-gates": "-component.UseLocalHostAsDefaultHost",
"--hii": "hello",
"--arg1": "",
}, res.Spec.Args)
}
2 changes: 0 additions & 2 deletions pkg/collector/upgrade/v0_43_0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ service:
assert.Equal(t, map[string]string{
"--test-upgrade43": "true",
"--test-arg1": "otel",
"feature-gates": "-component.UseLocalHostAsDefaultHost",
}, res.Spec.Args)

// verify
Expand Down Expand Up @@ -143,7 +142,6 @@ service:
assert.Equal(t, map[string]string{
"--test-upgrade43": "true",
"--test-arg1": "otel",
"feature-gates": "-component.UseLocalHostAsDefaultHost",
}, res.Spec.Args)

}
4 changes: 4 additions & 0 deletions pkg/collector/upgrade/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ var (
Version: *semver.MustParse("0.105.0"),
upgradeV1beta1: upgrade0_105_0,
},
{
Version: *semver.MustParse("0.110.0"),
upgradeV1beta1: upgrade0_110_0,
},
}

// Latest represents the latest version that we need to upgrade. This is not necessarily the latest known version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ spec:
- name: otel-apache-conf-dir
mountPath: /usr/local/apache2/conf
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ spec:
- name: OTEL_RESOURCE_ATTRIBUTES
name: myrabbit
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ spec:
- image: rabbitmq
name: myrabbit
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ spec:
- mountPath: /otel-auto-instrumentation-dotnet
name: opentelemetry-auto-instrumentation-dotnet
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ spec:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
readOnly: true
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ spec:
- mountPath: /otel-auto-instrumentation-dotnet
name: opentelemetry-auto-instrumentation-dotnet
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ spec:
- mountPath: /otel-auto-instrumentation-dotnet
name: opentelemetry-auto-instrumentation-dotnet
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ spec:
containers:
- name: productcatalogservice
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
- env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ spec:
- mountPath: /otel-auto-instrumentation-java
name: opentelemetry-auto-instrumentation-java
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ spec:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
readOnly: true
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ spec:
- mountPath: /otel-auto-instrumentation-java
name: opentelemetry-auto-instrumentation-java
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ spec:
- mountPath: /otel-auto-instrumentation-java
name: opentelemetry-auto-instrumentation-java
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ spec:
- mountPath: /etc/nginx
name: otel-nginx-conf-dir
- args:
- --feature-gates=-component.UseLocalHostAsDefaultHost
- --config=env:OTEL_CONFIG
name: otc-container
initContainers:
Expand Down
Loading

0 comments on commit 098afda

Please sign in to comment.