-
Notifications
You must be signed in to change notification settings - Fork 22
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
MonitorScopeSelector with optional NetworkService? #178
Labels
enhancement
New feature or request
Comments
diff --git a/pkg/api/networkservice/connection.pb.go b/pkg/api/networkservice/connection.pb.go
index 1b1122b..bc01690 100644
--- a/pkg/api/networkservice/connection.pb.go
+++ b/pkg/api/networkservice/connection.pb.go
@@ -46,9 +46,18 @@ const (
type State int32
const (
- State_UP State = 0
- State_DOWN State = 1
- State_REFRESH_REQUESTED State = 2
+ // UP - Endpoint sets the connection state to UP when it successfully
+ // establishes the connection.
+ State_UP State = 0
+ // DOWN - Monitor Connection Server sets the connection state to DOWN
+ // when the connection is broken (for example, one of the NSM components is dead).
+ // Monitor Connection Server also sets the DOWN state for the deleted connections.
+ State_DOWN State = 1
+ // REFRESH_REQUESTED - This state indicates the server's connection parameters have
+ // been changed and the client should make a refresh to get them.
+ State_REFRESH_REQUESTED State = 2
+ // RESELECT_REQUESTED - This state indicates the client wants to use another endpoint
+ // for the connection. The client can set this state when it loses the connection.
State_RESELECT_REQUESTED State = 3
)
@@ -98,9 +107,17 @@ func (State) EnumDescriptor() ([]byte, []int) {
type ConnectionEventType int32
const (
+ // INITIAL_STATE_TRANSFER - Monitor Connection Server immediately sends event
+ // with this type to a client when the client makes MonitorConnections Request.
+ // Event with this type contains all connections that Monitor Connection Server
+ // currently has.
ConnectionEventType_INITIAL_STATE_TRANSFER ConnectionEventType = 0
- ConnectionEventType_UPDATE ConnectionEventType = 1
- ConnectionEventType_DELETE ConnectionEventType = 2
+ // UPDATE - Monitor Connection Server sends event with this type when the
+ // connection changes. For exapmle, when the state of the connection has been changed.
+ ConnectionEventType_UPDATE ConnectionEventType = 1
+ // DELETE - Monitor Connection Server sends event with this type when the connection
+ // has been closed.
+ ConnectionEventType_DELETE ConnectionEventType = 2
)
// Enum value maps for ConnectionEventType.
@@ -512,7 +529,8 @@ type MonitorScopeSelector struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- PathSegments []*PathSegment `protobuf:"bytes,1,rep,name=path_segments,json=pathSegments,proto3" json:"path_segments,omitempty"`
+ PathSegments []*PathSegment `protobuf:"bytes,1,rep,name=path_segments,json=pathSegments,proto3" json:"path_segments,omitempty"`
+ NetworkService []string `protobuf:"bytes,2,rep,name=network_service,json=networkService,proto3" json:"network_service,omitempty"`
}
func (x *MonitorScopeSelector) Reset() {
@@ -554,6 +572,13 @@ func (x *MonitorScopeSelector) GetPathSegments() []*PathSegment {
return nil
}
+func (x *MonitorScopeSelector) GetNetworkService() []string {
+ if x != nil {
+ return x.NetworkService
+ }
+ return nil
+}
+
var File_connection_proto protoreflect.FileDescriptor
var file_connection_proto_rawDesc = []byte{
@@ -640,33 +665,35 @@ var file_connection_proto_rawDesc = []byte{
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
- 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x54, 0x0a, 0x14, 0x4d,
+ 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x7d, 0x0a, 0x14, 0x4d,
0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63,
0x74, 0x6f, 0x72, 0x12, 0x3c, 0x0a, 0x0d, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x73, 0x65, 0x67, 0x6d,
0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x6e,
0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x53, 0x65, 0x67, 0x6d,
0x65, 0x6e, 0x74, 0x52, 0x0c, 0x70, 0x61, 0x74, 0x68, 0x53, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74,
- 0x73, 0x2a, 0x48, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x55, 0x50,
- 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x4f, 0x57, 0x4e, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11,
- 0x52, 0x45, 0x46, 0x52, 0x45, 0x53, 0x48, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x45,
- 0x44, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x45, 0x53, 0x45, 0x4c, 0x45, 0x43, 0x54, 0x5f,
- 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x45, 0x44, 0x10, 0x03, 0x2a, 0x49, 0x0a, 0x13, 0x43,
- 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79,
- 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x49, 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, 0x5f, 0x53, 0x54,
- 0x41, 0x54, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x4e, 0x53, 0x46, 0x45, 0x52, 0x10, 0x00, 0x12, 0x0a,
- 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45,
- 0x4c, 0x45, 0x54, 0x45, 0x10, 0x02, 0x32, 0x6a, 0x0a, 0x11, 0x4d, 0x6f, 0x6e, 0x69, 0x74, 0x6f,
- 0x72, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x55, 0x0a, 0x12, 0x4d,
- 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
- 0x73, 0x12, 0x20, 0x2e, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4d,
- 0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x53, 0x65, 0x6c, 0x65, 0x63,
- 0x74, 0x6f, 0x72, 0x1a, 0x1b, 0x2e, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
- 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74,
- 0x30, 0x01, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
- 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x6d,
- 0x65, 0x73, 0x68, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x2f,
- 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x73, 0x65, 0x72,
+ 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x6e, 0x65, 0x74, 0x77,
+ 0x6f, 0x72, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2a, 0x48, 0x0a, 0x05, 0x53, 0x74,
+ 0x61, 0x74, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x55, 0x50, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x44,
+ 0x4f, 0x57, 0x4e, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x52, 0x45, 0x46, 0x52, 0x45, 0x53, 0x48,
+ 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x16, 0x0a, 0x12,
+ 0x52, 0x45, 0x53, 0x45, 0x4c, 0x45, 0x43, 0x54, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54,
+ 0x45, 0x44, 0x10, 0x03, 0x2a, 0x49, 0x0a, 0x13, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x49,
+ 0x4e, 0x49, 0x54, 0x49, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x54, 0x52, 0x41,
+ 0x4e, 0x53, 0x46, 0x45, 0x52, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x50, 0x44, 0x41, 0x54,
+ 0x45, 0x10, 0x01, 0x12, 0x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x74, 0x6f, 0x33,
}
var (
diff --git a/pkg/api/networkservice/connection.proto b/pkg/api/networkservice/connection.proto
index 9fbe87e..e8eceee 100644
--- a/pkg/api/networkservice/connection.proto
+++ b/pkg/api/networkservice/connection.proto
@@ -91,6 +91,7 @@ message ConnectionEvent {
message MonitorScopeSelector {
repeated PathSegment path_segments = 1;
+ repeated string network_service = 2;
}
service MonitorConnection {
diff --git a/pkg/api/networkservice/connection_helpers.go b/pkg/api/networkservice/connection_helpers.go
index c37ef85..7aa1149 100644
--- a/pkg/api/networkservice/connection_helpers.go
+++ b/pkg/api/networkservice/connection_helpers.go
@@ -37,12 +37,38 @@ func (x *Connection) Clone() *Connection {
return proto.Clone(x).(*Connection)
}
+// Iterate through the selector.NetworkService array looking for a network service
+// that matches the Connection.NetworkService, treating an empty selector.NetworkService
+// array as a wildcard
+func (x *Connection) matchesNetworkService(networkService []string) bool {
+ if len(networkService) == 0 {
+ return true
+ }
+
+ for _, v := range networkService {
+ if v == x.GetNetworkService() {
+ // matched network service
+ return true
+ }
+ }
+
+ return false
+}
+
// MatchesMonitorScopeSelector - Returns true of the connection matches the selector
func (x *Connection) MatchesMonitorScopeSelector(selector *MonitorScopeSelector) bool {
if x == nil {
return false
}
// Note: Empty selector always matches a non-nil Connection
+ if len(selector.GetPathSegments()) == 0 && len(selector.GetNetworkService()) == 0 {
+ return true
+ }
+ // Compare network service names
+ if !x.matchesNetworkService(selector.GetNetworkService()) {
+ return false
+ }
+ // Empty PathSegments in selector, treat as wildcard
if len(selector.GetPathSegments()) == 0 {
return true
}
|
OK, let's consider how it can be done with the current API. ProblemMonitor events for a specific network service that implements N endpoints. Solution (without API modifications)
Solution with API modification
|
So, if I don't miss anything, then proposed solution looks good to me. @edwarnicke Could you also have a look? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd be interested in NSM connections around the cluster that belong to a particular Network Service. The concept would be similar to cmd-dashboard-backend.
However, MonitorScopeSelector only allows PathSegment based filtering/subscription.
The processes doing the monitoring would have NO knowledge on the path segments involved (might come and go over time). Using an empty selector does work, but the reason why I'd be interested in Network Service based filtering is mostly due to performance considerations.
I've attached a rudimentary patch with the proposed changes.
api.txt
The text was updated successfully, but these errors were encountered: