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

feat: Add support for point-to-multipoint forwarders in NSM #1122

Merged
merged 6 commits into from
Nov 7, 2021

Conversation

denis-tingaikin
Copy link
Member

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?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionallity
  • Documentation
  • Refactoring
  • CI

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>
@denis-tingaikin denis-tingaikin force-pushed the p2mp branch 2 times, most recently from 26f4994 to 83f9185 Compare November 7, 2021 09:33
Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
@denis-tingaikin denis-tingaikin changed the title [WIP] feat: Add support for point-to-multipoint forwarders in NSM feat: Add support for point-to-multipoint forwarders in NSM Nov 7, 2021
@@ -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) {
Copy link
Member Author

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?

Copy link
Member

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(
Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

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 := &registry.NetworkServiceEndpoint{
Name: "forwarder",
Name: "forwarder",
NetworkServiceNames: []string{"forwarder"},
Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

Choose a reason for hiding this comment

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

@edwarnicke

  1. Should we add const for forwarder networkservicename into api?
  2. Should we create a registry network service endpoint client chain element for registration forwarders?

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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 ?

Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

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.

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

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

Copy link
Member Author

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

Copy link
Member Author

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")
Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

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")
Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

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) {
Copy link
Member Author

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.

Comment on lines 27 to 35
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) {
Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

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?

Copy link
Member

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?

Copy link
Member Author

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 == "")

Copy link
Member

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?

Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

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
Copy link
Member Author

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
Copy link
Member Author

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

Copy link
Member

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
Copy link
Member Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Got it.

Comment on lines +135 to +136
discover.NewServer(nsClient, nseClient),
roundrobin.NewServer(),
Copy link
Member Author

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?

Copy link
Member

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...

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

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.

Copy link
Member Author

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 :)

@denis-tingaikin denis-tingaikin marked this pull request as ready for review November 7, 2021 09:45
return nil, errors.New("no candidates found")
}

u, err := url.Parse(nses[0].Url) // TODO: Should we consider about load balancing?
Copy link
Member

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 :)

Copy link
Member Author

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)

Copy link
Member

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?

Copy link
Member Author

@denis-tingaikin denis-tingaikin Nov 7, 2021

Choose a reason for hiding this comment

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

  1. cut this line https://github.com/networkservicemesh/sdk/blob/main/pkg/networkservice/common/roundrobin/server.go#L64
  2. 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.
  3. 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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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 :)

@edwarnicke
Copy link
Member

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>
@edwarnicke edwarnicke merged commit c57ed95 into networkservicemesh:main Nov 7, 2021
nsmbot pushed a commit to networkservicemesh/cmd-registry-memory that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/cmd-admission-webhook-k8s that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr-proxy that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/sdk-kernel that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/cmd-nse-vfio that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/cmd-nsc-init that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/cmd-registry-proxy-dns that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr that referenced this pull request Nov 7, 2021
…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>
nsmbot pushed a commit to networkservicemesh/sdk-k8s that referenced this pull request Nov 7, 2021
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants