Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/resolver: introduce a new delegating resolver to handle both target URI and proxy address resolution #7857

Merged
merged 75 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
bccef6b
delegating resolver
eshitachandwani Nov 20, 2024
6b89e0d
correct comments
eshitachandwani Nov 20, 2024
7c2fb21
correct comments
eshitachandwani Nov 20, 2024
e8bb6bc
use env from envconfig
eshitachandwani Nov 20, 2024
36d0573
use env from envconfig
eshitachandwani Nov 20, 2024
5a87284
improve comment and var
eshitachandwani Nov 20, 2024
e05a895
add comment
eshitachandwani Nov 20, 2024
e724a9a
add newaddress function
eshitachandwani Nov 20, 2024
975e235
add target resolution option and test
eshitachandwani Nov 20, 2024
4b8ade9
correct NewAddress function
eshitachandwani Nov 20, 2024
4ba3578
improve style and comments
eshitachandwani Nov 22, 2024
fa55e5b
change variable name
eshitachandwani Nov 22, 2024
df11d7c
change variable name
eshitachandwani Nov 22, 2024
8bcf2b6
test example
eshitachandwani Nov 22, 2024
a5aeb9a
revert commit
eshitachandwani Nov 22, 2024
47e7936
cleanup test and address comments
eshitachandwani Nov 25, 2024
a2e1415
address comments
eshitachandwani Nov 26, 2024
df87a68
address comments
eshitachandwani Nov 26, 2024
ed3d577
add comment
eshitachandwani Nov 26, 2024
dd5bdb3
add comment
eshitachandwani Nov 27, 2024
d24ec8b
address comments
eshitachandwani Nov 27, 2024
74c6cd0
address comments
eshitachandwani Nov 27, 2024
31d8c2c
address comments
eshitachandwani Nov 28, 2024
1643768
mae unexported key
eshitachandwani Nov 28, 2024
4a5ab5b
add backoff
eshitachandwani Nov 29, 2024
fd061c7
add backoff
eshitachandwani Nov 29, 2024
c6dbcbc
Revert "add backoff"
eshitachandwani Nov 29, 2024
2be9db3
revert backoff
eshitachandwani Nov 29, 2024
67e3799
add attributes package
eshitachandwani Nov 29, 2024
f5e1d37
correct atrributes
eshitachandwani Nov 29, 2024
019f621
address comments
eshitachandwani Dec 4, 2024
8348b1f
change tests
eshitachandwani Dec 4, 2024
f0d5b7b
correct comment
eshitachandwani Dec 4, 2024
4ac31f9
improve code
eshitachandwani Dec 6, 2024
ed413f6
improve code
eshitachandwani Dec 6, 2024
402316c
add endpt support
eshitachandwani Dec 7, 2024
dea9ddd
improve
eshitachandwani Dec 9, 2024
40f1035
add comment
eshitachandwani Dec 9, 2024
95d98b9
Merge branch 'grpc:master' into delegating_pr
eshitachandwani Dec 9, 2024
d5f4d8f
address comments
eshitachandwani Dec 10, 2024
e743cbf
add endpnt support
eshitachandwani Dec 10, 2024
e008feb
improve endpt
eshitachandwani Dec 10, 2024
4aea07d
add test for endpoints
eshitachandwani Dec 10, 2024
ed345a1
add test for endpoints
eshitachandwani Dec 10, 2024
7f416b0
condition and comment for endpoint
eshitachandwani Dec 11, 2024
e68d5de
remove condition
eshitachandwani Dec 11, 2024
8848105
refactors
eshitachandwani Dec 12, 2024
61edca1
correct
eshitachandwani Dec 12, 2024
a01cc7a
change endpoint support
eshitachandwani Dec 13, 2024
845680d
correct endpoint behvaiour for DNS
eshitachandwani Dec 13, 2024
c752bd8
correct endpoint behvaiour for DNS
eshitachandwani Dec 13, 2024
d53100c
address comments
eshitachandwani Dec 16, 2024
99292ea
improve
eshitachandwani Dec 17, 2024
74b3cf6
improve
eshitachandwani Dec 17, 2024
c745144
improve
eshitachandwani Dec 17, 2024
628a2a4
test for addresses
eshitachandwani Dec 17, 2024
eeae936
correct var names
eshitachandwani Dec 17, 2024
bc0adeb
rerun test
eshitachandwani Dec 17, 2024
9c2ce28
address comments
eshitachandwani Dec 17, 2024
4482e51
address comments
eshitachandwani Dec 17, 2024
2bafe77
improve comment
eshitachandwani Dec 17, 2024
a0a2e50
address comments
eshitachandwani Dec 18, 2024
ca2cc24
remove internal
eshitachandwani Dec 18, 2024
1f1e7f5
add no op res
eshitachandwani Dec 18, 2024
402badf
comments
eshitachandwani Dec 19, 2024
163ad20
improve
eshitachandwani Dec 19, 2024
db8b92c
Merge branch 'grpc:master' into delegating_pr
eshitachandwani Dec 19, 2024
6623eb5
Merge branch 'grpc:master' into delegating_pr
eshitachandwani Dec 20, 2024
c4bde98
address comments
eshitachandwani Dec 20, 2024
1c4b416
change target resolver state to pointer
eshitachandwani Dec 20, 2024
5dc893c
tests
eshitachandwani Dec 20, 2024
69253c7
pointer
eshitachandwani Dec 20, 2024
c5f8d6f
address comments
eshitachandwani Dec 20, 2024
bbea8c4
formatting
eshitachandwani Dec 23, 2024
fc2c41f
address comments
eshitachandwani Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions internal/proxyattributes/proxyattributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ type keyType string
const proxyOptionsKey = keyType("grpc.resolver.delegatingresolver.proxyOptions")

