From fc4c13d3c2822bec39fa9d9658836d1a020c6844 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Wed, 20 Mar 2024 15:28:45 -0600 Subject: [PATCH] [configgrpc] Remove deprecated func, add ToServer with context (#9787) **Description:** Removes deprecated `ToServer`. Deprecate `ToServerContext` Add new `ToServer` with `context.Context`. **Link to tracking Issue:** Related to https://github.com/open-telemetry/opentelemetry-collector/issues/9490 --------- Co-authored-by: Dmitrii Anoshin --- .../configgrpc-remove-deprecated-func.yaml | 25 +++++++++++++++++++ .../configgrpc-remove-deprecated-func2.yaml | 25 +++++++++++++++++++ config/configgrpc/configgrpc.go | 14 +++++------ config/configgrpc/configgrpc_test.go | 2 +- 4 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 .chloggen/configgrpc-remove-deprecated-func.yaml create mode 100644 .chloggen/configgrpc-remove-deprecated-func2.yaml diff --git a/.chloggen/configgrpc-remove-deprecated-func.yaml b/.chloggen/configgrpc-remove-deprecated-func.yaml new file mode 100644 index 00000000000..6a6572d4de6 --- /dev/null +++ b/.chloggen/configgrpc-remove-deprecated-func.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 `ToServer` function. + +# One or more tracking issues or pull requests related to the change +issues: [9787] + +# (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-func2.yaml b/.chloggen/configgrpc-remove-deprecated-func2.yaml new file mode 100644 index 00000000000..125b33da6fb --- /dev/null +++ b/.chloggen/configgrpc-remove-deprecated-func2.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: deprecation + +# 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: Deprecated `ToServerContext`, use `ToServer` instead. + +# One or more tracking issues or pull requests related to the change +issues: [9787] + +# (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 da592245d20..9460a008616 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -269,13 +269,7 @@ func validateBalancerName(balancerName string) bool { } // ToServer returns a grpc.Server for the configuration -// Deprecated: [0.96.0] Use ToServerContext instead. -func (gss *ServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) { - return gss.ToServerContext(context.Background(), host, settings, extraOpts...) -} - -// ToServerContext returns a grpc.Server for the configuration -func (gss *ServerConfig) ToServerContext(_ context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) { +func (gss *ServerConfig) ToServer(_ context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) { opts, err := gss.toServerOption(host, settings) if err != nil { return nil, err @@ -284,6 +278,12 @@ func (gss *ServerConfig) ToServerContext(_ context.Context, host component.Host, 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 20c853bbbc7..0e6a6efb0be 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -256,7 +256,7 @@ func TestGrpcServerAuthSettings_Deprecated(t *testing.T) { mockID: auth.NewServer(), }, } - srv, err := gss.ToServer(host, componenttest.NewNopTelemetrySettings()) + srv, err := gss.ToServer(context.Background(), host, componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) assert.NotNil(t, srv) }