forked from networkservicemesh/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Filter mechanism chain element works incorrectly in remote case (n…
…etworkservicemesh#575) Signed-off-by: denis-tingajkin <denis.tingajkin@xored.com>
- Loading branch information
1 parent
3216266
commit 39537ac
Showing
5 changed files
with
227 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
## Intro | ||
|
||
Package `filtermechanisms` filters out remote mechanisms if communicating by remote url | ||
filters out local mechanisms otherwise. Can be used with eNSMGR. | ||
|
||
## Options | ||
|
||
Supported option `WithExternalThreshold` that sets max path segments count for eNSMgrs. | ||
|
||
## Examples | ||
Note: **Is local** true when path segment index less than localThreshold and nsmgr knows NSE url | ||
|
||
1. Local: | ||
``` | ||
Scheme: nsc-->NSMgr-->cross-nse-->NSMgr-->nse | ||
NSMgr knows nse: true | ||
filterMechanismsServer.localThreshold: 5 | ||
len(request.Connection.Path.PathSegments): 4 | ||
Is local: true | ||
``` | ||
|
||
2. Local eNSM: | ||
``` | ||
Scheme: nsc-->eNSMgr-->nse | ||
eNSMgr knows nse: true | ||
filterMechanismsServer.localThreshold: 3 | ||
len(request.Connection.Path.PathSegments): 2 | ||
Is local: true | ||
``` | ||
|
||
3. Remote eNSM: | ||
``` | ||
Scheme: nsc-->eNSMgr1-->eNSMgr2-->nse | ||
eNSMgr1: | ||
knows nse: false | ||
filterMechanismsServer.localThreshold = 3 | ||
len(request.Connection.Path.PathSegments) = 2 | ||
Is local: false | ||
eNSMgr2: | ||
knows nse: true | ||
filterMechanismsServer.localThreshold = 3 | ||
len(request.Connection.Path.PathSegments) = 3 | ||
Is local: false | ||
``` | ||
|
||
4. Remote NSMgr + eNSMGR | ||
``` | ||
Scheme: nsc-->NSMgr1-->cross-nse1-->NSMgr1-->eNSMgr1-->nse | ||
NSMgr1: | ||
knows nse: false | ||
filterMechanismsServer.localThreshold = 5 | ||
len(request.Connection.Path.PathSegments) = 4 | ||
Is local: false | ||
eNSMgr1: | ||
knows nse: true | ||
filterMechanismsServer.localThreshold = 3 | ||
len(request.Connection.Path.PathSegments) = 5 | ||
Is local: false | ||
``` | ||
|
||
5. Remote eNSMGR + NSMgr | ||
``` | ||
Scheme: nsc-->eNSMgr1-->NSMgr1-->cross-nse1-->NSMgr1-->eNSMgr2-->nse | ||
eNSMgr1: | ||
knows nse: false | ||
filterMechanismsServer.localThreshold = 3 | ||
len(request.Connection.Path.PathSegments) = 2 | ||
Is local: false | ||
NSMgr1: | ||
knows nse: true | ||
filterMechanismsServer.localThreshold = 5 | ||
len(request.Connection.Path.PathSegments) = 5 | ||
Is local: false | ||
``` | ||
|
||
6. Remote | ||
|
||
``` | ||
Scheme: nsc-->NSMgr1-->cross-nse1-->NSMgr1-->NSMgr2-->cross-nse2-->NSMgr2-->nse | ||
NSMgr2: | ||
knows nse: false | ||
filterMechanismsServer.localThreshold = 5 | ||
len(request.Connection.Path.PathSegments) = 4 | ||
Is local: false | ||
NSMgr1: | ||
knows nse: true | ||
filterMechanismsServer.localThreshold = 5 | ||
len(request.Connection.Path.PathSegments) = 7 | ||
Is local: false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) 2020 Doc.ai and/or its affiliates. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at: | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package filtermechanisms | ||
|
||
const ( | ||
// See at examples section in README.md | ||
defaultThreshold = 5 | ||
externalThreshold = 3 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2020 Doc.ai and/or its affiliates. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at: | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package filtermechanisms | ||
|
||
// Option is option applier for filterMechanismsServer | ||
type Option func(server *filterMechanismsServer) | ||
|
||
// WithExternalThreshold configures filterMechanismsServer to work with external NSMgr. | ||
func WithExternalThreshold() Option { | ||
return Option(func(server *filterMechanismsServer) { | ||
server.localThreshold = externalThreshold | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters