diff --git a/internal/machine/api/pb/machine.pb.go b/internal/machine/api/pb/machine.pb.go index ac589a74..4119dbca 100644 --- a/internal/machine/api/pb/machine.pb.go +++ b/internal/machine/api/pb/machine.pb.go @@ -466,6 +466,44 @@ func (x *TokenResponse) GetToken() string { return "" } +type ResetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ResetRequest) Reset() { + *x = ResetRequest{} + 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 *ResetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResetRequest) ProtoMessage() {} + +func (x *ResetRequest) 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 ResetRequest.ProtoReflect.Descriptor instead. +func (*ResetRequest) Descriptor() ([]byte, []int) { + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{7} +} + type Service struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -480,7 +518,7 @@ type Service struct { func (x *Service) Reset() { *x = Service{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[7] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -493,7 +531,7 @@ func (x *Service) String() string { func (*Service) ProtoMessage() {} func (x *Service) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[7] + 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 { @@ -506,7 +544,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{7} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{8} } func (x *Service) GetId() string { @@ -548,7 +586,7 @@ type InspectServiceRequest struct { func (x *InspectServiceRequest) Reset() { *x = InspectServiceRequest{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[8] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -561,7 +599,7 @@ func (x *InspectServiceRequest) String() string { func (*InspectServiceRequest) ProtoMessage() {} func (x *InspectServiceRequest) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[8] + 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 { @@ -574,7 +612,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{8} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{9} } func (x *InspectServiceRequest) GetId() string { @@ -595,7 +633,7 @@ type InspectServiceResponse struct { func (x *InspectServiceResponse) Reset() { *x = InspectServiceResponse{} if protoimpl.UnsafeEnabled { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[9] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -608,7 +646,7 @@ func (x *InspectServiceResponse) String() string { func (*InspectServiceResponse) ProtoMessage() {} func (x *InspectServiceResponse) ProtoReflect() protoreflect.Message { - mi := &file_internal_machine_api_pb_machine_proto_msgTypes[9] + 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 { @@ -621,7 +659,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{9} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{10} } func (x *InspectServiceResponse) GetService() *Service { @@ -644,7 +682,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[10] + mi := &file_internal_machine_api_pb_machine_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -657,7 +695,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[10] + 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 { @@ -670,7 +708,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{7, 0} + return file_internal_machine_api_pb_machine_proto_rawDescGZIP(), []int{8, 0} } func (x *Service_Container) GetMachineId() string { @@ -748,7 +786,8 @@ var file_internal_machine_api_pb_machine_proto_rawDesc = []byte{ 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, 0xc3, 0x01, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 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, @@ -767,7 +806,7 @@ var file_internal_machine_api_pb_machine_proto_rawDesc = []byte{ 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, 0x8f, 0x03, 0x0a, 0x07, 0x4d, 0x61, 0x63, 0x68, 0x69, + 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, @@ -787,16 +826,19 @@ var file_internal_machine_api_pb_machine_proto_rawDesc = []byte{ 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, 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, + 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, + 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 ( @@ -811,7 +853,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, 11) +var file_internal_machine_api_pb_machine_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_internal_machine_api_pb_machine_proto_goTypes = []any{ (*MachineInfo)(nil), // 0: api.MachineInfo (*NetworkConfig)(nil), // 1: api.NetworkConfig @@ -820,42 +862,45 @@ var file_internal_machine_api_pb_machine_proto_goTypes = []any{ (*InitClusterResponse)(nil), // 4: api.InitClusterResponse (*JoinClusterRequest)(nil), // 5: api.JoinClusterRequest (*TokenResponse)(nil), // 6: api.TokenResponse - (*Service)(nil), // 7: api.Service - (*InspectServiceRequest)(nil), // 8: api.InspectServiceRequest - (*InspectServiceResponse)(nil), // 9: api.InspectServiceResponse - (*Service_Container)(nil), // 10: api.Service.Container - (*IP)(nil), // 11: api.IP - (*IPPrefix)(nil), // 12: api.IPPrefix - (*IPPort)(nil), // 13: api.IPPort - (*emptypb.Empty)(nil), // 14: google.protobuf.Empty + (*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 } var file_internal_machine_api_pb_machine_proto_depIdxs = []int32{ 1, // 0: api.MachineInfo.network:type_name -> api.NetworkConfig - 11, // 1: api.MachineInfo.public_ip:type_name -> api.IP - 12, // 2: api.NetworkConfig.subnet:type_name -> api.IPPrefix - 11, // 3: api.NetworkConfig.management_ip:type_name -> api.IP - 13, // 4: api.NetworkConfig.endpoints:type_name -> api.IPPort - 12, // 5: api.InitClusterRequest.network:type_name -> api.IPPrefix - 11, // 6: api.InitClusterRequest.public_ip:type_name -> api.IP + 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 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 - 10, // 10: api.Service.containers:type_name -> api.Service.Container - 7, // 11: api.InspectServiceResponse.service:type_name -> api.Service - 14, // 12: api.Machine.CheckPrerequisites:input_type -> google.protobuf.Empty + 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 - 14, // 15: api.Machine.Token:input_type -> google.protobuf.Empty - 14, // 16: api.Machine.Inspect:input_type -> google.protobuf.Empty - 8, // 17: api.Machine.InspectService:input_type -> api.InspectServiceRequest - 2, // 18: api.Machine.CheckPrerequisites:output_type -> api.CheckPrerequisitesResponse - 4, // 19: api.Machine.InitCluster:output_type -> api.InitClusterResponse - 14, // 20: api.Machine.JoinCluster:output_type -> google.protobuf.Empty - 6, // 21: api.Machine.Token:output_type -> api.TokenResponse - 0, // 22: api.Machine.Inspect:output_type -> api.MachineInfo - 9, // 23: api.Machine.InspectService:output_type -> api.InspectServiceResponse - 18, // [18:24] is the sub-list for method output_type - 12, // [12:18] is the sub-list for method input_type + 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 @@ -953,7 +998,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.(*Service); i { + switch v := v.(*ResetRequest); i { case 0: return &v.state case 1: @@ -965,7 +1010,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.(*InspectServiceRequest); i { + switch v := v.(*Service); i { case 0: return &v.state case 1: @@ -977,7 +1022,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.(*InspectServiceResponse); i { + switch v := v.(*InspectServiceRequest); i { case 0: return &v.state case 1: @@ -989,6 +1034,18 @@ 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 { + 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[11].Exporter = func(v any, i int) any { switch v := v.(*Service_Container); i { case 0: return &v.state @@ -1011,7 +1068,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: 11, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/machine/api/pb/machine.proto b/internal/machine/api/pb/machine.proto index ec81c5d4..87188390 100644 --- a/internal/machine/api/pb/machine.proto +++ b/internal/machine/api/pb/machine.proto @@ -14,6 +14,9 @@ service Machine { rpc JoinCluster(JoinClusterRequest) returns (google.protobuf.Empty); rpc Token(google.protobuf.Empty) returns (TokenResponse); rpc Inspect(google.protobuf.Empty) returns (MachineInfo); + // Reset restores the machine to a clean state, removing all cluster-related сonfiguration and data. + rpc Reset(ResetRequest) returns (google.protobuf.Empty); + rpc InspectService(InspectServiceRequest) returns (InspectServiceResponse); } @@ -61,6 +64,9 @@ message TokenResponse { string token = 1; } +message ResetRequest { +} + message Service { string id = 1; string name = 2; diff --git a/internal/machine/api/pb/machine_grpc.pb.go b/internal/machine/api/pb/machine_grpc.pb.go index eccd76a6..a53be439 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_Reset_FullMethodName = "/api.Machine/Reset" Machine_InspectService_FullMethodName = "/api.Machine/InspectService" ) @@ -38,6 +39,8 @@ type MachineClient interface { JoinCluster(ctx context.Context, in *JoinClusterRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) Token(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*TokenResponse, error) Inspect(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*MachineInfo, error) + // Reset restores the machine to a clean state, removing all cluster-related сonfiguration 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) } @@ -99,6 +102,16 @@ func (c *machineClient) Inspect(ctx context.Context, in *emptypb.Empty, opts ... 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) + err := c.cc.Invoke(ctx, Machine_Reset_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *machineClient) InspectService(ctx context.Context, in *InspectServiceRequest, opts ...grpc.CallOption) (*InspectServiceResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(InspectServiceResponse) @@ -119,6 +132,8 @@ type MachineServer interface { JoinCluster(context.Context, *JoinClusterRequest) (*emptypb.Empty, error) Token(context.Context, *emptypb.Empty) (*TokenResponse, error) Inspect(context.Context, *emptypb.Empty) (*MachineInfo, error) + // Reset restores the machine to a clean state, removing all cluster-related сonfiguration and data. + Reset(context.Context, *ResetRequest) (*emptypb.Empty, error) InspectService(context.Context, *InspectServiceRequest) (*InspectServiceResponse, error) mustEmbedUnimplementedMachineServer() } @@ -145,6 +160,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) Reset(context.Context, *ResetRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Reset not implemented") +} func (UnimplementedMachineServer) InspectService(context.Context, *InspectServiceRequest) (*InspectServiceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method InspectService not implemented") } @@ -259,6 +277,24 @@ func _Machine_Inspect_Handler(srv interface{}, ctx context.Context, dec func(int 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 { + return nil, err + } + if interceptor == nil { + return srv.(MachineServer).Reset(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Machine_Reset_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MachineServer).Reset(ctx, req.(*ResetRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Machine_InspectService_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(InspectServiceRequest) if err := dec(in); err != nil { @@ -304,6 +340,10 @@ var Machine_ServiceDesc = grpc.ServiceDesc{ MethodName: "Inspect", Handler: _Machine_Inspect_Handler, }, + { + MethodName: "Reset", + Handler: _Machine_Reset_Handler, + }, { MethodName: "InspectService", Handler: _Machine_InspectService_Handler, diff --git a/internal/machine/machine.go b/internal/machine/machine.go index 07fd5bca..27b6c643 100644 --- a/internal/machine/machine.go +++ b/internal/machine/machine.go @@ -776,6 +776,22 @@ func (m *Machine) Inspect(_ context.Context, _ *emptypb.Empty) (*pb.MachineInfo, }, nil } +// Reset restores the machine to a clean state, removing all cluster-related сonfiguration and data and scheduling +// a graceful shutdown. The uncloud daemon will restart the machine if managed by systemd. +func (m *Machine) Reset(ctx context.Context, _ *pb.ResetRequest) (*emptypb.Empty, error) { + slog.Info("Resetting machine to a clean state.") + + // TODO: stop and remove all managed service containers. + // TODO: check if the request is coming from the unix or network socket. For the network socket, the reset should + // be called in a separate goroutine to avoid blocking the RPC response. + // TODO: stop the network controller + // TODO: implement and call Cleanup on the network controller to remove Docker network, WG interface, iptables + // rules, corrosion state, ?stop corrosion service. + // TODO: stop the machine and remove the machine.json state. The daemon should restart it to a clean state. + + return &emptypb.Empty{}, status.Error(codes.Unimplemented, "reset machine is not implemented yet") +} + // InspectService returns detailed information about a service and its containers stored in the cluster store. func (m *Machine) InspectService( ctx context.Context, req *pb.InspectServiceRequest,