From fc847093d29c121ab48f2401cb720971806d8c85 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Fri, 19 Dec 2025 16:29:14 +1000 Subject: [PATCH] chore: new InspectMachine gRPC method that to return store DB version (lamport time) --- internal/machine/api/pb/machine.pb.go | 421 +++++++++++++++------ internal/machine/api/pb/machine.proto | 17 + internal/machine/api/pb/machine_grpc.pb.go | 42 ++ internal/machine/machine.go | 27 ++ internal/machine/state.go | 3 + internal/machine/store/store.go | 19 + 6 files changed, 406 insertions(+), 123 deletions(-) diff --git a/internal/machine/api/pb/machine.pb.go b/internal/machine/api/pb/machine.pb.go index 4119dbca..c41c3d0b 100644 --- a/internal/machine/api/pb/machine.pb.go +++ b/internal/machine/api/pb/machine.pb.go @@ -371,6 +371,8 @@ type JoinClusterRequest struct { Machine *MachineInfo `protobuf:"bytes,1,opt,name=machine,proto3" json:"machine,omitempty"` OtherMachines []*MachineInfo `protobuf:"bytes,3,rep,name=other_machines,json=otherMachines,proto3" json:"other_machines,omitempty"` + // Minimum store database version the new machine should sync to before starting cluster operations. + MinStoreDbVersion int64 `protobuf:"varint,4,opt,name=min_store_db_version,json=minStoreDbVersion,proto3" json:"min_store_db_version,omitempty"` } func (x *JoinClusterRequest) Reset() { @@ -419,6 +421,125 @@ func (x *JoinClusterRequest) GetOtherMachines() []*MachineInfo { return nil } +func (x *JoinClusterRequest) GetMinStoreDbVersion() int64 { + if x != nil { + return x.MinStoreDbVersion + } + return 0 +} + +type InspectMachineResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Must contain only one repeated messages field to allow broadcasting InspectMachine requests to multiple machines. + Machines []*MachineDetails `protobuf:"bytes,1,rep,name=machines,proto3" json:"machines,omitempty"` +} + +func (x *InspectMachineResponse) Reset() { + *x = InspectMachineResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InspectMachineResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InspectMachineResponse) ProtoMessage() {} + +func (x *InspectMachineResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[6] + 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 InspectMachineResponse.ProtoReflect.Descriptor instead. +func (*InspectMachineResponse) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{6} +} + +func (x *InspectMachineResponse) GetMachines() []*MachineDetails { + if x != nil { + return x.Machines + } + return nil +} + +type MachineDetails struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + Machine *MachineInfo `protobuf:"bytes,2,opt,name=machine,proto3" json:"machine,omitempty"` + // Current Corrosion cr-sqlite database version (Lamport timestamp) of the cluster store. + StoreDbVersion int64 `protobuf:"varint,3,opt,name=store_db_version,json=storeDbVersion,proto3" json:"store_db_version,omitempty"` +} + +func (x *MachineDetails) Reset() { + *x = MachineDetails{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MachineDetails) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MachineDetails) ProtoMessage() {} + +func (x *MachineDetails) ProtoReflect() protoreflect.Message { + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[7] + 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 MachineDetails.ProtoReflect.Descriptor instead. +func (*MachineDetails) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{7} +} + +func (x *MachineDetails) GetMetadata() *Metadata { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *MachineDetails) GetMachine() *MachineInfo { + if x != nil { + return x.Machine + } + return nil +} + +func (x *MachineDetails) GetStoreDbVersion() int64 { + if x != nil { + return x.StoreDbVersion + } + return 0 +} + type TokenResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -430,7 +551,7 @@ type TokenResponse struct { func (x *TokenResponse) Reset() { *x = TokenResponse{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[6] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -443,7 +564,7 @@ func (x *TokenResponse) String() string { func (*TokenResponse) ProtoMessage() {} func (x *TokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[6] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -456,7 +577,7 @@ func (x *TokenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use TokenResponse.ProtoReflect.Descriptor instead. func (*TokenResponse) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{6} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{8} } func (x *TokenResponse) GetToken() string { @@ -475,7 +596,7 @@ type ResetRequest struct { func (x *ResetRequest) Reset() { *x = ResetRequest{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[7] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -488,7 +609,7 @@ func (x *ResetRequest) String() string { func (*ResetRequest) ProtoMessage() {} func (x *ResetRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[7] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -501,7 +622,7 @@ func (x *ResetRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResetRequest.ProtoReflect.Descriptor instead. func (*ResetRequest) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{7} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{9} } type Service struct { @@ -518,7 +639,7 @@ type Service struct { func (x *Service) Reset() { *x = Service{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[8] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -531,7 +652,7 @@ func (x *Service) String() string { func (*Service) ProtoMessage() {} func (x *Service) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[8] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -544,7 +665,7 @@ func (x *Service) ProtoReflect() protoreflect.Message { // Deprecated: Use Service.ProtoReflect.Descriptor instead. func (*Service) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{8} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{10} } func (x *Service) GetId() string { @@ -586,7 +707,7 @@ type InspectServiceRequest struct { func (x *InspectServiceRequest) Reset() { *x = InspectServiceRequest{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[9] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -599,7 +720,7 @@ func (x *InspectServiceRequest) String() string { func (*InspectServiceRequest) ProtoMessage() {} func (x *InspectServiceRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[9] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -612,7 +733,7 @@ func (x *InspectServiceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use InspectServiceRequest.ProtoReflect.Descriptor instead. func (*InspectServiceRequest) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{9} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{11} } func (x *InspectServiceRequest) GetId() string { @@ -633,7 +754,7 @@ type InspectServiceResponse struct { func (x *InspectServiceResponse) Reset() { *x = InspectServiceResponse{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[10] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -646,7 +767,7 @@ func (x *InspectServiceResponse) String() string { func (*InspectServiceResponse) ProtoMessage() {} func (x *InspectServiceResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[10] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -659,7 +780,7 @@ func (x *InspectServiceResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use InspectServiceResponse.ProtoReflect.Descriptor instead. func (*InspectServiceResponse) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{10} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{12} } func (x *InspectServiceResponse) GetService() *Service { @@ -682,7 +803,7 @@ type Service_Container struct { func (x *Service_Container) Reset() { *x = Service_Container{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[11] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -695,7 +816,7 @@ func (x *Service_Container) String() string { func (*Service_Container) ProtoMessage() {} func (x *Service_Container) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[11] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -708,7 +829,7 @@ func (x *Service_Container) ProtoReflect() protoreflect.Message { // Deprecated: Use Service_Container.ProtoReflect.Descriptor instead. func (*Service_Container) Descriptor() ([]byte, []int) { - return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{8, 0} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{10, 0} } func (x *Service_Container) GetMachineId() string { @@ -776,69 +897,91 @@ var file_internal_machine_api_pb_machine_proto_rawDesc = []byte{ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x07, 0x6d, 0x61, 0x63, 0x68, - 0x69, 0x6e, 0x65, 0x22, 0x79, 0x0a, 0x12, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x6d, 0x61, 0x63, - 0x68, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, + 0x69, 0x6e, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x12, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x07, 0x6d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x07, 0x6d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x37, 0x0a, 0x0e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, + 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x0d, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x12, + 0x2f, 0x0a, 0x14, 0x6d, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x64, 0x62, 0x5f, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x6d, + 0x69, 0x6e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x44, 0x62, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x22, 0x49, 0x0a, 0x16, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, + 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x6d, 0x61, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x73, 0x52, 0x08, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x22, 0x91, 0x01, 0x0a, 0x0e, + 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x29, + 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, + 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x07, 0x6d, 0x61, 0x63, + 0x68, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x07, 0x6d, 0x61, - 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x37, 0x0a, 0x0e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x6d, - 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, - 0x0d, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x73, 0x22, 0x25, - 0x0a, 0x0d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xc3, 0x01, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x36, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, - 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, - 0x73, 0x1a, 0x48, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x1d, - 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, - 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x22, 0x27, 0x0a, 0x15, 0x49, - 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x22, 0x40, 0x0a, 0x16, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, - 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x32, 0xc3, 0x03, 0x0a, 0x07, 0x4d, 0x61, 0x63, 0x68, 0x69, - 0x6e, 0x65, 0x12, 0x4d, 0x0a, 0x12, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x72, 0x65, - 0x71, 0x75, 0x69, 0x73, 0x69, 0x74, 0x65, 0x73, 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, 0x1f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x72, - 0x65, 0x71, 0x75, 0x69, 0x73, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x12, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x12, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 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, 0x12, 0x33, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 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, 0x12, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x49, 0x6e, 0x73, 0x70, - 0x65, 0x63, 0x74, 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, 0x10, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x32, 0x0a, - 0x05, 0x52, 0x65, 0x73, 0x65, 0x74, 0x12, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, - 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x63, 0x68, 0x69, 0x6e, 0x65, 0x12, 0x28, 0x0a, 0x10, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5f, 0x64, + 0x62, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x44, 0x62, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, + 0x25, 0x0a, 0x0d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xc3, 0x01, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x36, 0x0a, 0x0a, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, + 0x72, 0x73, 0x1a, 0x48, 0x0a, 0x09, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, + 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x12, 0x1c, + 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x22, 0x27, 0x0a, 0x15, + 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x40, 0x0a, 0x16, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x26, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x32, 0x8a, 0x04, 0x0a, 0x07, 0x4d, 0x61, 0x63, 0x68, + 0x69, 0x6e, 0x65, 0x12, 0x4d, 0x0a, 0x12, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x72, 0x65, 0x72, + 0x65, 0x71, 0x75, 0x69, 0x73, 0x69, 0x74, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x12, 0x49, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, - 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x37, 0x5a, 0x35, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x73, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x73, 0x6b, 0x69, 0x2f, 0x75, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x79, 0x1a, 0x1f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x72, 0x65, + 0x72, 0x65, 0x71, 0x75, 0x69, 0x73, 0x69, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x40, 0x0a, 0x0b, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x12, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x49, 0x6e, 0x69, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0b, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x12, 0x17, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4a, 0x6f, 0x69, 0x6e, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 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, 0x12, 0x33, 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 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, 0x12, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x49, 0x6e, 0x73, + 0x70, 0x65, 0x63, 0x74, 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, 0x10, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x45, + 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, + 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, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, + 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x52, 0x65, 0x73, 0x65, 0x74, 0x12, 0x11, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 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, 0x12, 0x49, 0x0a, 0x0e, 0x49, 0x6e, 0x73, + 0x70, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1a, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x49, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x49, 0x6e, + 0x73, 0x70, 0x65, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x70, 0x73, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x6b, 0x69, 0x2f, 0x75, 0x6e, + 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x6d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -853,7 +996,7 @@ func file_internal_machine_api_pb_machine_proto_rawDescGZIP() []byte { return file_internal_machine_api_pb_machine_proto_rawDescData } -var file_internal_machine_api_pb_machine_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_internal_machine_api_pb_machine_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_internal_machine_api_pb_machine_proto_goTypes = []any{ (*MachineInfo)(nil), // 0: api.MachineInfo (*NetworkConfig)(nil), // 1: api.NetworkConfig @@ -861,49 +1004,57 @@ var file_internal_machine_api_pb_machine_proto_goTypes = []any{ (*InitClusterRequest)(nil), // 3: api.InitClusterRequest (*InitClusterResponse)(nil), // 4: api.InitClusterResponse (*JoinClusterRequest)(nil), // 5: api.JoinClusterRequest - (*TokenResponse)(nil), // 6: api.TokenResponse - (*ResetRequest)(nil), // 7: api.ResetRequest - (*Service)(nil), // 8: api.Service - (*InspectServiceRequest)(nil), // 9: api.InspectServiceRequest - (*InspectServiceResponse)(nil), // 10: api.InspectServiceResponse - (*Service_Container)(nil), // 11: api.Service.Container - (*IP)(nil), // 12: api.IP - (*IPPrefix)(nil), // 13: api.IPPrefix - (*IPPort)(nil), // 14: api.IPPort - (*emptypb.Empty)(nil), // 15: google.protobuf.Empty + (*InspectMachineResponse)(nil), // 6: api.InspectMachineResponse + (*MachineDetails)(nil), // 7: api.MachineDetails + (*TokenResponse)(nil), // 8: api.TokenResponse + (*ResetRequest)(nil), // 9: api.ResetRequest + (*Service)(nil), // 10: api.Service + (*InspectServiceRequest)(nil), // 11: api.InspectServiceRequest + (*InspectServiceResponse)(nil), // 12: api.InspectServiceResponse + (*Service_Container)(nil), // 13: api.Service.Container + (*IP)(nil), // 14: api.IP + (*IPPrefix)(nil), // 15: api.IPPrefix + (*IPPort)(nil), // 16: api.IPPort + (*Metadata)(nil), // 17: api.Metadata + (*emptypb.Empty)(nil), // 18: google.protobuf.Empty } var file_internal_machine_api_pb_machine_proto_depIdxs = []int32{ 1, // 0: api.MachineInfo.network:type_name -> api.NetworkConfig - 12, // 1: api.MachineInfo.public_ip:type_name -> api.IP - 13, // 2: api.NetworkConfig.subnet:type_name -> api.IPPrefix - 12, // 3: api.NetworkConfig.management_ip:type_name -> api.IP - 14, // 4: api.NetworkConfig.endpoints:type_name -> api.IPPort - 13, // 5: api.InitClusterRequest.network:type_name -> api.IPPrefix - 12, // 6: api.InitClusterRequest.public_ip:type_name -> api.IP + 14, // 1: api.MachineInfo.public_ip:type_name -> api.IP + 15, // 2: api.NetworkConfig.subnet:type_name -> api.IPPrefix + 14, // 3: api.NetworkConfig.management_ip:type_name -> api.IP + 16, // 4: api.NetworkConfig.endpoints:type_name -> api.IPPort + 15, // 5: api.InitClusterRequest.network:type_name -> api.IPPrefix + 14, // 6: api.InitClusterRequest.public_ip:type_name -> api.IP 0, // 7: api.InitClusterResponse.machine:type_name -> api.MachineInfo 0, // 8: api.JoinClusterRequest.machine:type_name -> api.MachineInfo 0, // 9: api.JoinClusterRequest.other_machines:type_name -> api.MachineInfo - 11, // 10: api.Service.containers:type_name -> api.Service.Container - 8, // 11: api.InspectServiceResponse.service:type_name -> api.Service - 15, // 12: api.Machine.CheckPrerequisites:input_type -> google.protobuf.Empty - 3, // 13: api.Machine.InitCluster:input_type -> api.InitClusterRequest - 5, // 14: api.Machine.JoinCluster:input_type -> api.JoinClusterRequest - 15, // 15: api.Machine.Token:input_type -> google.protobuf.Empty - 15, // 16: api.Machine.Inspect:input_type -> google.protobuf.Empty - 7, // 17: api.Machine.Reset:input_type -> api.ResetRequest - 9, // 18: api.Machine.InspectService:input_type -> api.InspectServiceRequest - 2, // 19: api.Machine.CheckPrerequisites:output_type -> api.CheckPrerequisitesResponse - 4, // 20: api.Machine.InitCluster:output_type -> api.InitClusterResponse - 15, // 21: api.Machine.JoinCluster:output_type -> google.protobuf.Empty - 6, // 22: api.Machine.Token:output_type -> api.TokenResponse - 0, // 23: api.Machine.Inspect:output_type -> api.MachineInfo - 15, // 24: api.Machine.Reset:output_type -> google.protobuf.Empty - 10, // 25: api.Machine.InspectService:output_type -> api.InspectServiceResponse - 19, // [19:26] is the sub-list for method output_type - 12, // [12:19] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 7, // 10: api.InspectMachineResponse.machines:type_name -> api.MachineDetails + 17, // 11: api.MachineDetails.metadata:type_name -> api.Metadata + 0, // 12: api.MachineDetails.machine:type_name -> api.MachineInfo + 13, // 13: api.Service.containers:type_name -> api.Service.Container + 10, // 14: api.InspectServiceResponse.service:type_name -> api.Service + 18, // 15: api.Machine.CheckPrerequisites:input_type -> google.protobuf.Empty + 3, // 16: api.Machine.InitCluster:input_type -> api.InitClusterRequest + 5, // 17: api.Machine.JoinCluster:input_type -> api.JoinClusterRequest + 18, // 18: api.Machine.Token:input_type -> google.protobuf.Empty + 18, // 19: api.Machine.Inspect:input_type -> google.protobuf.Empty + 18, // 20: api.Machine.InspectMachine:input_type -> google.protobuf.Empty + 9, // 21: api.Machine.Reset:input_type -> api.ResetRequest + 11, // 22: api.Machine.InspectService:input_type -> api.InspectServiceRequest + 2, // 23: api.Machine.CheckPrerequisites:output_type -> api.CheckPrerequisitesResponse + 4, // 24: api.Machine.InitCluster:output_type -> api.InitClusterResponse + 18, // 25: api.Machine.JoinCluster:output_type -> google.protobuf.Empty + 8, // 26: api.Machine.Token:output_type -> api.TokenResponse + 0, // 27: api.Machine.Inspect:output_type -> api.MachineInfo + 6, // 28: api.Machine.InspectMachine:output_type -> api.InspectMachineResponse + 18, // 29: api.Machine.Reset:output_type -> google.protobuf.Empty + 12, // 30: api.Machine.InspectService:output_type -> api.InspectServiceResponse + 23, // [23:31] is the sub-list for method output_type + 15, // [15:23] is the sub-list for method input_type + 15, // [15:15] is the sub-list for extension type_name + 15, // [15:15] is the sub-list for extension extendee + 0, // [0:15] is the sub-list for field type_name } func init() { file_internal_machine_api_pb_machine_proto_init() } @@ -986,7 +1137,7 @@ func file_internal_machine_api_pb_machine_proto_init() { } } file_internal_machine_api_pb_machine_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*TokenResponse); i { + switch v := v.(*InspectMachineResponse); i { case 0: return &v.state case 1: @@ -998,7 +1149,7 @@ func file_internal_machine_api_pb_machine_proto_init() { } } file_internal_machine_api_pb_machine_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*ResetRequest); i { + switch v := v.(*MachineDetails); i { case 0: return &v.state case 1: @@ -1010,7 +1161,7 @@ func file_internal_machine_api_pb_machine_proto_init() { } } file_internal_machine_api_pb_machine_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*Service); i { + switch v := v.(*TokenResponse); i { case 0: return &v.state case 1: @@ -1022,7 +1173,7 @@ func file_internal_machine_api_pb_machine_proto_init() { } } file_internal_machine_api_pb_machine_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*InspectServiceRequest); i { + switch v := v.(*ResetRequest); i { case 0: return &v.state case 1: @@ -1034,7 +1185,7 @@ func file_internal_machine_api_pb_machine_proto_init() { } } file_internal_machine_api_pb_machine_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*InspectServiceResponse); i { + switch v := v.(*Service); i { case 0: return &v.state case 1: @@ -1046,6 +1197,30 @@ func file_internal_machine_api_pb_machine_proto_init() { } } file_internal_machine_api_pb_machine_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*InspectServiceRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_machine_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*InspectServiceResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_machine_api_pb_machine_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*Service_Container); i { case 0: return &v.state @@ -1068,7 +1243,7 @@ func file_internal_machine_api_pb_machine_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_internal_machine_api_pb_machine_proto_rawDesc, NumEnums: 0, - NumMessages: 12, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/machine/api/pb/machine.proto b/internal/machine/api/pb/machine.proto index bfa126f3..a9ab05f3 100644 --- a/internal/machine/api/pb/machine.proto +++ b/internal/machine/api/pb/machine.proto @@ -13,7 +13,10 @@ service Machine { rpc InitCluster(InitClusterRequest) returns (InitClusterResponse); rpc JoinCluster(JoinClusterRequest) returns (google.protobuf.Empty); rpc Token(google.protobuf.Empty) returns (TokenResponse); + // Deprecated: use InspectMachine instead. rpc Inspect(google.protobuf.Empty) returns (MachineInfo); + // InspectMachine retrieves detailed information about the machine. Supports broadcasting to multiple machines. + rpc InspectMachine(google.protobuf.Empty) returns (InspectMachineResponse); // Reset restores the machine to a clean state, removing all cluster-related configuration and data. rpc Reset(ResetRequest) returns (google.protobuf.Empty); @@ -58,6 +61,20 @@ message InitClusterResponse { message JoinClusterRequest { MachineInfo machine = 1; repeated MachineInfo other_machines = 3; + // Minimum store database version the new machine should sync to before starting cluster operations. + int64 min_store_db_version = 4; +} + +message InspectMachineResponse { + // Must contain only one repeated messages field to allow broadcasting InspectMachine requests to multiple machines. + repeated MachineDetails machines = 1; +} + +message MachineDetails { + Metadata metadata = 1; + MachineInfo machine = 2; + // Current Corrosion cr-sqlite database version (Lamport timestamp) of the cluster store. + int64 store_db_version = 3; } message TokenResponse { diff --git a/internal/machine/api/pb/machine_grpc.pb.go b/internal/machine/api/pb/machine_grpc.pb.go index 035883ed..eaefded3 100644 --- a/internal/machine/api/pb/machine_grpc.pb.go +++ b/internal/machine/api/pb/machine_grpc.pb.go @@ -25,6 +25,7 @@ const ( Machine_JoinCluster_FullMethodName = "/api.Machine/JoinCluster" Machine_Token_FullMethodName = "/api.Machine/Token" Machine_Inspect_FullMethodName = "/api.Machine/Inspect" + Machine_InspectMachine_FullMethodName = "/api.Machine/InspectMachine" Machine_Reset_FullMethodName = "/api.Machine/Reset" Machine_InspectService_FullMethodName = "/api.Machine/InspectService" ) @@ -38,7 +39,10 @@ type MachineClient interface { InitCluster(ctx context.Context, in *InitClusterRequest, opts ...grpc.CallOption) (*InitClusterResponse, error) JoinCluster(ctx context.Context, in *JoinClusterRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) Token(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*TokenResponse, error) + // Deprecated: use InspectMachine instead. Inspect(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*MachineInfo, error) + // InspectMachine retrieves detailed information about the machine. Supports broadcasting to multiple machines. + InspectMachine(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*InspectMachineResponse, error) // Reset restores the machine to a clean state, removing all cluster-related configuration and data. Reset(ctx context.Context, in *ResetRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) InspectService(ctx context.Context, in *InspectServiceRequest, opts ...grpc.CallOption) (*InspectServiceResponse, error) @@ -102,6 +106,16 @@ func (c *machineClient) Inspect(ctx context.Context, in *emptypb.Empty, opts ... return out, nil } +func (c *machineClient) InspectMachine(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*InspectMachineResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(InspectMachineResponse) + err := c.cc.Invoke(ctx, Machine_InspectMachine_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *machineClient) Reset(ctx context.Context, in *ResetRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) @@ -131,7 +145,10 @@ type MachineServer interface { InitCluster(context.Context, *InitClusterRequest) (*InitClusterResponse, error) JoinCluster(context.Context, *JoinClusterRequest) (*emptypb.Empty, error) Token(context.Context, *emptypb.Empty) (*TokenResponse, error) + // Deprecated: use InspectMachine instead. Inspect(context.Context, *emptypb.Empty) (*MachineInfo, error) + // InspectMachine retrieves detailed information about the machine. Supports broadcasting to multiple machines. + InspectMachine(context.Context, *emptypb.Empty) (*InspectMachineResponse, error) // Reset restores the machine to a clean state, removing all cluster-related configuration and data. Reset(context.Context, *ResetRequest) (*emptypb.Empty, error) InspectService(context.Context, *InspectServiceRequest) (*InspectServiceResponse, error) @@ -160,6 +177,9 @@ func (UnimplementedMachineServer) Token(context.Context, *emptypb.Empty) (*Token func (UnimplementedMachineServer) Inspect(context.Context, *emptypb.Empty) (*MachineInfo, error) { return nil, status.Errorf(codes.Unimplemented, "method Inspect not implemented") } +func (UnimplementedMachineServer) InspectMachine(context.Context, *emptypb.Empty) (*InspectMachineResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InspectMachine not implemented") +} func (UnimplementedMachineServer) Reset(context.Context, *ResetRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Reset not implemented") } @@ -277,6 +297,24 @@ func _Machine_Inspect_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Machine_InspectMachine_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(emptypb.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MachineServer).InspectMachine(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Machine_InspectMachine_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MachineServer).InspectMachine(ctx, req.(*emptypb.Empty)) + } + return interceptor(ctx, in, info, handler) +} + func _Machine_Reset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ResetRequest) if err := dec(in); err != nil { @@ -340,6 +378,10 @@ var Machine_ServiceDesc = grpc.ServiceDesc{ MethodName: "Inspect", Handler: _Machine_Inspect_Handler, }, + { + MethodName: "InspectMachine", + Handler: _Machine_InspectMachine_Handler, + }, { MethodName: "Reset", Handler: _Machine_Reset_Handler, diff --git a/internal/machine/machine.go b/internal/machine/machine.go index a2d1749b..568ad8a1 100644 --- a/internal/machine/machine.go +++ b/internal/machine/machine.go @@ -792,6 +792,7 @@ func (m *Machine) JoinCluster(_ context.Context, req *pb.JoinClusterRequest) (*e PrivateKey: m.state.Network.PrivateKey, PublicKey: m.state.Network.PublicKey, } + m.state.MinStoreDBVersion = req.MinStoreDbVersion // Build a peers config from other cluster machines. m.state.Network.Peers = make([]network.PeerConfig, 0, len(req.OtherMachines)) @@ -864,6 +865,7 @@ func (m *Machine) Token(_ context.Context, _ *emptypb.Empty) (*pb.TokenResponse, return &pb.TokenResponse{Token: tokenStr}, nil } +// Deprecated: use InspectMachine instead. func (m *Machine) Inspect(_ context.Context, _ *emptypb.Empty) (*pb.MachineInfo, error) { return &pb.MachineInfo{ Id: m.state.ID, @@ -876,6 +878,31 @@ func (m *Machine) Inspect(_ context.Context, _ *emptypb.Empty) (*pb.MachineInfo, }, nil } +func (m *Machine) InspectMachine(ctx context.Context, _ *emptypb.Empty) (*pb.InspectMachineResponse, error) { + dbVersion, err := m.store.DBVersion(ctx) + if err != nil { + return nil, status.Errorf(codes.Internal, "get database version of the cluster store: %v", err) + } + + return &pb.InspectMachineResponse{ + Machines: []*pb.MachineDetails{ + { + // Metadata is injected by the gRPC proxy. + Machine: &pb.MachineInfo{ + Id: m.state.ID, + Name: m.state.Name, + Network: &pb.NetworkConfig{ + Subnet: pb.NewIPPrefix(m.state.Network.Subnet), + ManagementIp: pb.NewIP(m.state.Network.ManagementIP), + PublicKey: m.state.Network.PublicKey, + }, + }, + StoreDbVersion: dbVersion, + }, + }, + }, nil +} + // IsNetworkReady returns true if the Docker network is ready for containers. func (m *Machine) IsNetworkReady() bool { if !m.Initialised() { diff --git a/internal/machine/state.go b/internal/machine/state.go index 3443e8a2..5a19e3ab 100644 --- a/internal/machine/state.go +++ b/internal/machine/state.go @@ -24,6 +24,9 @@ type State struct { Name string // Network specifies the network configuration for this machine. Network *network.Config + // MinStoreDBVersion is the latest database version of one of the existing cluster machines at the time this machine + // joined the cluster. The machine should sync to at least this version before starting any cluster operations. + MinStoreDBVersion int64 `json:",omitempty"` // path is the file path config is read from and saved to. path string diff --git a/internal/machine/store/store.go b/internal/machine/store/store.go index 10096681..12029694 100644 --- a/internal/machine/store/store.go +++ b/internal/machine/store/store.go @@ -56,6 +56,25 @@ func (s *Store) Delete(ctx context.Context, key string) error { return err } +// DBVersion returns the current cr-sqlite database version (Lamport timestamp). +func (s *Store) DBVersion(ctx context.Context) (int64, error) { + rows, err := s.corro.QueryContext(ctx, "SELECT crsql_db_version()") + if err != nil { + return 0, fmt.Errorf("query crsql_db_version(): %w", err) + } + defer rows.Close() + + if !rows.Next() { + return 0, fmt.Errorf("no result from crsql_db_version()") + } + + var version int64 + if err = rows.Scan(&version); err != nil { + return 0, fmt.Errorf("scan db version: %w", err) + } + return version, nil +} + func (s *Store) CreateMachine(ctx context.Context, m *pb.MachineInfo) error { mJSON, err := protojson.Marshal(m) if err != nil {