Skip to content

Commit

Permalink
[configgrpc] Deprecate GRPCServerSettings, use ServerConfig instead (#…
Browse files Browse the repository at this point in the history
…9403)

**Description:**
Deprecate GRPCServerSettings, use ~GRPC~ServerConfig instead

**Link to tracking Issue:**
#6767
  • Loading branch information
atoulme committed Feb 1, 2024
1 parent 5bcd109 commit 421c655
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 32 deletions.
25 changes: 25 additions & 0 deletions .chloggen/grpcserversettings_grpcserverconfig.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: 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: Deprecate GRPCServerSettings, use ServerConfig instead

# One or more tracking issues or pull requests related to the change
issues: [6767]

# (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]
14 changes: 9 additions & 5 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ type KeepaliveEnforcementPolicy struct {
}

// GRPCServerSettings defines common settings for a gRPC server configuration.
type GRPCServerSettings struct {
// 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.
NetAddr confignet.NetAddr `mapstructure:",squash"`

Expand Down Expand Up @@ -269,17 +273,17 @@ func validateBalancerName(balancerName string) bool {
}

// ToListenerContext returns the net.Listener constructed from the settings.
func (gss *GRPCServerSettings) ToListenerContext(ctx context.Context) (net.Listener, error) {
func (gss *ServerConfig) ToListenerContext(ctx context.Context) (net.Listener, error) {
return gss.NetAddr.Listen(ctx)
}

// ToListener returns the net.Listener constructed from the settings.
// Deprecated: [v0.94.0] use ToListenerContext instead.
func (gss *GRPCServerSettings) ToListener() (net.Listener, error) {
func (gss *ServerConfig) ToListener() (net.Listener, error) {
return gss.ToListenerContext(context.Background())
}

func (gss *GRPCServerSettings) ToServer(host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
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 {
return nil, err
Expand All @@ -288,7 +292,7 @@ func (gss *GRPCServerSettings) ToServer(host component.Host, settings component.
return grpc.NewServer(opts...), nil
}

func (gss *GRPCServerSettings) toServerOption(host component.Host, settings component.TelemetrySettings) ([]grpc.ServerOption, error) {
func (gss *ServerConfig) toServerOption(host component.Host, settings component.TelemetrySettings) ([]grpc.ServerOption, error) {
switch gss.NetAddr.Transport {
case "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6":
internal.WarnOnUnspecifiedHost(settings.Logger, gss.NetAddr.Endpoint)
Expand Down
30 changes: 15 additions & 15 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
}

func TestDefaultGrpcServerSettings(t *testing.T) {
gss := &GRPCServerSettings{
gss := &ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "0.0.0.0:1234",
},
Expand All @@ -184,7 +184,7 @@ func TestDefaultGrpcServerSettings(t *testing.T) {
}

func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
gss := &GRPCServerSettings{
gss := &ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "localhost:1234",
Transport: "tcp",
Expand Down Expand Up @@ -217,7 +217,7 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
}

func TestGrpcServerAuthSettings(t *testing.T) {
gss := &GRPCServerSettings{
gss := &ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "0.0.0.0:1234",
},
Expand Down Expand Up @@ -378,11 +378,11 @@ func TestUseSecure(t *testing.T) {
func TestGRPCServerWarning(t *testing.T) {
tests := []struct {
name string
settings GRPCServerSettings
settings ServerConfig
len int
}{
{
settings: GRPCServerSettings{
settings: ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "0.0.0.0:1234",
Transport: "tcp",
Expand All @@ -391,7 +391,7 @@ func TestGRPCServerWarning(t *testing.T) {
len: 1,
},
{
settings: GRPCServerSettings{
settings: ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "127.0.0.1:1234",
Transport: "tcp",
Expand All @@ -400,7 +400,7 @@ func TestGRPCServerWarning(t *testing.T) {
len: 0,
},
{
settings: GRPCServerSettings{
settings: ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "0.0.0.0:1234",
Transport: "unix",
Expand Down Expand Up @@ -428,12 +428,12 @@ func TestGRPCServerWarning(t *testing.T) {

func TestGRPCServerSettingsError(t *testing.T) {
tests := []struct {
settings GRPCServerSettings
settings ServerConfig
err string
}{
{
err: "^failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:",
settings: GRPCServerSettings{
settings: ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "127.0.0.1:1234",
Transport: "tcp",
Expand All @@ -447,7 +447,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
},
{
err: "^failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither",
settings: GRPCServerSettings{
settings: ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "127.0.0.1:1234",
Transport: "tcp",
Expand All @@ -461,7 +461,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
},
{
err: "^failed to load client CA CertPool: failed to load CA /doesnt/exist:",
settings: GRPCServerSettings{
settings: ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "127.0.0.1:1234",
Transport: "tcp",
Expand All @@ -481,7 +481,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
}

func TestGRPCServerSettings_ToListener_Error(t *testing.T) {
settings := GRPCServerSettings{
settings := ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "127.0.0.1:1234567",
Transport: "tcp",
Expand Down Expand Up @@ -608,7 +608,7 @@ func TestHttpReception(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
gss := &GRPCServerSettings{
gss := &ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "localhost:0",
Transport: "tcp",
Expand Down Expand Up @@ -655,7 +655,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) {
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })

socketName := tempSocketName(t)
gss := &GRPCServerSettings{
gss := &ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: socketName,
Transport: "unix",
Expand Down Expand Up @@ -850,7 +850,7 @@ func TestClientInfoInterceptors(t *testing.T) {

// prepare the server
{
gss := &GRPCServerSettings{
gss := &ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "localhost:0",
Transport: "tcp",
Expand Down
4 changes: 2 additions & 2 deletions receiver/otlpreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type HTTPConfig struct {

// Protocols is the configuration for the supported protocols.
type Protocols struct {
GRPC *configgrpc.GRPCServerSettings `mapstructure:"grpc"`
HTTP *HTTPConfig `mapstructure:"http"`
GRPC *configgrpc.ServerConfig `mapstructure:"grpc"`
HTTP *HTTPConfig `mapstructure:"http"`
}

// Config defines configuration for OTLP receiver.
Expand Down
4 changes: 2 additions & 2 deletions receiver/otlpreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestUnmarshalConfig(t *testing.T) {
assert.Equal(t,
&Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "0.0.0.0:4317",
Transport: "tcp",
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestUnmarshalConfigUnix(t *testing.T) {
assert.Equal(t,
&Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "/tmp/grpc_otlp.sock",
Transport: "unix",
Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewFactory() receiver.Factory {
func createDefaultConfig() component.Config {
return &Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: localhostgate.EndpointForPort(grpcPort),
Transport: "tcp",
Expand Down
12 changes: 6 additions & 6 deletions receiver/otlpreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestCreateSameReceiver(t *testing.T) {

func TestCreateTracesReceiver(t *testing.T) {
factory := NewFactory()
defaultGRPCSettings := &configgrpc.GRPCServerSettings{
defaultGRPCSettings := &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: testutil.GetAvailableLocalAddress(t),
Transport: "tcp",
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestCreateTracesReceiver(t *testing.T) {
name: "invalid_grpc_port",
cfg: &Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "localhost:112233",
Transport: "tcp",
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestCreateTracesReceiver(t *testing.T) {

func TestCreateMetricReceiver(t *testing.T) {
factory := NewFactory()
defaultGRPCSettings := &configgrpc.GRPCServerSettings{
defaultGRPCSettings := &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: testutil.GetAvailableLocalAddress(t),
Transport: "tcp",
Expand Down Expand Up @@ -198,7 +198,7 @@ func TestCreateMetricReceiver(t *testing.T) {
name: "invalid_grpc_address",
cfg: &Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "327.0.0.1:1122",
Transport: "tcp",
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestCreateMetricReceiver(t *testing.T) {

func TestCreateLogReceiver(t *testing.T) {
factory := NewFactory()
defaultGRPCSettings := &configgrpc.GRPCServerSettings{
defaultGRPCSettings := &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: testutil.GetAvailableLocalAddress(t),
Transport: "tcp",
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestCreateLogReceiver(t *testing.T) {
name: "invalid_grpc_address",
cfg: &Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: "327.0.0.1:1122",
Transport: "tcp",
Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ func TestOTLPReceiverHTTPTracesIngestTest(t *testing.T) {
func TestGRPCInvalidTLSCredentials(t *testing.T) {
cfg := &Config{
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.NetAddr{
Endpoint: testutil.GetAvailableLocalAddress(t),
Transport: "tcp",
Expand Down

0 comments on commit 421c655

Please sign in to comment.