-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: Add support for point-to-multipoint forwarders in NSM #1122
Conversation
Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com>
Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com>
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
26f4994
to
83f9185
Compare
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
@@ -253,3 +254,78 @@ func Test_ShouldParseNetworkServiceLabelsTemplate(t *testing.T) { | |||
_, err = nse.Unregister(ctx, nseReg) | |||
require.NoError(t, err) | |||
} | |||
|
|||
func Test_UsecasePoint2MultiPoint(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edwarnicke Is this test look valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
nsRegistry, | ||
) | ||
|
||
var nseInMemoryRegistry = registrychain.NewNetworkServiceEndpointRegistryServer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: now nsmgr has its own memory registry cache by default.
@@ -119,7 +119,8 @@ func Test_ShouldCorrectlyAddForwardersWithSameNames(t *testing.T) { | |||
require.NoError(t, err) | |||
|
|||
forwarderReg := ®istry.NetworkServiceEndpoint{ | |||
Name: "forwarder", | |||
Name: "forwarder", | |||
NetworkServiceNames: []string{"forwarder"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should we add const for forwarder networkservicename into api?
- Should we create a registry network service endpoint client chain element for registration forwarders?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we create a registry network service endpoint client chain element for registration forwarders?
I don't quite follow this, could you say more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can add something like:
type setForwarderNetworkServiceNameNSEClient struct{}
func (n *setNetworkServiceNamesNSEClient) Register(ctx context.Context, in *registry.NetworkServiceEndpoint, opts ...grpc.CallOption) (*registry.NetworkServiceEndpoint, error) {
in.NetworkServiceNames = []string{"forwarder"}
...
This client can be used by forwarders on registration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... that's interesting... but how does it handle the case of that being overriden for some reason by env variables in the forwarder?
Better question... where is the 'forwarder' string encoded in the NSMgr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better question... where is the 'forwarder' string encoded in the NSMgr ?
See at discovercrossnse chain element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you are fine with this, then I'll add the option as you suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forwarders should already be able to overload the NS name via ENV variable... do they not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but all forwarders and nsmgrs on the cluster should use the same network service name. So constant in api can simplify it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly, I like your suggestion, but just shared another possible way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 1a0be07
@@ -39,6 +39,7 @@ import ( | |||
) | |||
|
|||
func Test_Local_NoURLUsecase(t *testing.T) { | |||
t.Skip("https://github.com/networkservicemesh/sdk/issues/1118") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This is disabled because with p2mp rework forwarder should recv fd from the nsmgr registry. Currently, it is not working in these unit tests by #1118 but these scenarios work well in integration tests.
@@ -84,6 +85,7 @@ func Test_Local_NoURLUsecase(t *testing.T) { | |||
} | |||
|
|||
func Test_MultiForwarderSendfd(t *testing.T) { | |||
t.Skip("https://github.com/networkservicemesh/sdk/issues/1118") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This is disabled because with p2mp rework forwarder should recv fd from the nsmgr registry. Currently, it is not working in these unit tests by #1118 but these scenarios work well in integration tests.
continue | ||
} | ||
nseCandidates := make([]*registry.NetworkServiceEndpoint, 0) | ||
// Check all Destinations in that match | ||
for _, destination := range match.GetRoutes() { | ||
// Each NSE should be matched against that destination | ||
for _, nse := range validNetworkServiceEndpoints { | ||
if isSubset(nse.GetNetworkServiceLabels()[ns.Name].Labels, destination.GetDestinationSelector(), nsLabels) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potential nil panic.
nse.GetNetworkServiceLabels()[ns.Name] can be nil.
Fixed.
func loadForwarderName(ctx context.Context) string { | ||
v, ok := metadata.Map(ctx, false).Load(selectedForworderKey{}) | ||
if !ok { | ||
return "" | ||
} | ||
return v.(string) | ||
} | ||
|
||
// Is returns true if passed name contains interpose identity | ||
func Is(name string) bool { | ||
return strings.HasSuffix(name, nameSuffix) | ||
func storeForwarderName(ctx context.Context, v string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential improvement:
@edwarnicke What if we'll load the forwarder name from the next path segment instead of metadata?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would that work on initial request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would that work on initial request?
For the initial request, we do have not the next segment.
So simply go to discover a forwarder (see at branch where forwarderName == ""
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And what if the next segment is no longer valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edwarnicke That's a good question. It looks like in this case we should select another forwarder.
|
||
// Package interpose provides a NetworkServiceServer chain element that tracks local Cross connect Endpoints and call them first | ||
// their unix file socket as the clienturl.ClientURL(ctx) used to connect to them. | ||
package interpose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: interpose totally deleted.
|
||
// +build linux | ||
|
||
package recvfd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: forwarder should be able to get fd from the local nse registration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
|
||
// +build linux | ||
|
||
package sendfd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: nsmgr should be able to send fd from the local nse registration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
discover.NewServer(nsClient, nseClient), | ||
roundrobin.NewServer(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edwarnicke Should we add chains/forwarder with these two chain elements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add chains/forwarder with these two chain elements?
Could you say more... I don't quite follow...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add a new pkg forwarder
into sdk/pkg/networkservice/chains/
.
So currently, it seems to me we have motivation because many forwarders may be interested in default SDK chain elements such as roundrobin
, disocver
, recvfd
, sendfd
. So we can add a default preset for them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... lets try getting the existing forwarders going first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because discover/roundrobin are kind of bespoke to our p2p forwarders... p2mp forwarders may chose to do something quite different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edwarnicke Load balancing sound like option :)
return nil, errors.New("no candidates found") | ||
} | ||
|
||
u, err := url.Parse(nses[0].Url) // TODO: Should we consider about load balancing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should consider load balancing... open an issue :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be resolved in this PR if we go with #1122 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would it be resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- cut this line https://github.com/networkservicemesh/sdk/blob/main/pkg/networkservice/common/roundrobin/server.go#L64
- add into
sdk/pkg/networkservice/setednpoint
chain element that will set this
https://github.com/networkservicemesh/sdk/blob/main/pkg/networkservice/common/roundrobin/server.go#L64 based on candidates and cleinturl from the context only if request.GetConnection().NetworkServiceEndpointName is empty. discovercrossnse
should pass into context candates.
Finally, we can have chains like this:
nsmgr:
...
discoverforwarder.NewServer(...) // works based on path segments. If it is presented into connection just get it otherwise add canidates for the next load balancing chain element
roundrobin.NewServer()
forwarder
discover.NewServer(...)
roundrobin.NewServer()
setednpointname.NewServer() //sets nse name into connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... I see... you are separating the setting of the value in the connection from the selection of where to go next.
Would it be possible to open an issue to come back to this and go ahead and land the P2MP now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to open an issue to come back to this and go ahead and land the P2MP now?
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do that then :)
Do we have corresponding PRs for the Forwarders to have them do selection? |
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k@main PR link: networkservicemesh/sdk#1122 Commit: c57ed95 Author: Denis Tingaikin Date: 2021-11-08 00:18:37 +0300 Message: - feat: Add support for point-to-multipoint forwarders in NSM (#1122) * initial p2mp re-work Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * add fixes after manual testing Signed-off-by: Denis Tingaikin <denis.tingajkin@xored.com> * delete interpose pkg Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * rework discovercrossnse and add p2mp unit test Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply review comments fixes Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com> * apply self code review Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Signed-off-by: Denis Tingaikin denis.tingajkin@xored.com
Description
This PR adds a part of p2mp rework related to SDK
Issue link
#1094
How Has This Been Tested?
Types of changes