From a47e5fee940eb0cae952e2c3e90a74d51c24a4d5 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:57:52 -0700 Subject: [PATCH] Remove deprecated functions/structs --- .../configgrpc-remove-deprecated-items.yaml | 25 ++++++++++++++ config/configgrpc/configgrpc.go | 34 +------------------ config/configgrpc/configgrpc_test.go | 14 +++----- exporter/otlpexporter/config.go | 2 +- receiver/otlpreceiver/otlp.go | 2 +- 5 files changed, 32 insertions(+), 45 deletions(-) create mode 100755 .chloggen/configgrpc-remove-deprecated-items.yaml diff --git a/.chloggen/configgrpc-remove-deprecated-items.yaml b/.chloggen/configgrpc-remove-deprecated-items.yaml new file mode 100755 index 00000000000..c0a3478264f --- /dev/null +++ b/.chloggen/configgrpc-remove-deprecated-items.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 `GRPCClientSettings`, `GRPCServerSettings`, `ServerConfig.ToListenerContext` and `ClientConfig.SanitizedEndpoint`. + +# One or more tracking issues or pull requests related to the change +issues: [9616] + +# (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: [] diff --git a/config/configgrpc/configgrpc.go b/config/configgrpc/configgrpc.go index 6dea5917ea2..4e98734dfb7 100644 --- a/config/configgrpc/configgrpc.go +++ b/config/configgrpc/configgrpc.go @@ -8,7 +8,6 @@ import ( "crypto/tls" "errors" "fmt" - "net" "strings" "time" @@ -47,10 +46,6 @@ type KeepaliveClientConfig struct { PermitWithoutStream bool `mapstructure:"permit_without_stream"` } -// GRPCClientSettings defines common settings for a gRPC client configuration. -// Deprecated: [v0.94.0] Use ClientConfig instead -type GRPCClientSettings = ClientConfig - // ClientConfig defines common settings for a gRPC client configuration. type ClientConfig struct { // The target to which the exporter is going to send traces or metrics, @@ -120,10 +115,6 @@ type KeepaliveEnforcementPolicy struct { PermitWithoutStream bool `mapstructure:"permit_without_stream"` } -// GRPCServerSettings defines common settings for a gRPC server configuration. -// Deprecated: [v0.94.0] Use ServerConfig instead -type GRPCServerSettings = ServerConfig - // ServerConfig defines common settings for a gRPC server configuration. type ServerConfig struct { // Server net.Addr config. For transport only "tcp" and "unix" are valid options. @@ -159,23 +150,6 @@ type ServerConfig struct { IncludeMetadata bool `mapstructure:"include_metadata"` } -// SanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint. -// Deprecated: [v0.95.0] Trim the prefix from configgrpc.ClientConfig.Endpoint directly. -func (gcs *ClientConfig) SanitizedEndpoint() string { - switch { - case gcs.isSchemeHTTP(): - return strings.TrimPrefix(gcs.Endpoint, "http://") - case gcs.isSchemeHTTPS(): - return strings.TrimPrefix(gcs.Endpoint, "https://") - default: - return gcs.Endpoint - } -} - -func (gcs *ClientConfig) isSchemeHTTP() bool { - return strings.HasPrefix(gcs.Endpoint, "http://") -} - func (gcs *ClientConfig) isSchemeHTTPS() bool { return strings.HasPrefix(gcs.Endpoint, "https://") } @@ -190,7 +164,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.Endpoint, opts...) } func (gcs *ClientConfig) toDialOptions(host component.Host, settings component.TelemetrySettings) ([]grpc.DialOption, error) { @@ -277,12 +251,6 @@ func validateBalancerName(balancerName string) bool { return balancer.Get(balancerName) != nil } -// ToListenerContext returns the net.Listener constructed from the settings. -// Deprecated: [v0.95.0] Call Listen directly on the NetAddr field. -func (gss *ServerConfig) ToListenerContext(ctx context.Context) (net.Listener, error) { - return gss.NetAddr.Listen(ctx) -} - func (gss *ServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) { opts, err := gss.toServerOption(host, settings) if err != nil { diff --git a/config/configgrpc/configgrpc_test.go b/config/configgrpc/configgrpc_test.go index 913ac06d206..dd77209d3e8 100644 --- a/config/configgrpc/configgrpc_test.go +++ b/config/configgrpc/configgrpc_test.go @@ -493,14 +493,8 @@ func TestGRPCServerSettings_ToListener_Error(t *testing.T) { Endpoint: "127.0.0.1:1234567", Transport: "tcp", }, - TLSSetting: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CertFile: "/doesnt/exist", - }, - }, - Keepalive: nil, } - _, err := settings.ToListenerContext(context.Background()) + _, err := settings.NetAddr.Listen(context.Background()) assert.Error(t, err) } @@ -622,7 +616,7 @@ func TestHttpReception(t *testing.T) { }, TLSSetting: test.tlsServerCreds, } - ln, err := gss.ToListenerContext(context.Background()) + ln, err := gss.NetAddr.Listen(context.Background()) assert.NoError(t, err) s, err := gss.ToServer(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) @@ -669,7 +663,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) { Transport: "unix", }, } - ln, err := gss.ToListenerContext(context.Background()) + ln, err := gss.NetAddr.Listen(context.Background()) assert.NoError(t, err) srv, err := gss.ToServer(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) assert.NoError(t, err) @@ -871,7 +865,7 @@ func TestClientInfoInterceptors(t *testing.T) { defer srv.Stop() - l, err = gss.ToListenerContext(context.Background()) + l, err = gss.NetAddr.Listen(context.Background()) require.NoError(t, err) go func() { diff --git a/exporter/otlpexporter/config.go b/exporter/otlpexporter/config.go index 61440c3a9e3..4f9efd5363a 100644 --- a/exporter/otlpexporter/config.go +++ b/exporter/otlpexporter/config.go @@ -22,7 +22,7 @@ type Config struct { } func (c *Config) Validate() error { - if c.SanitizedEndpoint() == "" { + if c.Endpoint == "" { return errors.New(`requires a non-empty "endpoint"`) } return nil diff --git a/receiver/otlpreceiver/otlp.go b/receiver/otlpreceiver/otlp.go index da94a6eca71..a31895de054 100644 --- a/receiver/otlpreceiver/otlp.go +++ b/receiver/otlpreceiver/otlp.go @@ -101,7 +101,7 @@ func (r *otlpReceiver) startGRPCServer(host component.Host) error { r.settings.Logger.Info("Starting GRPC server", zap.String("endpoint", r.cfg.GRPC.NetAddr.Endpoint)) var gln net.Listener - if gln, err = r.cfg.GRPC.ToListenerContext(context.Background()); err != nil { + if gln, err = r.cfg.GRPC.NetAddr.Listen(context.Background()); err != nil { return err }