Skip to content

Commit

Permalink
Remove warning when 0.0.0.0 is used (open-telemetry#11902)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Based on the discussions from
open-telemetry#11713 (comment)
and
open-telemetry#8510 (comment)
the warning message logged when `0.0.0.0` is used, should be removed.

<!-- Issue number if applicable -->
#### Link to tracking issue
Probably fixes
open-telemetry#11713

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

/cc @mx-psi

---------

Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark authored and HongChenTW committed Dec 19, 2024
1 parent 2c9fc56 commit ea638f4
Show file tree
Hide file tree
Showing 27 changed files with 28 additions and 308 deletions.
25 changes: 25 additions & 0 deletions .chloggen/remove_net_interface_warn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# 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. otlpreceiver)
component: otelcol

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: This PR removes the warning when 0.0.0.0 is used

# One or more tracking issues or pull requests related to the change
issues: [11713, 8510]

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

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
1 change: 0 additions & 1 deletion cmd/builder/internal/builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ var replaceModules = []string{
"/config/configretry",
"/config/configtelemetry",
"/config/configtls",
"/config/internal",
"/confmap",
"/confmap/provider/envprovider",
"/confmap/provider/fileprovider",
Expand Down
1 change: 0 additions & 1 deletion cmd/builder/test/core.builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ replaces:
- go.opentelemetry.io/collector/config/configretry => ${WORKSPACE_DIR}/config/configretry
- go.opentelemetry.io/collector/config/configtelemetry => ${WORKSPACE_DIR}/config/configtelemetry
- go.opentelemetry.io/collector/config/configtls => ${WORKSPACE_DIR}/config/configtls
- go.opentelemetry.io/collector/config/internal => ${WORKSPACE_DIR}/config/internal
- go.opentelemetry.io/collector/confmap => ${WORKSPACE_DIR}/confmap
- go.opentelemetry.io/collector/confmap/provider/envprovider => ${WORKSPACE_DIR}/confmap/provider/envprovider
- go.opentelemetry.io/collector/confmap/provider/fileprovider => ${WORKSPACE_DIR}/confmap/provider/fileprovider
Expand Down
1 change: 0 additions & 1 deletion cmd/otelcorecol/builder-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ replaces:
- go.opentelemetry.io/collector/config/configretry => ../../config/configretry
- go.opentelemetry.io/collector/config/configtelemetry => ../../config/configtelemetry
- go.opentelemetry.io/collector/config/configtls => ../../config/configtls
- go.opentelemetry.io/collector/config/internal => ../../config/internal
- go.opentelemetry.io/collector/confmap => ../../confmap
- go.opentelemetry.io/collector/confmap/provider/envprovider => ../../confmap/provider/envprovider
- go.opentelemetry.io/collector/confmap/provider/fileprovider => ../../confmap/provider/fileprovider
Expand Down
3 changes: 0 additions & 3 deletions cmd/otelcorecol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ require (
go.opentelemetry.io/collector/config/configretry v1.22.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.116.0 // indirect
go.opentelemetry.io/collector/config/configtls v1.22.0 // indirect
go.opentelemetry.io/collector/config/internal v0.116.0 // indirect
go.opentelemetry.io/collector/connector/connectortest v0.116.0 // indirect
go.opentelemetry.io/collector/connector/xconnector v0.116.0 // indirect
go.opentelemetry.io/collector/consumer v1.22.0 // indirect
Expand Down Expand Up @@ -187,8 +186,6 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con

replace go.opentelemetry.io/collector/config/configtls => ../../config/configtls

replace go.opentelemetry.io/collector/config/internal => ../../config/internal

replace go.opentelemetry.io/collector/confmap => ../../confmap

replace go.opentelemetry.io/collector/confmap/provider/envprovider => ../../confmap/provider/envprovider
Expand Down
6 changes: 0 additions & 6 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/config/internal"
"go.opentelemetry.io/collector/extension/auth"
)

Expand Down Expand Up @@ -404,11 +403,6 @@ func (gss *ServerConfig) getGrpcServerOptions(
settings component.TelemetrySettings,
extraOpts []ToServerOption,
) ([]grpc.ServerOption, error) {
switch gss.NetAddr.Transport {
case confignet.TransportTypeTCP, confignet.TransportTypeTCP4, confignet.TransportTypeTCP6, confignet.TransportTypeUDP, confignet.TransportTypeUDP4, confignet.TransportTypeUDP6:
internal.WarnOnUnspecifiedHost(settings.Logger, gss.NetAddr.Endpoint)
}

var opts []grpc.ServerOption

if gss.TLSSetting != nil {
Expand Down
52 changes: 0 additions & 52 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
Expand Down Expand Up @@ -514,56 +512,6 @@ func TestUseSecure(t *testing.T) {
assert.Len(t, dialOpts, 2)
}

func TestGRPCServerWarning(t *testing.T) {
tests := []struct {
name string
settings ServerConfig
len int
}{
{
settings: ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "0.0.0.0:1234",
Transport: confignet.TransportTypeTCP,
},
},
len: 1,
},
{
settings: ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "127.0.0.1:1234",
Transport: confignet.TransportTypeTCP,
},
},
len: 0,
},
{
settings: ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "0.0.0.0:1234",
Transport: confignet.TransportTypeUnix,
},
},
len: 0,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
set := componenttest.NewNopTelemetrySettings()
logger, observed := observer.New(zap.DebugLevel)
set.Logger = zap.New(logger)

opts, err := test.settings.getGrpcServerOptions(componenttest.NewNopHost(), set, []ToServerOption{})
require.NoError(t, err)
require.NotNil(t, opts)
_ = grpc.NewServer(opts...)

require.Len(t, observed.FilterLevelExact(zap.WarnLevel).All(), test.len)
})
}
}

