diff --git a/.chloggen/remove_net_interface_warn.yaml b/.chloggen/remove_net_interface_warn.yaml new file mode 100644 index 00000000000..02ed7a92357 --- /dev/null +++ b/.chloggen/remove_net_interface_warn.yaml @@ -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] diff --git a/cmd/builder/internal/builder/main_test.go b/cmd/builder/internal/builder/main_test.go index 824d73585c0..8220e48df85 100644 --- a/cmd/builder/internal/builder/main_test.go +++ b/cmd/builder/internal/builder/main_test.go @@ -52,7 +52,6 @@ var replaceModules = []string{ "/config/configretry", "/config/configtelemetry", "/config/configtls", - "/config/internal", "/confmap", "/confmap/provider/envprovider", "/confmap/provider/fileprovider", diff --git a/cmd/otelcorecol/builder-config.yaml b/cmd/otelcorecol/builder-config.yaml index 22e883a53f9..02ce3a8c934 100644 --- a/cmd/otelcorecol/builder-config.yaml +++ b/cmd/otelcorecol/builder-config.yaml @@ -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 diff --git a/cmd/otelcorecol/go.mod b/cmd/otelcorecol/go.mod index 23f14e92b6d..c4655a98b68 100644 --- a/cmd/otelcorecol/go.mod +++ b/cmd/otelcorecol/go.mod @@ -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 @@ -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 diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index 5def5bbb0a1..b9c99d4d997 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -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" ) @@ -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 { diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 29979609197..248077d32db 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -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" @@ -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 diff --git a/config/configgrpc/go.mod b/config/configgrpc/go.mod index 6733c1bb366..95ca605c7ba 100644 --- a/config/configgrpc/go.mod +++ b/config/configgrpc/go.mod @@ -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 @@ -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 ) @@ -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 @@ -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 diff --git a/config/confighttp/confighttp.go b/config/confighttp/confighttp.go index c8ab4544aeb..6f8efc53f45 100644 --- a/config/confighttp/confighttp.go +++ b/config/confighttp/confighttp.go @@ -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" ) @@ -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...) diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go index a0759d390e9..c4b69ae8e27 100644 --- a/config/confighttp/confighttp_test.go +++ b/config/confighttp/confighttp_test.go @@ -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" @@ -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 diff --git a/config/confighttp/go.mod b/config/confighttp/go.mod index 8919d41f9bc..75ddce82414 100644 --- a/config/confighttp/go.mod +++ b/config/confighttp/go.mod @@ -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 @@ -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 @@ -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 diff --git a/config/confighttp/xconfighttp/go.mod b/config/confighttp/xconfighttp/go.mod index 6b0c5a01e52..e67025dc73e 100644 --- a/config/confighttp/xconfighttp/go.mod +++ b/config/confighttp/xconfighttp/go.mod @@ -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 @@ -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 diff --git a/config/internal/Makefile b/config/internal/Makefile deleted file mode 100644 index ded7a36092d..00000000000 --- a/config/internal/Makefile +++ /dev/null @@ -1 +0,0 @@ -include ../../Makefile.Common diff --git a/config/internal/go.mod b/config/internal/go.mod deleted file mode 100644 index 2327799b7d6..00000000000 --- a/config/internal/go.mod +++ /dev/null @@ -1,19 +0,0 @@ -module go.opentelemetry.io/collector/config/internal - -go 1.22.0 - -require ( - github.com/stretchr/testify v1.10.0 - go.uber.org/goleak v1.3.0 - go.uber.org/zap v1.27.0 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/config/internal/go.sum b/config/internal/go.sum deleted file mode 100644 index d451d407663..00000000000 --- a/config/internal/go.sum +++ /dev/null @@ -1,29 +0,0 @@ -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/config/internal/package_test.go b/config/internal/package_test.go deleted file mode 100644 index 4486cdb28aa..00000000000 --- a/config/internal/package_test.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package internal - -import ( - "testing" - - "go.uber.org/goleak" -) - -func TestMain(m *testing.M) { - goleak.VerifyTestMain(m) -} diff --git a/config/internal/warning.go b/config/internal/warning.go deleted file mode 100644 index 0f5f6363431..00000000000 --- a/config/internal/warning.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package internal // import "go.opentelemetry.io/collector/config/internal" - -import ( - "net" - "strconv" - "strings" - - "go.uber.org/zap" -) - -func shouldWarn(endpoint string) bool { - if endpoint == ":" { - // : (aka 0.0.0.0:0) - return true - } - - if strings.HasPrefix(endpoint, ":") { - // : (aka 0.0.0.0:) - _, err := strconv.ParseInt(endpoint[1:], 10, 64) - // If it's not a number, it's probably invalid, don't warn. - return err == nil - } - - // : - host, _, err := net.SplitHostPort(endpoint) - if err != nil { // Probably invalid, don't warn. - return false - } - - ip := net.ParseIP(host) - return ip != nil && ip.IsUnspecified() -} - -// WarnOnUnspecifiedHost emits a warning if an endpoint has an unspecified host. -func WarnOnUnspecifiedHost(logger *zap.Logger, endpoint string) { - if shouldWarn(endpoint) { - logger.Warn( - "Using the 0.0.0.0 address exposes this server to every network interface, which may facilitate Denial of Service attacks.", - zap.String( - "documentation", - "https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/security-best-practices.md#safeguards-against-denial-of-service-attacks", - ), - ) - } -} diff --git a/config/internal/warning_test.go b/config/internal/warning_test.go deleted file mode 100644 index 3e8a2f01387..00000000000 --- a/config/internal/warning_test.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package internal // import "go.opentelemetry.io/collector/config/internal" - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestShouldWarn(t *testing.T) { - tests := []struct { - endpoint string - warn bool - }{ - { - endpoint: "0.0.0.0:0", - warn: true, - }, - { - endpoint: ":0", - warn: true, - }, - { - // Valid input for net.Listen - endpoint: ":+0", - warn: true, - }, - { - // Valid input for net.Listen - endpoint: ":-0", - warn: true, - }, - { - // Valid input for net.Listen, same as zero port. - // https://github.com/golang/go/issues/13610 - endpoint: ":", - warn: true, - }, - { - endpoint: "127.0.0.1:0", - }, - { - endpoint: "localhost:0", - }, - { - // invalid, don't warn - endpoint: "localhost::0", - }, - } - for _, test := range tests { - t.Run(test.endpoint, func(t *testing.T) { - assert.Equal(t, shouldWarn(test.endpoint), test.warn) - }) - } -} diff --git a/docs/component-status.md b/docs/component-status.md index bcc1a73f013..894f1eac2c0 100644 --- a/docs/component-status.md +++ b/docs/component-status.md @@ -36,7 +36,7 @@ There is a finite state machine underlying the status reporting API that governs ![State Diagram](img/component-status-state-diagram.png) -The finite state machine ensures that components progress through the lifecycle properly and it manages transitions through runtime states so that components do not need to track their state internally. Only changes in status result in new events being generated; repeat reports of the same status are ignored. PermanentError and FatalError are permanent runtime states. A component in these states cannot make any further state transitions. +The finite state machine ensures that components progress through the lifecycle properly and it manages transitions through runtime states so that components do not need to track their state internally. Only changes in status result in new events being generated; repeat reports of the same status are ignored. PermanentError is a permanent runtime state. A component in a PermanentError state cannot transtion to OK or RecoverableError, but it can transition to Stopping. FatalError is a final state. A component in a FatalError state cannot make any further state transitions. ![Status Event Generation](img/component-status-event-generation.png) @@ -61,6 +61,7 @@ Under most circumstances, a component does not need to report explicit status du **Runtime** ![Runtime State Diagram](img/component-status-runtime-states.png) + During runtime a component should not have to keep track of its state. A component should report status as operations succeed or fail and the finite state machine will handle the rest. Changes in status will result in new status events being emitted. Repeat reports of the same status will no-op. Similarly, attempts to make an invalid state transition, such as PermanentError to OK, will have no effect. We intend to define guidelines to help component authors distinguish between recoverable and permanent errors on a per-component type basis and we'll update this document as we make decisions. See [this issue](https://github.com/open-telemetry/opentelemetry-collector/issues/9957) for current thoughts and discussions. diff --git a/docs/img/component-status-state-diagram.png b/docs/img/component-status-state-diagram.png index ad9735edfe3..20911f7ae22 100644 Binary files a/docs/img/component-status-state-diagram.png and b/docs/img/component-status-state-diagram.png differ diff --git a/exporter/otlpexporter/go.mod b/exporter/otlpexporter/go.mod index 7875f2359e1..8bd3a2cb65b 100644 --- a/exporter/otlpexporter/go.mod +++ b/exporter/otlpexporter/go.mod @@ -55,7 +55,6 @@ require ( go.opentelemetry.io/collector/client v1.22.0 // indirect go.opentelemetry.io/collector/config/confignet v1.22.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.116.0 // indirect - go.opentelemetry.io/collector/config/internal v0.116.0 // indirect go.opentelemetry.io/collector/consumer/consumererror/xconsumererror v0.116.0 // indirect go.opentelemetry.io/collector/consumer/consumertest v0.116.0 // indirect go.opentelemetry.io/collector/consumer/xconsumer v0.116.0 // indirect @@ -97,8 +96,6 @@ replace go.opentelemetry.io/collector/config/configopaque => ../../config/config 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/exporter => ../ diff --git a/exporter/otlphttpexporter/go.mod b/exporter/otlphttpexporter/go.mod index 6ce87a333b3..45485795b51 100644 --- a/exporter/otlphttpexporter/go.mod +++ b/exporter/otlphttpexporter/go.mod @@ -55,7 +55,6 @@ require ( go.opentelemetry.io/collector/client v1.22.0 // indirect go.opentelemetry.io/collector/config/configauth v0.116.0 // indirect go.opentelemetry.io/collector/config/configtelemetry v0.116.0 // indirect - go.opentelemetry.io/collector/config/internal v0.116.0 // indirect go.opentelemetry.io/collector/consumer/consumererror/xconsumererror v0.116.0 // indirect go.opentelemetry.io/collector/consumer/consumertest v0.116.0 // indirect go.opentelemetry.io/collector/consumer/xconsumer v0.116.0 // indirect @@ -99,8 +98,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/exporter => ../ diff --git a/extension/zpagesextension/go.mod b/extension/zpagesextension/go.mod index 8937c665915..35bbcc7c817 100644 --- a/extension/zpagesextension/go.mod +++ b/extension/zpagesextension/go.mod @@ -44,7 +44,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/auth v0.116.0 // indirect go.opentelemetry.io/collector/pdata v1.22.0 // indirect go.opentelemetry.io/collector/pipeline v0.116.0 // indirect @@ -82,8 +81,6 @@ replace go.opentelemetry.io/collector/config/configtelemetry => ../../config/con replace go.opentelemetry.io/collector/config/configopaque => ../../config/configopaque -replace go.opentelemetry.io/collector/config/internal => ../../config/internal - replace go.opentelemetry.io/collector/config/configtls => ../../config/configtls replace go.opentelemetry.io/collector/config/configcompression => ../../config/configcompression diff --git a/internal/e2e/go.mod b/internal/e2e/go.mod index eb92d65d0ce..76d13d66a64 100644 --- a/internal/e2e/go.mod +++ b/internal/e2e/go.mod @@ -81,7 +81,6 @@ require ( go.opentelemetry.io/collector/config/configauth v0.116.0 // indirect go.opentelemetry.io/collector/config/configcompression v1.22.0 // indirect go.opentelemetry.io/collector/config/confignet v1.22.0 // indirect - go.opentelemetry.io/collector/config/internal v0.116.0 // indirect go.opentelemetry.io/collector/connector/xconnector v0.116.0 // indirect go.opentelemetry.io/collector/consumer/consumererror v0.116.0 // indirect go.opentelemetry.io/collector/consumer/consumererror/xconsumererror v0.116.0 // indirect @@ -142,8 +141,6 @@ replace go.opentelemetry.io/collector/config/configopaque => ../../config/config replace go.opentelemetry.io/collector/config/configgrpc => ../../config/configgrpc -replace go.opentelemetry.io/collector/config/internal => ../../config/internal - replace go.opentelemetry.io/collector/config/confignet => ../../config/confignet replace go.opentelemetry.io/collector/config/confighttp => ../../config/confighttp diff --git a/otelcol/go.mod b/otelcol/go.mod index 44eee0446a7..440a6eb5dd4 100644 --- a/otelcol/go.mod +++ b/otelcol/go.mod @@ -157,8 +157,6 @@ replace go.opentelemetry.io/collector/config/configretry => ../config/configretr replace go.opentelemetry.io/collector/config/confighttp => ../config/confighttp -replace go.opentelemetry.io/collector/config/internal => ../config/internal - replace go.opentelemetry.io/collector/config/configauth => ../config/configauth replace go.opentelemetry.io/collector/extension/auth => ../extension/auth diff --git a/otelcol/otelcoltest/go.mod b/otelcol/otelcoltest/go.mod index 9fe514daf9e..96aed1b0ae5 100644 --- a/otelcol/otelcoltest/go.mod +++ b/otelcol/otelcoltest/go.mod @@ -202,8 +202,6 @@ replace go.opentelemetry.io/collector/config/configcompression => ../../config/c replace go.opentelemetry.io/collector/config/confighttp => ../../config/confighttp -replace go.opentelemetry.io/collector/config/internal => ../../config/internal - replace go.opentelemetry.io/collector/client => ../../client replace go.opentelemetry.io/collector/extension/auth => ../../extension/auth diff --git a/receiver/otlpreceiver/go.mod b/receiver/otlpreceiver/go.mod index e26402ba9c8..fabee5c2983 100644 --- a/receiver/otlpreceiver/go.mod +++ b/receiver/otlpreceiver/go.mod @@ -59,7 +59,6 @@ require ( go.opentelemetry.io/collector/config/configcompression v1.22.0 // indirect 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/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/pipeline v0.116.0 // indirect @@ -99,8 +98,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/extension => ../../extension diff --git a/service/go.mod b/service/go.mod index c408cd5853c..e50017a3203 100644 --- a/service/go.mod +++ b/service/go.mod @@ -103,7 +103,6 @@ require ( go.opentelemetry.io/collector/config/configcompression v1.22.0 // indirect go.opentelemetry.io/collector/config/configopaque v1.22.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/consumer/consumererror v0.116.0 // indirect go.opentelemetry.io/collector/extension/auth v0.116.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect @@ -179,8 +178,6 @@ replace go.opentelemetry.io/collector/config/confighttp => ../config/confighttp replace go.opentelemetry.io/collector/config/configauth => ../config/configauth -replace go.opentelemetry.io/collector/config/internal => ../config/internal - replace go.opentelemetry.io/collector/config/configtls => ../config/configtls replace go.opentelemetry.io/collector/config/configcompression => ../config/configcompression diff --git a/service/internal/graph/lifecycle_test.go b/service/internal/graph/lifecycle_test.go index 9fb91f5af6f..07db29df3e4 100644 --- a/service/internal/graph/lifecycle_test.go +++ b/service/internal/graph/lifecycle_test.go @@ -351,6 +351,8 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) { instanceIDs[eStErr]: { componentstatus.NewEvent(componentstatus.StatusStarting), componentstatus.NewPermanentErrorEvent(assert.AnError), + componentstatus.NewEvent(componentstatus.StatusStopping), + componentstatus.NewEvent(componentstatus.StatusStopped), }, }, startupErr: assert.AnError, @@ -362,6 +364,8 @@ func TestStatusReportedOnStartupShutdown(t *testing.T) { instanceIDs[rStErr]: { componentstatus.NewEvent(componentstatus.StatusStarting), componentstatus.NewPermanentErrorEvent(assert.AnError), + componentstatus.NewEvent(componentstatus.StatusStopping), + componentstatus.NewEvent(componentstatus.StatusStopped), }, instanceIDs[eNoErr]: { componentstatus.NewEvent(componentstatus.StatusStarting), diff --git a/service/internal/status/status.go b/service/internal/status/status.go index a27bff618dd..5a44a02665f 100644 --- a/service/internal/status/status.go +++ b/service/internal/status/status.go @@ -70,8 +70,10 @@ func newFSM(onTransition onTransitionFunc) *fsm { componentstatus.StatusFatalError: {}, componentstatus.StatusStopping: {}, }, - componentstatus.StatusPermanentError: {}, - componentstatus.StatusFatalError: {}, + componentstatus.StatusPermanentError: { + componentstatus.StatusStopping: {}, + }, + componentstatus.StatusFatalError: {}, componentstatus.StatusStopping: { componentstatus.StatusRecoverableError: {}, componentstatus.StatusPermanentError: {}, diff --git a/service/internal/status/status_test.go b/service/internal/status/status_test.go index 6a61b863a26..d744e1aa694 100644 --- a/service/internal/status/status_test.go +++ b/service/internal/status/status_test.go @@ -75,17 +75,19 @@ func TestStatusFSM(t *testing.T) { expectedErrorCount: 2, }, { - name: "PermanentError is terminal", + name: "PermanentError is stoppable", reportedStatuses: []componentstatus.Status{ componentstatus.StatusStarting, componentstatus.StatusOK, componentstatus.StatusPermanentError, componentstatus.StatusOK, + componentstatus.StatusStopping, }, expectedStatuses: []componentstatus.Status{ componentstatus.StatusStarting, componentstatus.StatusOK, componentstatus.StatusPermanentError, + componentstatus.StatusStopping, }, expectedErrorCount: 1, }, @@ -154,7 +156,7 @@ func TestValidSeqsToStopped(t *testing.T) { } for _, ev := range events { - name := fmt.Sprintf("transition from: %s to: %s invalid", ev.Status(), componentstatus.StatusStopped) + name := fmt.Sprintf("transition from: %s to: %s", ev.Status(), componentstatus.StatusStopped) t.Run(name, func(t *testing.T) { fsm := newFSM(func(*componentstatus.Event) {}) if ev.Status() != componentstatus.StatusStarting { @@ -165,9 +167,9 @@ func TestValidSeqsToStopped(t *testing.T) { err := fsm.transition(componentstatus.NewEvent(componentstatus.StatusStopped)) require.ErrorIs(t, err, errInvalidStateTransition) - // stopping -> stopped is allowed for non-fatal, non-permanent errors + // stopping -> stopped is allowed for non-fatal errors err = fsm.transition(componentstatus.NewEvent(componentstatus.StatusStopping)) - if ev.Status() == componentstatus.StatusPermanentError || ev.Status() == componentstatus.StatusFatalError { + if ev.Status() == componentstatus.StatusFatalError { require.ErrorIs(t, err, errInvalidStateTransition) } else { require.NoError(t, err) diff --git a/versions.yaml b/versions.yaml index abddc9ddd27..b43a032906b 100644 --- a/versions.yaml +++ b/versions.yaml @@ -37,7 +37,6 @@ module-sets: - go.opentelemetry.io/collector/config/confighttp - go.opentelemetry.io/collector/config/confighttp/xconfighttp - go.opentelemetry.io/collector/config/configtelemetry - - go.opentelemetry.io/collector/config/internal - go.opentelemetry.io/collector/connector - go.opentelemetry.io/collector/connector/connectortest - go.opentelemetry.io/collector/connector/forwardconnector