Skip to content

Commit

Permalink
apis/v1beta1: remove ComponentUseLocalHostAsDefaultHost feature gate
Browse files Browse the repository at this point in the history
Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
  • Loading branch information
frzifus committed Oct 7, 2024
1 parent 20a320c commit c08913e
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 38 deletions.
16 changes: 16 additions & 0 deletions .chloggen/remove_localhost_fg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# 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: operator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove ComponentUseLocalHostAsDefaultHost 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:
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
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
}
}
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) {

Check failure on line 21 in pkg/collector/upgrade/v0_110_0.go

View workflow job for this annotation

GitHub Actions / Code standards (linting)

upgrade0_110_0 - result 1 (error) is always nil (unparam)
envVarExpansionFeatureFlag := "-component.UseLocalHostAsDefaultHost"
otelcol.Spec.OpenTelemetryCommonFields.Args = RemoveFeatureGate(otelcol.Spec.OpenTelemetryCommonFields.Args, envVarExpansionFeatureFlag)
return otelcol, nil
}
1 change: 0 additions & 1 deletion tests/e2e/daemonset-features/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ spec:
containers:
- args:
- --config=/conf/collector.yaml
- --feature-gates=-component.UseLocalHostAsDefaultHost
name: otc-container
1 change: 0 additions & 1 deletion tests/e2e/statefulset-features/00-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
containers:
- args:
- --config=/conf/collector.yaml
- --feature-gates=-component.UseLocalHostAsDefaultHost
name: otc-container
volumeMounts:
- mountPath: /conf
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/statefulset-features/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ spec:
containers:
- args:
- --config=/conf/collector.yaml
- --feature-gates=-component.UseLocalHostAsDefaultHost
name: otc-container
volumeMounts:
- mountPath: /conf
Expand Down

0 comments on commit c08913e

Please sign in to comment.