func TestGRPCServerSettingsError(t *testing.T) {
tests := []struct {
settings ServerConfig
Expand Down
6 changes: 2 additions & 4 deletions config/configgrpc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
go.opentelemetry.io/collector/config/configopaque v1.22.0
go.opentelemetry.io/collector/config/configtelemetry v0.116.0
go.opentelemetry.io/collector/config/configtls v1.22.0
go.opentelemetry.io/collector/config/internal v0.116.0
go.opentelemetry.io/collector/extension/auth v0.116.0
go.opentelemetry.io/collector/extension/auth/authtest v0.116.0
go.opentelemetry.io/collector/pdata v1.22.0
Expand All @@ -23,7 +22,6 @@ require (
go.opentelemetry.io/otel v1.32.0
go.opentelemetry.io/otel/metric v1.32.0
go.uber.org/goleak v1.3.0
go.uber.org/zap v1.27.0
google.golang.org/grpc v1.68.1
)

Expand All @@ -40,12 +38,14 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
go.opentelemetry.io/collector/extension v0.116.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.116.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.19.0 // indirect
Expand All @@ -68,8 +68,6 @@ replace go.opentelemetry.io/collector/config/configtls => ../configtls

replace go.opentelemetry.io/collector/config/configtelemetry => ../configtelemetry

replace go.opentelemetry.io/collector/config/internal => ../internal

replace go.opentelemetry.io/collector/extension => ../../extension

replace go.opentelemetry.io/collector/extension/auth => ../../extension/auth
Expand Down
3 changes: 0 additions & 3 deletions config/confighttp/confighttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configtelemetry"
"go.opentelemetry.io/collector/config/configtls"
configinternal "go.opentelemetry.io/collector/config/internal"
"go.opentelemetry.io/collector/extension/auth"
)

Expand Down Expand Up @@ -407,8 +406,6 @@ func WithDecoder(key string, dec func(body io.ReadCloser) (io.ReadCloser, error)

// ToServer creates an http.Server from settings object.
func (hss *ServerConfig) ToServer(_ context.Context, host component.Host, settings component.TelemetrySettings, handler http.Handler, opts ...ToServerOption) (*http.Server, error) {
configinternal.WarnOnUnspecifiedHost(settings.Logger, hss.Endpoint)

serverOpts := &toServerOptions{}
serverOpts.Apply(opts...)

Expand Down
40 changes: 0 additions & 40 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"

"go.opentelemetry.io/collector/client"
"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -516,45 +515,6 @@ func TestHTTPServerSettingsError(t *testing.T) {
}
}

func TestHTTPServerWarning(t *testing.T) {
tests := []struct {
name string
settings ServerConfig
len int
}{
{
settings: ServerConfig{
Endpoint: "0.0.0.0:0",
},
len: 1,
},
{
settings: ServerConfig{
Endpoint: "127.0.0.1:0",
},
len: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
set := componenttest.NewNopTelemetrySettings()
logger, observed := observer.New(zap.DebugLevel)
set.Logger = zap.New(logger)

_, err := tt.settings.ToServer(
context.Background(),
componenttest.NewNopHost(),
set,
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
_, errWrite := fmt.Fprint(w, "tt")
assert.NoError(t, errWrite)
}))
require.NoError(t, err)
require.Len(t, observed.FilterLevelExact(zap.WarnLevel).All(), tt.len)
})
}
}

