Skip to content

Commit

Permalink
updated grpc config to use DialContext (#11575)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This is related #11537 and [this grpc
issue](grpc/grpc-go#7779), to reiterate there
is a bug in the grpc-go NewClient that makes the way the hostname is
resolved incompatible with the way proxy setting are applied. Due to
this domain based NO_PROXY setting do not work for grpc connections.
They are working on a fix in the grpc library but until then it seems
like it might be a good idea to revert to using DialContext instead of
NewClient.

If there's a workaround for this that anyone is aware of that could be
suitable as well, the most clear one of using passthrough doesn't work
since we sanitize the endpoint.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #11537 

<!--Describe what testing was performed and which tests were added.-->
#### Testing

I added some logging where the proxy setting are evaluated to show the
behavior.

**DialContext**
______
InMatch
host :  otel*******</DOMAIN-NAME/>
m.host :  </DOMAIN-NAME/> 
hasSuffix :  true
m.matchHost :  true
______

**NewClient**
______
InMatch
host :  10.*.*.*.*
m.host :  </DOMAIN-NAME/> 
hasSuffix :  false
m.matchHost :  false
______

---------

Co-authored-by: Yang Song <[email protected]>
  • Loading branch information
akats7 and songy23 authored Nov 4, 2024
1 parent 9ae29a8 commit bfa1dc5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-client-update.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: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: config/configgrpc

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Patch for bug in the grpc-go NewClient that makes the way the hostname is resolved incompatible with the way proxy setting are applied.

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

# (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: []
3 changes: 2 additions & 1 deletion config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ func (gcs *ClientConfig) ToClientConn(
if err != nil {
return nil, err
}
return grpc.NewClient(gcs.sanitizedEndpoint(), grpcOpts...)
//nolint:staticcheck //SA1019 see https://github.com/open-telemetry/opentelemetry-collector/pull/11575
return grpc.DialContext(ctx, gcs.sanitizedEndpoint(), grpcOpts...)
}

func (gcs *ClientConfig) getGrpcDialOptions(
Expand Down

0 comments on commit bfa1dc5

Please sign in to comment.