API endpoint and associated RPC changes to resolve VMs IP's (#188)

* API endpoint and associated RPC changes to resolve VMs IP's

* Fix "Missing expected argument '<name>'" error when doing "tart set"

* Implement TestIPEndpoint() and IP() method in controller HTTP client
This commit is contained in:
Nikolay Edigaryev
2024-07-03 22:56:43 +04:00
committed by GitHub
parent 8119b22817
commit 76f192bdb0
18 changed files with 603 additions and 124 deletions
+7
View File
@@ -0,0 +1,7 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
+221 -49
View File
@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc-gen-go v1.34.2
// protoc (unknown)
// source: orchard.proto
@@ -30,6 +30,7 @@ type WatchInstruction struct {
//
// *WatchInstruction_PortForwardAction
// *WatchInstruction_SyncVmsAction
// *WatchInstruction_ResolveIpAction
Action isWatchInstruction_Action `protobuf_oneof:"action"`
}
@@ -86,6 +87,13 @@ func (x *WatchInstruction) GetSyncVmsAction() *WatchInstruction_SyncVMs {
return nil
}
func (x *WatchInstruction) GetResolveIpAction() *WatchInstruction_ResolveIP {
if x, ok := x.GetAction().(*WatchInstruction_ResolveIpAction); ok {
return x.ResolveIpAction
}
return nil
}
type isWatchInstruction_Action interface {
isWatchInstruction_Action()
}
@@ -98,10 +106,16 @@ type WatchInstruction_SyncVmsAction struct {
SyncVmsAction *WatchInstruction_SyncVMs `protobuf:"bytes,2,opt,name=sync_vms_action,json=syncVmsAction,proto3,oneof"`
}
type WatchInstruction_ResolveIpAction struct {
ResolveIpAction *WatchInstruction_ResolveIP `protobuf:"bytes,3,opt,name=resolve_ip_action,json=resolveIpAction,proto3,oneof"`
}
func (*WatchInstruction_PortForwardAction) isWatchInstruction_Action() {}
func (*WatchInstruction_SyncVmsAction) isWatchInstruction_Action() {}
func (*WatchInstruction_ResolveIpAction) isWatchInstruction_Action() {}
type PortForwardData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -149,6 +163,61 @@ func (x *PortForwardData) GetData() []byte {
return nil
}
type ResolveIPResult struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Session string `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"`
Ip string `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"`
}
func (x *ResolveIPResult) Reset() {
*x = ResolveIPResult{}
if protoimpl.UnsafeEnabled {
mi := &file_orchard_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ResolveIPResult) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ResolveIPResult) ProtoMessage() {}
func (x *ResolveIPResult) ProtoReflect() protoreflect.Message {
mi := &file_orchard_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ResolveIPResult.ProtoReflect.Descriptor instead.
func (*ResolveIPResult) Descriptor() ([]byte, []int) {
return file_orchard_proto_rawDescGZIP(), []int{2}
}
func (x *ResolveIPResult) GetSession() string {
if x != nil {
return x.Session
}
return ""
}
func (x *ResolveIPResult) GetIp() string {
if x != nil {
return x.Ip
}
return ""
}
type WatchInstruction_PortForward struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -157,7 +226,7 @@ type WatchInstruction_PortForward struct {
// we can have multiple port forwards for the same vm/port pair
// let's distinguish them by a unique session
Session string `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"`
// can be empty to request a forwarding to the worker itself
// can be empty to request port-forwarding to the worker itself
VmUid string `protobuf:"bytes,2,opt,name=vm_uid,json=vmUid,proto3" json:"vm_uid,omitempty"`
Port uint32 `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
}
@@ -165,7 +234,7 @@ type WatchInstruction_PortForward struct {
func (x *WatchInstruction_PortForward) Reset() {
*x = WatchInstruction_PortForward{}
if protoimpl.UnsafeEnabled {
mi := &file_orchard_proto_msgTypes[2]
mi := &file_orchard_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -178,7 +247,7 @@ func (x *WatchInstruction_PortForward) String() string {
func (*WatchInstruction_PortForward) ProtoMessage() {}
func (x *WatchInstruction_PortForward) ProtoReflect() protoreflect.Message {
mi := &file_orchard_proto_msgTypes[2]
mi := &file_orchard_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -224,7 +293,7 @@ type WatchInstruction_SyncVMs struct {
func (x *WatchInstruction_SyncVMs) Reset() {
*x = WatchInstruction_SyncVMs{}
if protoimpl.UnsafeEnabled {
mi := &file_orchard_proto_msgTypes[3]
mi := &file_orchard_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -237,7 +306,7 @@ func (x *WatchInstruction_SyncVMs) String() string {
func (*WatchInstruction_SyncVMs) ProtoMessage() {}
func (x *WatchInstruction_SyncVMs) ProtoReflect() protoreflect.Message {
mi := &file_orchard_proto_msgTypes[3]
mi := &file_orchard_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -253,12 +322,69 @@ func (*WatchInstruction_SyncVMs) Descriptor() ([]byte, []int) {
return file_orchard_proto_rawDescGZIP(), []int{0, 1}
}
type WatchInstruction_ResolveIP struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// we can have multiple IP resolution requests for the same vm
// let's distinguish them by a unique session
Session string `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"`
VmUid string `protobuf:"bytes,2,opt,name=vm_uid,json=vmUid,proto3" json:"vm_uid,omitempty"`
}
func (x *WatchInstruction_ResolveIP) Reset() {
*x = WatchInstruction_ResolveIP{}
if protoimpl.UnsafeEnabled {
mi := &file_orchard_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WatchInstruction_ResolveIP) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WatchInstruction_ResolveIP) ProtoMessage() {}
func (x *WatchInstruction_ResolveIP) ProtoReflect() protoreflect.Message {
mi := &file_orchard_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use WatchInstruction_ResolveIP.ProtoReflect.Descriptor instead.
func (*WatchInstruction_ResolveIP) Descriptor() ([]byte, []int) {
return file_orchard_proto_rawDescGZIP(), []int{0, 2}
}
func (x *WatchInstruction_ResolveIP) GetSession() string {
if x != nil {
return x.Session
}
return ""
}
func (x *WatchInstruction_ResolveIP) GetVmUid() string {
if x != nil {
return x.VmUid
}
return ""
}
var File_orchard_proto protoreflect.FileDescriptor
var file_orchard_proto_rawDesc = []byte{
0x0a, 0x0d, 0x6f, 0x72, 0x63, 0x68, 0x61, 0x72, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x91, 0x02, 0x0a,
0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9a, 0x03, 0x0a,
0x10, 0x57, 0x61, 0x74, 0x63, 0x68, 0x49, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f,
0x6e, 0x12, 0x4f, 0x0a, 0x13, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72,
0x64, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d,
@@ -269,26 +395,42 @@ var file_orchard_proto_rawDesc = []byte{
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x57, 0x61,
0x74, 0x63, 0x68, 0x49, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53,
0x79, 0x6e, 0x63, 0x56, 0x4d, 0x73, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x79, 0x6e, 0x63, 0x56, 0x6d,
0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x52, 0x0a, 0x0b, 0x50, 0x6f, 0x72, 0x74, 0x46,
0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x12, 0x15, 0x0a, 0x06, 0x76, 0x6d, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x76, 0x6d, 0x55, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x09, 0x0a, 0x07, 0x53,
0x79, 0x6e, 0x63, 0x56, 0x4d, 0x73, 0x42, 0x08, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x22, 0x25, 0x0a, 0x0f, 0x50, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x44,
0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x79, 0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x72,
0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x05, 0x57, 0x61, 0x74, 0x63, 0x68, 0x12, 0x16,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x49, 0x6e,
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x0b, 0x50,
0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x12, 0x10, 0x2e, 0x50, 0x6f, 0x72,
0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x44, 0x61, 0x74, 0x61, 0x1a, 0x10, 0x2e, 0x50,
0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x44, 0x61, 0x74, 0x61, 0x28, 0x01,
0x30, 0x01, 0x42, 0x23, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x63, 0x69, 0x72, 0x72, 0x75, 0x73, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6f, 0x72, 0x63, 0x68,
0x61, 0x72, 0x64, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x49, 0x0a, 0x11, 0x72, 0x65, 0x73, 0x6f, 0x6c,
0x76, 0x65, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x49, 0x6e, 0x73, 0x74, 0x72, 0x75,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x49, 0x50, 0x48,
0x00, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x49, 0x70, 0x41, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x1a, 0x52, 0x0a, 0x0b, 0x50, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72,
0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x76,
0x6d, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x6d, 0x55,
0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x09, 0x0a, 0x07, 0x53, 0x79, 0x6e, 0x63, 0x56, 0x4d,
0x73, 0x1a, 0x3c, 0x0a, 0x09, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x49, 0x50, 0x12, 0x18,
0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x06, 0x76, 0x6d, 0x5f, 0x75,
0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x6d, 0x55, 0x69, 0x64, 0x42,
0x08, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x25, 0x0a, 0x0f, 0x50, 0x6f, 0x72,
0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04,
0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
0x22, 0x3b, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x49, 0x50, 0x52, 0x65, 0x73,
0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x32, 0xb0, 0x01,
0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x05,
0x57, 0x61, 0x74, 0x63, 0x68, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x11, 0x2e,
0x57, 0x61, 0x74, 0x63, 0x68, 0x49, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x30, 0x01, 0x12, 0x35, 0x0a, 0x0b, 0x50, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72,
0x64, 0x12, 0x10, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x44,
0x61, 0x74, 0x61, 0x1a, 0x10, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x46, 0x6f, 0x72, 0x77, 0x61, 0x72,
0x64, 0x44, 0x61, 0x74, 0x61, 0x28, 0x01, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x09, 0x52, 0x65, 0x73,
0x6f, 0x6c, 0x76, 0x65, 0x49, 0x50, 0x12, 0x10, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65,
0x49, 0x50, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x42, 0x23, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63,
0x69, 0x72, 0x72, 0x75, 0x73, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6f, 0x72, 0x63, 0x68, 0x61, 0x72,
0x64, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -303,26 +445,31 @@ func file_orchard_proto_rawDescGZIP() []byte {
return file_orchard_proto_rawDescData
}
var file_orchard_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_orchard_proto_goTypes = []interface{}{
var file_orchard_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_orchard_proto_goTypes = []any{
(*WatchInstruction)(nil), // 0: WatchInstruction
(*PortForwardData)(nil), // 1: PortForwardData
(*WatchInstruction_PortForward)(nil), // 2: WatchInstruction.PortForward
(*WatchInstruction_SyncVMs)(nil), // 3: WatchInstruction.SyncVMs
(*emptypb.Empty)(nil), // 4: google.protobuf.Empty
(*ResolveIPResult)(nil), // 2: ResolveIPResult
(*WatchInstruction_PortForward)(nil), // 3: WatchInstruction.PortForward
(*WatchInstruction_SyncVMs)(nil), // 4: WatchInstruction.SyncVMs
(*WatchInstruction_ResolveIP)(nil), // 5: WatchInstruction.ResolveIP
(*emptypb.Empty)(nil), // 6: google.protobuf.Empty
}
var file_orchard_proto_depIdxs = []int32{
2, // 0: WatchInstruction.port_forward_action:type_name -> WatchInstruction.PortForward
3, // 1: WatchInstruction.sync_vms_action:type_name -> WatchInstruction.SyncVMs
4, // 2: Controller.Watch:input_type -> google.protobuf.Empty
1, // 3: Controller.PortForward:input_type -> PortForwardData
0, // 4: Controller.Watch:output_type -> WatchInstruction
1, // 5: Controller.PortForward:output_type -> PortForwardData
4, // [4:6] is the sub-list for method output_type
2, // [2:4] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
3, // 0: WatchInstruction.port_forward_action:type_name -> WatchInstruction.PortForward
4, // 1: WatchInstruction.sync_vms_action:type_name -> WatchInstruction.SyncVMs
5, // 2: WatchInstruction.resolve_ip_action:type_name -> WatchInstruction.ResolveIP
6, // 3: Controller.Watch:input_type -> google.protobuf.Empty
1, // 4: Controller.PortForward:input_type -> PortForwardData
2, // 5: Controller.ResolveIP:input_type -> ResolveIPResult
0, // 6: Controller.Watch:output_type -> WatchInstruction
1, // 7: Controller.PortForward:output_type -> PortForwardData
6, // 8: Controller.ResolveIP:output_type -> google.protobuf.Empty
6, // [6:9] is the sub-list for method output_type
3, // [3:6] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_orchard_proto_init() }
@@ -331,7 +478,7 @@ func file_orchard_proto_init() {
return
}
if !protoimpl.UnsafeEnabled {
file_orchard_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
file_orchard_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*WatchInstruction); i {
case 0:
return &v.state
@@ -343,7 +490,7 @@ func file_orchard_proto_init() {
return nil
}
}
file_orchard_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
file_orchard_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*PortForwardData); i {
case 0:
return &v.state
@@ -355,7 +502,19 @@ func file_orchard_proto_init() {
return nil
}
}
file_orchard_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
file_orchard_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*ResolveIPResult); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_orchard_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*WatchInstruction_PortForward); i {
case 0:
return &v.state
@@ -367,7 +526,7 @@ func file_orchard_proto_init() {
return nil
}
}
file_orchard_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
file_orchard_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*WatchInstruction_SyncVMs); i {
case 0:
return &v.state
@@ -379,10 +538,23 @@ func file_orchard_proto_init() {
return nil
}
}
file_orchard_proto_msgTypes[5].Exporter = func(v any, i int) any {
switch v := v.(*WatchInstruction_ResolveIP); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_orchard_proto_msgTypes[0].OneofWrappers = []interface{}{
file_orchard_proto_msgTypes[0].OneofWrappers = []any{
(*WatchInstruction_PortForwardAction)(nil),
(*WatchInstruction_SyncVmsAction)(nil),
(*WatchInstruction_ResolveIpAction)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -390,7 +562,7 @@ func file_orchard_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_orchard_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
+16
View File
@@ -11,6 +11,9 @@ service Controller {
// single purpose method when a port forward is requested and running
// session information is passed in the requests metadata
rpc PortForward(stream PortForwardData) returns (stream PortForwardData);
// worker calls this method when it has successfully resolved the VM's IP
rpc ResolveIP(ResolveIPResult) returns (google.protobuf.Empty);
}
message WatchInstruction {
@@ -23,14 +26,27 @@ message WatchInstruction {
uint32 port = 3;
}
message SyncVMs {
// nothing for now
}
message ResolveIP {
// we can have multiple IP resolution requests for the same vm
// let's distinguish them by a unique session
string session = 1;
string vm_uid = 2;
}
oneof action {
PortForward port_forward_action = 1;
SyncVMs sync_vms_action = 2;
ResolveIP resolve_ip_action = 3;
}
}
message PortForwardData {
bytes data = 1;
}
message ResolveIPResult {
string session = 1;
string ip = 2;
}
+53 -10
View File
@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc-gen-go-grpc v1.4.0
// - protoc (unknown)
// source: orchard.proto
@@ -16,12 +16,13 @@ import (
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// Requires gRPC-Go v1.62.0 or later.
const _ = grpc.SupportPackageIsVersion8
const (
Controller_Watch_FullMethodName = "/Controller/Watch"
Controller_PortForward_FullMethodName = "/Controller/PortForward"
Controller_ResolveIP_FullMethodName = "/Controller/ResolveIP"
)
// ControllerClient is the client API for Controller service.
@@ -33,6 +34,8 @@ type ControllerClient interface {
// single purpose method when a port forward is requested and running
// session information is passed in the requests metadata
PortForward(ctx context.Context, opts ...grpc.CallOption) (Controller_PortForwardClient, error)
// worker calls this method when it has successfully resolved the VM's IP
ResolveIP(ctx context.Context, in *ResolveIPResult, opts ...grpc.CallOption) (*emptypb.Empty, error)
}
type controllerClient struct {
@@ -44,11 +47,12 @@ func NewControllerClient(cc grpc.ClientConnInterface) ControllerClient {
}
func (c *controllerClient) Watch(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (Controller_WatchClient, error) {
stream, err := c.cc.NewStream(ctx, &Controller_ServiceDesc.Streams[0], Controller_Watch_FullMethodName, opts...)
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &Controller_ServiceDesc.Streams[0], Controller_Watch_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &controllerWatchClient{stream}
x := &controllerWatchClient{ClientStream: stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
@@ -76,11 +80,12 @@ func (x *controllerWatchClient) Recv() (*WatchInstruction, error) {
}
func (c *controllerClient) PortForward(ctx context.Context, opts ...grpc.CallOption) (Controller_PortForwardClient, error) {
stream, err := c.cc.NewStream(ctx, &Controller_ServiceDesc.Streams[1], Controller_PortForward_FullMethodName, opts...)
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &Controller_ServiceDesc.Streams[1], Controller_PortForward_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &controllerPortForwardClient{stream}
x := &controllerPortForwardClient{ClientStream: stream}
return x, nil
}
@@ -106,6 +111,16 @@ func (x *controllerPortForwardClient) Recv() (*PortForwardData, error) {
return m, nil
}
func (c *controllerClient) ResolveIP(ctx context.Context, in *ResolveIPResult, opts ...grpc.CallOption) (*emptypb.Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, Controller_ResolveIP_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// ControllerServer is the server API for Controller service.
// All implementations must embed UnimplementedControllerServer
// for forward compatibility
@@ -115,6 +130,8 @@ type ControllerServer interface {
// single purpose method when a port forward is requested and running
// session information is passed in the requests metadata
PortForward(Controller_PortForwardServer) error
// worker calls this method when it has successfully resolved the VM's IP
ResolveIP(context.Context, *ResolveIPResult) (*emptypb.Empty, error)
mustEmbedUnimplementedControllerServer()
}
@@ -128,6 +145,9 @@ func (UnimplementedControllerServer) Watch(*emptypb.Empty, Controller_WatchServe
func (UnimplementedControllerServer) PortForward(Controller_PortForwardServer) error {
return status.Errorf(codes.Unimplemented, "method PortForward not implemented")
}
func (UnimplementedControllerServer) ResolveIP(context.Context, *ResolveIPResult) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ResolveIP not implemented")
}
func (UnimplementedControllerServer) mustEmbedUnimplementedControllerServer() {}
// UnsafeControllerServer may be embedded to opt out of forward compatibility for this service.
@@ -146,7 +166,7 @@ func _Controller_Watch_Handler(srv interface{}, stream grpc.ServerStream) error
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(ControllerServer).Watch(m, &controllerWatchServer{stream})
return srv.(ControllerServer).Watch(m, &controllerWatchServer{ServerStream: stream})
}
type Controller_WatchServer interface {
@@ -163,7 +183,7 @@ func (x *controllerWatchServer) Send(m *WatchInstruction) error {
}
func _Controller_PortForward_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ControllerServer).PortForward(&controllerPortForwardServer{stream})
return srv.(ControllerServer).PortForward(&controllerPortForwardServer{ServerStream: stream})
}
type Controller_PortForwardServer interface {
@@ -188,13 +208,36 @@ func (x *controllerPortForwardServer) Recv() (*PortForwardData, error) {
return m, nil
}
func _Controller_ResolveIP_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ResolveIPResult)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ControllerServer).ResolveIP(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Controller_ResolveIP_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ControllerServer).ResolveIP(ctx, req.(*ResolveIPResult))
}
return interceptor(ctx, in, info, handler)
}
// Controller_ServiceDesc is the grpc.ServiceDesc for Controller service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Controller_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Controller",
HandlerType: (*ControllerServer)(nil),
Methods: []grpc.MethodDesc{},
Methods: []grpc.MethodDesc{
{
MethodName: "ResolveIP",
Handler: _Controller_ResolveIP_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "Watch",