func TestHttpReception(t *testing.T) {
tests := []struct {
name string
Expand Down
4 changes: 1 addition & 3 deletions config/confighttp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
go.opentelemetry.io/collector/config/configopaque v1.22.0
go.opentelemetry.io/collector/config/configtelemetry v0.116.0
go.opentelemetry.io/collector/config/configtls v1.22.0
go.opentelemetry.io/collector/config/internal v0.116.0
go.opentelemetry.io/collector/extension/auth v0.116.0
go.opentelemetry.io/collector/extension/auth/authtest v0.116.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0
Expand All @@ -36,6 +35,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
go.opentelemetry.io/collector/extension v0.116.0 // indirect
go.opentelemetry.io/collector/pdata v1.22.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
Expand All @@ -60,8 +60,6 @@ replace go.opentelemetry.io/collector/config/configtls => ../configtls

replace go.opentelemetry.io/collector/config/configtelemetry => ../configtelemetry

replace go.opentelemetry.io/collector/config/internal => ../internal

replace go.opentelemetry.io/collector/extension => ../../extension

replace go.opentelemetry.io/collector/extension/auth => ../../extension/auth
Expand Down
3 changes: 0 additions & 3 deletions config/confighttp/xconfighttp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ require (
go.opentelemetry.io/collector/config/configopaque v1.22.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.116.0 // indirect
go.opentelemetry.io/collector/config/configtls v1.22.0 // indirect
go.opentelemetry.io/collector/config/internal v0.116.0 // indirect
go.opentelemetry.io/collector/extension v0.116.0 // indirect
go.opentelemetry.io/collector/extension/auth v0.116.0 // indirect
go.opentelemetry.io/collector/pdata v1.22.0 // indirect
Expand All @@ -51,8 +50,6 @@ require (

replace go.opentelemetry.io/collector/config/confighttp => ../../confighttp

replace go.opentelemetry.io/collector/config/internal => ../../internal

replace go.opentelemetry.io/collector/config/configtelemetry => ../../configtelemetry

replace go.opentelemetry.io/collector/client => ../../../client
Expand Down
1 change: 0 additions & 1 deletion config/internal/Makefile

This file was deleted.

19 changes: 0 additions & 19 deletions config/internal/go.mod

This file was deleted.

29 changes: 0 additions & 29 deletions config/internal/go.sum

This file was deleted.

14 changes: 0 additions & 14 deletions config/internal/package_test.go

This file was deleted.

Loading

0 comments on commit ea638f4

Please sign in to comment.