// Options holds the proxy connection details needed during the CONNECT
// handshake. It includes the user information and the connect address.
// handshake.
type Options struct {
User url.Userinfo
ConnectAddr string
}

// Set returns a copy of addr with attributes containing the provided user
// and connect address, which are needed during the CONNECT handshake for a
// proxy connection.
// Set returns a copy of addr with opts set in its attributes.
func Set(addr resolver.Address, opts Options) resolver.Address {
addr.Attributes = addr.Attributes.WithValue(proxyOptionsKey, opts)
return addr
Expand Down
14 changes: 7 additions & 7 deletions internal/resolver/delegatingresolver/delegatingresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,6 @@ func (r *delegatingResolver) updateClientConnStateLocked() error {
return nil
}

// Update curState to include target resolver's state information, such as
// the service config, provided by the target resolver. This ensures
// curState contains all necessary information when passed to UpdateState.
// The state update is only sent after both the target and proxy resolvers
// have sent their updates, and curState has been updated with the combined
// addresses.
curState := *r.targetResolverState
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this down to where you commented about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// If multiple resolved proxy addresses are present, we send only the
// unresolved proxy host and let net.Dial handle the proxy host name
Expand Down Expand Up @@ -242,6 +236,7 @@ func (r *delegatingResolver) updateClientConnStateLocked() error {
}
endpoints = append(endpoints, resolver.Endpoint{Addresses: addrs})
}
// Use the targetResolverState for its service config and attributes contents.
curState.Addresses = addresses
curState.Endpoints = endpoints
return r.cc.UpdateState(curState)
Expand All @@ -259,12 +254,17 @@ func (r *delegatingResolver) updateProxyResolverState(state resolver.State) erro
logger.Infof("Addresses received from proxy resolver: %s", state.Addresses)
}
if len(state.Endpoints) > 0 {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this blank line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// We expect exactly one address per endpoint because the proxy
// resolver uses "dns" resolution.
r.proxyAddrs = make([]resolver.Address, 0, len(state.Endpoints))
for _, endpoint := range state.Endpoints {
r.proxyAddrs = append(r.proxyAddrs, endpoint.Addresses...)
arjan-bal marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
} else if state.Addresses != nil {
r.proxyAddrs = state.Addresses
dfawley marked this conversation as resolved.
Show resolved Hide resolved
} else {
r.proxyAddrs = []resolver.Address{} // ensure proxyAddrs is non-nil to indicate an update has been received
}
err := r.updateClientConnStateLocked()
// Another possible approach was to block until updates are received from
Expand Down
Loading