From 4f565097f38d46f7c752f14b106539a5860ced4f Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Wed, 3 Apr 2024 01:41:11 -0600 Subject: [PATCH] [configgrpc] remove deprecated funcs (#9836) Closes https://github.com/open-telemetry/opentelemetry-collector/issues/9482 Closes https://github.com/open-telemetry/opentelemetry-collector/issues/9812 --- .../configgrpc-remove-deprecated-funcs-2.yaml | 25 +++++++++++++++++ .../configgrpc-remove-deprecated-funcs.yaml | 25 +++++++++++++++++ config/configgrpc/configgrpc.go | 13 +++------ config/configgrpc/configgrpc_test.go | 27 +++---------------- receiver/otlpreceiver/otlp.go | 2 +- 5 files changed, 58 insertions(+), 34 deletions(-) create mode 100644 .chloggen/configgrpc-remove-deprecated-funcs-2.yaml create mode 100644 .chloggen/configgrpc-remove-deprecated-funcs.yaml diff --git a/.chloggen/configgrpc-remove-deprecated-funcs-2.yaml b/.chloggen/configgrpc-remove-deprecated-funcs-2.yaml new file mode 100644 index 00000000000..3bfefda5bae --- /dev/null +++ b/.chloggen/configgrpc-remove-deprecated-funcs-2.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: configgrpc + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove deprecated `ToServerContext`, use `ToServer` instead. + +# One or more tracking issues or pull requests related to the change +issues: [9836] + +# (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: [api] diff --git a/.chloggen/configgrpc-remove-deprecated-funcs.yaml b/.chloggen/configgrpc-remove-deprecated-funcs.yaml new file mode 100644 index 00000000000..2f7e1ba9751 --- /dev/null +++ b/.chloggen/configgrpc-remove-deprecated-funcs.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: configgrpc + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Remove deprecated `SanitizedEndpoint`. + +# One or more tracking issues or pull requests related to the change +issues: [9836] + +# (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: [api] diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index 4ca405e56b7..fa1f03d0b6d 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -150,9 +150,8 @@ type ServerConfig struct { IncludeMetadata bool `mapstructure:"include_metadata"` } -// SanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint. -// Deprecated: [v0.97.0] -func (gcs *ClientConfig) SanitizedEndpoint() string { +// sanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint. +func (gcs *ClientConfig) sanitizedEndpoint() string { switch { case gcs.isSchemeHTTP(): return strings.TrimPrefix(gcs.Endpoint, "http://") @@ -181,7 +180,7 @@ func (gcs *ClientConfig) ToClientConn(ctx context.Context, host component.Host, return nil, err } opts = append(opts, extraOpts...) - return grpc.DialContext(ctx, gcs.SanitizedEndpoint(), opts...) + return grpc.DialContext(ctx, gcs.sanitizedEndpoint(), opts...) } func (gcs *ClientConfig) toDialOptions(host component.Host, settings component.TelemetrySettings) ([]grpc.DialOption, error) { @@ -278,12 +277,6 @@ func (gss *ServerConfig) ToServer(_ context.Context, host component.Host, settin return grpc.NewServer(opts...), nil } -// ToServerContext returns a grpc.Server for the configuration -// Deprecated: [v0.97.0] Use ToServer instead. -func (gss *ServerConfig) ToServerContext(ctx context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) { - return gss.ToServer(ctx, host, settings, extraOpts...) -} - func (gss *ServerConfig) toServerOption(host component.Host, settings component.TelemetrySettings) ([]grpc.ServerOption, error) { switch gss.NetAddr.Transport { case confignet.TransportTypeTCP, confignet.TransportTypeTCP4, confignet.TransportTypeTCP6, confignet.TransportTypeUDP, confignet.TransportTypeUDP4, confignet.TransportTypeUDP6: diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 556dfa446b0..2a1b34cb4ee 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -224,25 +224,6 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) { } func TestGrpcServerAuthSettings(t *testing.T) { - gss := &ServerConfig{ - NetAddr: confignet.AddrConfig{ - Endpoint: "0.0.0.0:1234", - }, - } - gss.Auth = &configauth.Authentication{ - AuthenticatorID: mockID, - } - host := &mockHost{ - ext: map[component.ID]component.Component{ - mockID: auth.NewServer(), - }, - } - srv, err := gss.ToServerContext(context.Background(), host, componenttest.NewNopTelemetrySettings()) - assert.NoError(t, err) - assert.NotNil(t, srv) -} - -func TestGrpcServerAuthSettings_Deprecated(t *testing.T) { gss := &ServerConfig{ NetAddr: confignet.AddrConfig{ Endpoint: "0.0.0.0:1234", @@ -500,7 +481,7 @@ func TestGRPCServerSettingsError(t *testing.T) { } for _, test := range tests { t.Run(test.err, func(t *testing.T) { - _, err := test.settings.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) + _, err := test.settings.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.Regexp(t, test.err, err) }) } @@ -637,7 +618,7 @@ func TestHttpReception(t *testing.T) { } ln, err := gss.NetAddr.Listen(context.Background()) assert.NoError(t, err) - s, err := gss.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) + s, err := gss.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) ptraceotlp.RegisterGRPCServer(s, &grpcTraceServer{}) @@ -684,7 +665,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) { } ln, err := gss.NetAddr.Listen(context.Background()) assert.NoError(t, err) - srv, err := gss.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) + srv, err := gss.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) ptraceotlp.RegisterGRPCServer(srv, &grpcTraceServer{}) @@ -878,7 +859,7 @@ func TestClientInfoInterceptors(t *testing.T) { Transport: confignet.TransportTypeTCP, }, } - srv, err := gss.ToServerContext(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) + srv, err := gss.ToServer(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) require.NoError(t, err) ptraceotlp.RegisterGRPCServer(srv, mock) diff --git a/receiver/otlpreceiver/otlp.go b/receiver/otlpreceiver/otlp.go index 91936bfb6a5..fd7a2ee82ef 100644 --- a/receiver/otlpreceiver/otlp.go +++ b/receiver/otlpreceiver/otlp.go @@ -83,7 +83,7 @@ func (r *otlpReceiver) startGRPCServer(host component.Host) error { } var err error - if r.serverGRPC, err = r.cfg.GRPC.ToServerContext(context.Background(), host, r.settings.TelemetrySettings); err != nil { + if r.serverGRPC, err = r.cfg.GRPC.ToServer(context.Background(), host, r.settings.TelemetrySettings); err != nil { return err }