From a6b7e5546ab20561f1d86af4d68d223cc2ca779a Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Thu, 4 Jan 2024 10:34:20 +0530 Subject: [PATCH 1/9] add rpc call for peerBlockPool Signed-off-by: Rewant Soni --- services/provider/pb/provider.pb.go | 267 +++++++++++++++++------ services/provider/pb/provider_grpc.pb.go | 38 ++++ services/provider/proto/provider.proto | 14 ++ 3 files changed, 258 insertions(+), 61 deletions(-) diff --git a/services/provider/pb/provider.pb.go b/services/provider/pb/provider.pb.go index fb5118b5fb..9fc810868f 100644 --- a/services/provider/pb/provider.pb.go +++ b/services/provider/pb/provider.pb.go @@ -994,6 +994,110 @@ func (x *ReportStatusResponse) GetDesiredClientOperatorChannel() string { return "" } +type PeerBlockPoolRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // secretName is the name of the bootstrap secret + SecretName string `protobuf:"bytes,1,opt,name=secretName,proto3" json:"secretName,omitempty"` + // pool base64 encoded name of the block pool + Pool []byte `protobuf:"bytes,2,opt,name=pool,proto3" json:"pool,omitempty"` + // token is secret information from bootstrap secret + Token []byte `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` +} + +func (x *PeerBlockPoolRequest) Reset() { + *x = PeerBlockPoolRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_provider_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeerBlockPoolRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeerBlockPoolRequest) ProtoMessage() {} + +func (x *PeerBlockPoolRequest) ProtoReflect() protoreflect.Message { + mi := &file_provider_proto_msgTypes[17] + 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 PeerBlockPoolRequest.ProtoReflect.Descriptor instead. +func (*PeerBlockPoolRequest) Descriptor() ([]byte, []int) { + return file_provider_proto_rawDescGZIP(), []int{17} +} + +func (x *PeerBlockPoolRequest) GetSecretName() string { + if x != nil { + return x.SecretName + } + return "" +} + +func (x *PeerBlockPoolRequest) GetPool() []byte { + if x != nil { + return x.Pool + } + return nil +} + +func (x *PeerBlockPoolRequest) GetToken() []byte { + if x != nil { + return x.Token + } + return nil +} + +type PeerBlockPoolResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PeerBlockPoolResponse) Reset() { + *x = PeerBlockPoolResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_provider_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PeerBlockPoolResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PeerBlockPoolResponse) ProtoMessage() {} + +func (x *PeerBlockPoolResponse) ProtoReflect() protoreflect.Message { + mi := &file_provider_proto_msgTypes[18] + 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 PeerBlockPoolResponse.ProtoReflect.Descriptor instead. +func (*PeerBlockPoolResponse) Descriptor() ([]byte, []int) { + return file_provider_proto_rawDescGZIP(), []int{18} +} + var File_provider_proto protoreflect.FileDescriptor var file_provider_proto_rawDesc = []byte{ @@ -1114,57 +1218,70 @@ var file_provider_proto_rawDesc = []byte{ 0x65, 0x64, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1c, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x65, 0x72, - 0x61, 0x74, 0x6f, 0x72, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x32, 0x87, 0x06, 0x0a, 0x0b, - 0x4f, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0f, 0x4f, - 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x12, 0x20, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, - 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, - 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x6f, 0x72, - 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x10, - 0x4f, 0x66, 0x66, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, - 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x66, 0x66, 0x62, - 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, - 0x66, 0x66, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x41, 0x63, 0x6b, - 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, - 0x6e, 0x67, 0x12, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x41, 0x63, - 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, - 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, 0x13, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, - 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x24, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, 0x53, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x46, 0x75, - 0x6c, 0x66, 0x69, 0x6c, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, - 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x61, 0x0a, 0x12, 0x52, - 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, - 0x6d, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x76, + 0x61, 0x74, 0x6f, 0x72, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x22, 0x60, 0x0a, 0x14, 0x50, + 0x65, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x17, 0x0a, + 0x15, 0x50, 0x65, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xdb, 0x06, 0x0a, 0x0b, 0x4f, 0x43, 0x53, 0x50, 0x72, + 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0f, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, + 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, + 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, + 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x55, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, + 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, + 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x10, 0x4f, 0x66, 0x66, 0x62, 0x6f, + 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x12, 0x21, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x66, 0x66, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, + 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x66, 0x66, 0x62, 0x6f, 0x61, + 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, + 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x26, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, + 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x2e, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, + 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x64, 0x0a, 0x13, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, + 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x72, 0x2e, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, + 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x61, 0x0a, 0x12, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, + 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x23, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, - 0x72, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, - 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, - 0x0a, 0x15, 0x47, 0x65, 0x74, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, - 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, 0x15, 0x47, 0x65, 0x74, + 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, - 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, - 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, - 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x4f, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x52, 0x0a, 0x0d, 0x50, 0x65, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, + 0x6c, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x65, 0x65, + 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x65, 0x65, + 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1180,7 +1297,7 @@ func file_provider_proto_rawDescGZIP() []byte { } var file_provider_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_provider_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_provider_proto_msgTypes = make([]protoimpl.MessageInfo, 19) var file_provider_proto_goTypes = []interface{}{ (FulfillStorageClaimRequest_StorageType)(0), // 0: provider.FulfillStorageClaimRequest.StorageType (*OnboardConsumerRequest)(nil), // 1: provider.OnboardConsumerRequest @@ -1200,6 +1317,8 @@ var file_provider_proto_goTypes = []interface{}{ (*StorageClaimConfigResponse)(nil), // 15: provider.StorageClaimConfigResponse (*ReportStatusRequest)(nil), // 16: provider.ReportStatusRequest (*ReportStatusResponse)(nil), // 17: provider.ReportStatusResponse + (*PeerBlockPoolRequest)(nil), // 18: provider.PeerBlockPoolRequest + (*PeerBlockPoolResponse)(nil), // 19: provider.PeerBlockPoolResponse } var file_provider_proto_depIdxs = []int32{ 4, // 0: provider.StorageConfigResponse.externalResource:type_name -> provider.ExternalResource @@ -1213,16 +1332,18 @@ var file_provider_proto_depIdxs = []int32{ 12, // 8: provider.OCSProvider.RevokeStorageClaim:input_type -> provider.RevokeStorageClaimRequest 14, // 9: provider.OCSProvider.GetStorageClaimConfig:input_type -> provider.StorageClaimConfigRequest 16, // 10: provider.OCSProvider.ReportStatus:input_type -> provider.ReportStatusRequest - 2, // 11: provider.OCSProvider.OnboardConsumer:output_type -> provider.OnboardConsumerResponse - 5, // 12: provider.OCSProvider.GetStorageConfig:output_type -> provider.StorageConfigResponse - 7, // 13: provider.OCSProvider.OffboardConsumer:output_type -> provider.OffboardConsumerResponse - 9, // 14: provider.OCSProvider.AcknowledgeOnboarding:output_type -> provider.AcknowledgeOnboardingResponse - 11, // 15: provider.OCSProvider.FulfillStorageClaim:output_type -> provider.FulfillStorageClaimResponse - 13, // 16: provider.OCSProvider.RevokeStorageClaim:output_type -> provider.RevokeStorageClaimResponse - 15, // 17: provider.OCSProvider.GetStorageClaimConfig:output_type -> provider.StorageClaimConfigResponse - 17, // 18: provider.OCSProvider.ReportStatus:output_type -> provider.ReportStatusResponse - 11, // [11:19] is the sub-list for method output_type - 3, // [3:11] is the sub-list for method input_type + 18, // 11: provider.OCSProvider.PeerBlockPool:input_type -> provider.PeerBlockPoolRequest + 2, // 12: provider.OCSProvider.OnboardConsumer:output_type -> provider.OnboardConsumerResponse + 5, // 13: provider.OCSProvider.GetStorageConfig:output_type -> provider.StorageConfigResponse + 7, // 14: provider.OCSProvider.OffboardConsumer:output_type -> provider.OffboardConsumerResponse + 9, // 15: provider.OCSProvider.AcknowledgeOnboarding:output_type -> provider.AcknowledgeOnboardingResponse + 11, // 16: provider.OCSProvider.FulfillStorageClaim:output_type -> provider.FulfillStorageClaimResponse + 13, // 17: provider.OCSProvider.RevokeStorageClaim:output_type -> provider.RevokeStorageClaimResponse + 15, // 18: provider.OCSProvider.GetStorageClaimConfig:output_type -> provider.StorageClaimConfigResponse + 17, // 19: provider.OCSProvider.ReportStatus:output_type -> provider.ReportStatusResponse + 19, // 20: provider.OCSProvider.PeerBlockPool:output_type -> provider.PeerBlockPoolResponse + 12, // [12:21] is the sub-list for method output_type + 3, // [3:12] 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 @@ -1438,6 +1559,30 @@ func file_provider_proto_init() { return nil } } + file_provider_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeerBlockPoolRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_provider_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PeerBlockPoolResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1445,7 +1590,7 @@ func file_provider_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_provider_proto_rawDesc, NumEnums: 1, - NumMessages: 17, + NumMessages: 19, NumExtensions: 0, NumServices: 1, }, diff --git a/services/provider/pb/provider_grpc.pb.go b/services/provider/pb/provider_grpc.pb.go index 64c45e2b32..f1bf52fd9f 100644 --- a/services/provider/pb/provider_grpc.pb.go +++ b/services/provider/pb/provider_grpc.pb.go @@ -37,6 +37,8 @@ type OCSProviderClient interface { // specific resources. GetStorageClaimConfig(ctx context.Context, in *StorageClaimConfigRequest, opts ...grpc.CallOption) (*StorageClaimConfigResponse, error) ReportStatus(ctx context.Context, in *ReportStatusRequest, opts ...grpc.CallOption) (*ReportStatusResponse, error) + // PeerBlockPool RPC call to send the bootstrap secret for the pool + PeerBlockPool(ctx context.Context, in *PeerBlockPoolRequest, opts ...grpc.CallOption) (*PeerBlockPoolResponse, error) } type oCSProviderClient struct { @@ -119,6 +121,15 @@ func (c *oCSProviderClient) ReportStatus(ctx context.Context, in *ReportStatusRe return out, nil } +func (c *oCSProviderClient) PeerBlockPool(ctx context.Context, in *PeerBlockPoolRequest, opts ...grpc.CallOption) (*PeerBlockPoolResponse, error) { + out := new(PeerBlockPoolResponse) + err := c.cc.Invoke(ctx, "/provider.OCSProvider/PeerBlockPool", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // OCSProviderServer is the server API for OCSProvider service. // All implementations must embed UnimplementedOCSProviderServer // for forward compatibility @@ -142,6 +153,8 @@ type OCSProviderServer interface { // specific resources. GetStorageClaimConfig(context.Context, *StorageClaimConfigRequest) (*StorageClaimConfigResponse, error) ReportStatus(context.Context, *ReportStatusRequest) (*ReportStatusResponse, error) + // PeerBlockPool RPC call to send the bootstrap secret for the pool + PeerBlockPool(context.Context, *PeerBlockPoolRequest) (*PeerBlockPoolResponse, error) mustEmbedUnimplementedOCSProviderServer() } @@ -173,6 +186,9 @@ func (UnimplementedOCSProviderServer) GetStorageClaimConfig(context.Context, *St func (UnimplementedOCSProviderServer) ReportStatus(context.Context, *ReportStatusRequest) (*ReportStatusResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ReportStatus not implemented") } +func (UnimplementedOCSProviderServer) PeerBlockPool(context.Context, *PeerBlockPoolRequest) (*PeerBlockPoolResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PeerBlockPool not implemented") +} func (UnimplementedOCSProviderServer) mustEmbedUnimplementedOCSProviderServer() {} // UnsafeOCSProviderServer may be embedded to opt out of forward compatibility for this service. @@ -330,6 +346,24 @@ func _OCSProvider_ReportStatus_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _OCSProvider_PeerBlockPool_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PeerBlockPoolRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OCSProviderServer).PeerBlockPool(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provider.OCSProvider/PeerBlockPool", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OCSProviderServer).PeerBlockPool(ctx, req.(*PeerBlockPoolRequest)) + } + return interceptor(ctx, in, info, handler) +} + // OCSProvider_ServiceDesc is the grpc.ServiceDesc for OCSProvider service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -369,6 +403,10 @@ var OCSProvider_ServiceDesc = grpc.ServiceDesc{ MethodName: "ReportStatus", Handler: _OCSProvider_ReportStatus_Handler, }, + { + MethodName: "PeerBlockPool", + Handler: _OCSProvider_PeerBlockPool_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "provider.proto", diff --git a/services/provider/proto/provider.proto b/services/provider/proto/provider.proto index 2db2913b68..24c41cf25e 100644 --- a/services/provider/proto/provider.proto +++ b/services/provider/proto/provider.proto @@ -38,6 +38,9 @@ service OCSProvider { rpc ReportStatus(ReportStatusRequest) returns (ReportStatusResponse){} + // PeerBlockPool RPC call to send the bootstrap secret for the pool + rpc PeerBlockPool(PeerBlockPoolRequest) + returns (PeerBlockPoolResponse){} } // OnboardConsumerRequest holds the required information to validate the consumer and create StorageConsumer @@ -172,3 +175,14 @@ message ReportStatusResponse{ // Contains subscription channel of provider operator for client operator to match string desiredClientOperatorChannel = 1; } + +message PeerBlockPoolRequest{ + // secretName is the name of the bootstrap secret + string secretName = 1; + // pool base64 encoded name of the block pool + bytes pool = 2; + // token is secret information from bootstrap secret + bytes token = 3; +} + +message PeerBlockPoolResponse{} From 5634a8fc1abacc0c58432732c1d7e47d76d644fb Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 23 Jan 2024 13:48:45 +0530 Subject: [PATCH 2/9] add client implementation for the peerblockpool rpc call Signed-off-by: Rewant Soni --- services/provider/client/client.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/services/provider/client/client.go b/services/provider/client/client.go index c9093c4236..214522eba8 100644 --- a/services/provider/client/client.go +++ b/services/provider/client/client.go @@ -207,3 +207,20 @@ func (cc *OCSProviderClient) ReportStatus(ctx context.Context, consumerUUID stri return cc.Client.ReportStatus(apiCtx, req) } + +func (cc *OCSProviderClient) PeerBlockPool(ctx context.Context, secretName string, pool, token []byte) (*pb.PeerBlockPoolResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.PeerBlockPoolRequest{ + SecretName: secretName, + Pool: pool, + Token: token, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.PeerBlockPool(apiCtx, req) +} From a5e4604678c82cd63ed530b7524f73dee5d1aa2e Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Mon, 26 Feb 2024 18:37:06 +0530 Subject: [PATCH 3/9] add server implementation for peerblockpool rpc call Signed-off-by: Rewant Soni --- .../ocs-operator/manifests/provider-role.yaml | 29 ++++++- rbac/provider-role.yaml | 29 ++++++- services/provider/server/cephblockpool.go | 81 +++++++++++++++++++ services/provider/server/cephrbdmirror.go | 43 ++++++++++ services/provider/server/server.go | 46 +++++++++++ 5 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 services/provider/server/cephblockpool.go create mode 100644 services/provider/server/cephrbdmirror.go diff --git a/deploy/ocs-operator/manifests/provider-role.yaml b/deploy/ocs-operator/manifests/provider-role.yaml index bd708fc6fe..299f6cbf3e 100644 --- a/deploy/ocs-operator/manifests/provider-role.yaml +++ b/deploy/ocs-operator/manifests/provider-role.yaml @@ -7,10 +7,23 @@ rules: - "" resources: - configmaps - - secrets - services verbs: - get +- apiGroups: + - "" + resources: + - secrets + verbs: + - get + - create + - update +- apiGroups: + - ceph.rook.io + resources: + - cephblockpools/finalizers + verbs: + - update - apiGroups: - ceph.rook.io resources: @@ -19,6 +32,13 @@ rules: verbs: - get - list +- apiGroups: + - ceph.rook.io + resources: + - cephblockpools + verbs: + - get + - update - apiGroups: - ocs.openshift.io resources: @@ -61,3 +81,10 @@ rules: verbs: - get - list +- apiGroups: + - ceph.rook.io + resources: + - cephrbdmirrors + verbs: + - get + - create diff --git a/rbac/provider-role.yaml b/rbac/provider-role.yaml index bd708fc6fe..299f6cbf3e 100644 --- a/rbac/provider-role.yaml +++ b/rbac/provider-role.yaml @@ -7,10 +7,23 @@ rules: - "" resources: - configmaps - - secrets - services verbs: - get +- apiGroups: + - "" + resources: + - secrets + verbs: + - get + - create + - update +- apiGroups: + - ceph.rook.io + resources: + - cephblockpools/finalizers + verbs: + - update - apiGroups: - ceph.rook.io resources: @@ -19,6 +32,13 @@ rules: verbs: - get - list +- apiGroups: + - ceph.rook.io + resources: + - cephblockpools + verbs: + - get + - update - apiGroups: - ocs.openshift.io resources: @@ -61,3 +81,10 @@ rules: verbs: - get - list +- apiGroups: + - ceph.rook.io + resources: + - cephrbdmirrors + verbs: + - get + - create diff --git a/services/provider/server/cephblockpool.go b/services/provider/server/cephblockpool.go new file mode 100644 index 0000000000..3360076df0 --- /dev/null +++ b/services/provider/server/cephblockpool.go @@ -0,0 +1,81 @@ +package server + +import ( + "context" + "fmt" + "slices" + + rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" + corev1 "k8s.io/api/core/v1" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +type cephBlockPoolManager struct { + client client.Client + namespace string +} + +func newCephBlockPoolManager(cl client.Client, namespace string) (*cephBlockPoolManager, error) { + return &cephBlockPoolManager{ + client: cl, + namespace: namespace, + }, nil +} + +func (c *cephBlockPoolManager) EnableBlockPoolMirroring(ctx context.Context, cephBlockPool *rookCephv1.CephBlockPool) error { + + cephBlockPool.Spec.Mirroring.Enabled = true + cephBlockPool.Spec.Mirroring.Mode = "image" + + err := c.client.Update(ctx, cephBlockPool) + if err != nil { + return fmt.Errorf("failed to enable mirroring on CephBlockPool resource with name %q: %v", cephBlockPool.Name, err) + } + + return nil + +} + +func (c *cephBlockPoolManager) SetBootstrapSecretRef(ctx context.Context, cephBlockPool *rookCephv1.CephBlockPool, secretName string, secretData map[string][]byte) error { + + // create the secret + bootstrapSecret := &corev1.Secret{} + bootstrapSecret.Name = secretName + bootstrapSecret.Namespace = c.namespace + + _, err := ctrl.CreateOrUpdate(ctx, c.client, bootstrapSecret, func() error { + bootstrapSecret.Data = secretData + return ctrl.SetControllerReference(cephBlockPool, bootstrapSecret, c.client.Scheme()) + }) + if err != nil { + return fmt.Errorf("failed to create/update the bootstrap secret %q: %v", secretName, err) + } + + // set the secret ref + if cephBlockPool.Spec.Mirroring.Peers == nil { + cephBlockPool.Spec.Mirroring.Peers = &rookCephv1.MirroringPeerSpec{SecretNames: []string{secretName}} + } else { + if !slices.Contains(cephBlockPool.Spec.Mirroring.Peers.SecretNames, secretName) { + cephBlockPool.Spec.Mirroring.Peers.SecretNames = append(cephBlockPool.Spec.Mirroring.Peers.SecretNames, secretName) + } + } + + err = c.client.Update(ctx, cephBlockPool) + if err != nil { + return fmt.Errorf("failed to set bootstrap secret ref on CephBlockPool resource with name %q: %v", cephBlockPool.Name, err) + } + + return nil +} + +func (c *cephBlockPoolManager) GetBlockPoolByName(ctx context.Context, blockPoolName string) (*rookCephv1.CephBlockPool, error) { + blockPool := &rookCephv1.CephBlockPool{} + blockPool.Name = blockPoolName + blockPool.Namespace = c.namespace + err := c.client.Get(ctx, client.ObjectKeyFromObject(blockPool), blockPool) + if err != nil { + return nil, fmt.Errorf("failed to get CephBlockPool resource with name %q: %v", blockPoolName, err) + } + return blockPool, nil +} diff --git a/services/provider/server/cephrbdmirror.go b/services/provider/server/cephrbdmirror.go new file mode 100644 index 0000000000..ebafc0becd --- /dev/null +++ b/services/provider/server/cephrbdmirror.go @@ -0,0 +1,43 @@ +package server + +import ( + "context" + + rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" + kerrors "k8s.io/apimachinery/pkg/api/errors" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const rBDMirrorName = "rbd-mirror" + +type cephRBDMirrorManager struct { + client client.Client + namespace string +} + +func newCephRBDMirrorManager(cl client.Client, namespace string) (*cephRBDMirrorManager, error) { + return &cephRBDMirrorManager{ + client: cl, + namespace: namespace, + }, nil +} + +func (c *cephRBDMirrorManager) Create(ctx context.Context) error { + + cephRBDMirror := &rookCephv1.CephRBDMirror{} + cephRBDMirror.Name = rBDMirrorName + cephRBDMirror.Namespace = c.namespace + err := c.client.Get(ctx, client.ObjectKeyFromObject(cephRBDMirror), cephRBDMirror) + + // create if not found + if err != nil && kerrors.IsNotFound(err) { + cephRBDMirror.Spec = rookCephv1.RBDMirroringSpec{Count: 1} + err = c.client.Create(ctx, cephRBDMirror) + if err != nil { + return err + } + } + + // if any other err/nil return it + return err +} diff --git a/services/provider/server/server.go b/services/provider/server/server.go index b7e981824b..f8756de104 100644 --- a/services/provider/server/server.go +++ b/services/provider/server/server.go @@ -60,6 +60,8 @@ type OCSProviderServer struct { client client.Client consumerManager *ocsConsumerManager storageRequestManager *storageRequestManager + cephBlockPoolManager *cephBlockPoolManager + cephRBDMirrorManager *cephRBDMirrorManager namespace string } @@ -79,10 +81,23 @@ func NewOCSProviderServer(ctx context.Context, namespace string) (*OCSProviderSe return nil, fmt.Errorf("failed to create new StorageRequest instance. %v", err) } + cephBlockPoolManager, err := newCephBlockPoolManager(client, namespace) + if err != nil { + return nil, fmt.Errorf("failed to create new CephBlockPool instance. %v", err) + } + + cephRBDMirrorManager, err := newCephRBDMirrorManager(client, namespace) + if err != nil { + return nil, fmt.Errorf("failed to create new CephRBDMirror instance. %v", err) + + } + return &OCSProviderServer{ client: client, consumerManager: consumerManager, storageRequestManager: storageRequestManager, + cephBlockPoolManager: cephBlockPoolManager, + cephRBDMirrorManager: cephRBDMirrorManager, namespace: namespace, }, nil } @@ -722,3 +737,34 @@ func (s *OCSProviderServer) getOCSSubscriptionChannel(ctx context.Context) (stri } return subscription.Spec.Channel, nil } + +// PeerBlockPool RPC call to send the bootstrap secret for the pool +func (s *OCSProviderServer) PeerBlockPool(ctx context.Context, req *pb.PeerBlockPoolRequest) (*pb.PeerBlockPoolResponse, error) { + + cephBlockPool, err := s.cephBlockPoolManager.GetBlockPoolByName(ctx, string(req.Pool)) + if err != nil { + return nil, status.Errorf(codes.NotFound, "Failed to find CephBlockPool resource %s: %v", req.Pool, err) + } + + if err := s.cephRBDMirrorManager.Create(ctx); err != nil { + return nil, status.Errorf(codes.Internal, "Failed to create RBDMirror instance: %v", err) + } + + // enable mirroring on blockPool in the req + if err := s.cephBlockPoolManager.EnableBlockPoolMirroring(ctx, cephBlockPool); err != nil { + return nil, status.Errorf(codes.Internal, "Failed to enable mirroring for CephBlockPool resource %s: %v", req.Pool, err) + } + + // create and set secret ref on the blockPool + if err := s.cephBlockPoolManager.SetBootstrapSecretRef( + ctx, + cephBlockPool, + req.SecretName, + map[string][]byte{ + "pool": req.Pool, + "token": req.Token, + }); err != nil { + return nil, status.Errorf(codes.Internal, "Failed to set bootstrap secret ref for CephBlockPool resource %s: %v", req.Pool, err) + } + return &pb.PeerBlockPoolResponse{}, nil +} From 3d913dd1aa29097ac9cbf89fbb17206c66997276 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 5 Mar 2024 12:59:05 +0530 Subject: [PATCH 4/9] add rpc call for revokeBlockPoolPeering Signed-off-by: Rewant Soni --- services/provider/pb/provider.pb.go | 276 +++++++++++++++++------ services/provider/pb/provider_grpc.pb.go | 38 ++++ services/provider/proto/provider.proto | 12 + 3 files changed, 257 insertions(+), 69 deletions(-) diff --git a/services/provider/pb/provider.pb.go b/services/provider/pb/provider.pb.go index 9fc810868f..f3a5534010 100644 --- a/services/provider/pb/provider.pb.go +++ b/services/provider/pb/provider.pb.go @@ -1098,6 +1098,101 @@ func (*PeerBlockPoolResponse) Descriptor() ([]byte, []int) { return file_provider_proto_rawDescGZIP(), []int{18} } +type RevokeBlockPoolPeeringRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // secretName is the name of the bootstrap secret + SecretName string `protobuf:"bytes,1,opt,name=secretName,proto3" json:"secretName,omitempty"` + // pool base64 encoded name of the block pool + Pool []byte `protobuf:"bytes,2,opt,name=pool,proto3" json:"pool,omitempty"` +} + +func (x *RevokeBlockPoolPeeringRequest) Reset() { + *x = RevokeBlockPoolPeeringRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_provider_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RevokeBlockPoolPeeringRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RevokeBlockPoolPeeringRequest) ProtoMessage() {} + +func (x *RevokeBlockPoolPeeringRequest) ProtoReflect() protoreflect.Message { + mi := &file_provider_proto_msgTypes[19] + 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 RevokeBlockPoolPeeringRequest.ProtoReflect.Descriptor instead. +func (*RevokeBlockPoolPeeringRequest) Descriptor() ([]byte, []int) { + return file_provider_proto_rawDescGZIP(), []int{19} +} + +func (x *RevokeBlockPoolPeeringRequest) GetSecretName() string { + if x != nil { + return x.SecretName + } + return "" +} + +func (x *RevokeBlockPoolPeeringRequest) GetPool() []byte { + if x != nil { + return x.Pool + } + return nil +} + +type RevokeBlockPoolPeeringResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RevokeBlockPoolPeeringResponse) Reset() { + *x = RevokeBlockPoolPeeringResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_provider_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RevokeBlockPoolPeeringResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RevokeBlockPoolPeeringResponse) ProtoMessage() {} + +func (x *RevokeBlockPoolPeeringResponse) ProtoReflect() protoreflect.Message { + mi := &file_provider_proto_msgTypes[20] + 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 RevokeBlockPoolPeeringResponse.ProtoReflect.Descriptor instead. +func (*RevokeBlockPoolPeeringResponse) Descriptor() ([]byte, []int) { + return file_provider_proto_rawDescGZIP(), []int{20} +} + var File_provider_proto protoreflect.FileDescriptor var file_provider_proto_rawDesc = []byte{ @@ -1226,62 +1321,77 @@ var file_provider_proto_rawDesc = []byte{ 0x0c, 0x52, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x50, 0x65, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xdb, 0x06, 0x0a, 0x0b, 0x4f, 0x43, 0x53, 0x50, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0f, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, - 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, - 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, - 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x55, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, - 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, - 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x10, 0x4f, 0x66, 0x66, 0x62, 0x6f, - 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x12, 0x21, 0x2e, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x66, 0x66, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, - 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x66, 0x66, 0x62, 0x6f, 0x61, - 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, - 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x26, 0x2e, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, - 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, - 0x2e, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, - 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x64, 0x0a, 0x13, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, - 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x2e, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, - 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x61, 0x0a, 0x12, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, - 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x23, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, - 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x76, - 0x6f, 0x6b, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, 0x15, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, - 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, - 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x4f, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, - 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x52, 0x0a, 0x0d, 0x50, 0x65, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, - 0x6c, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x65, 0x65, - 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x50, 0x65, 0x65, - 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x76, 0x69, - 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x53, 0x0a, 0x1d, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x50, 0x65, 0x65, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, + 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x63, + 0x72, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x22, 0x20, 0x0a, 0x1e, 0x52, + 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x50, 0x65, + 0x65, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xca, 0x07, + 0x0a, 0x0b, 0x4f, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, + 0x0f, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, + 0x12, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, 0x62, 0x6f, + 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x6e, + 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1e, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, + 0x0a, 0x10, 0x4f, 0x66, 0x66, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, + 0x65, 0x72, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x4f, 0x66, + 0x66, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x2e, 0x4f, 0x66, 0x66, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6a, 0x0a, 0x15, 0x41, + 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, + 0x64, 0x69, 0x6e, 0x67, 0x12, 0x26, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, + 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, + 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x41, 0x63, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, + 0x64, 0x67, 0x65, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, 0x13, 0x46, 0x75, 0x6c, 0x66, 0x69, + 0x6c, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x12, 0x24, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, + 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, + 0x46, 0x75, 0x6c, 0x66, 0x69, 0x6c, 0x6c, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, + 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x61, 0x0a, + 0x12, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, + 0x61, 0x69, 0x6d, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, + 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, + 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x64, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, + 0x61, 0x69, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x61, 0x69, + 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x0c, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, + 0x72, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0d, 0x50, 0x65, 0x65, 0x72, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, + 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, + 0x64, 0x65, 0x72, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, + 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6d, 0x0a, 0x16, 0x52, + 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x50, 0x65, + 0x65, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x27, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, + 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, + 0x50, 0x65, 0x65, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x6f, 0x6f, 0x6c, 0x50, 0x65, 0x65, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, + 0x3b, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -1297,7 +1407,7 @@ func file_provider_proto_rawDescGZIP() []byte { } var file_provider_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_provider_proto_msgTypes = make([]protoimpl.MessageInfo, 19) +var file_provider_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_provider_proto_goTypes = []interface{}{ (FulfillStorageClaimRequest_StorageType)(0), // 0: provider.FulfillStorageClaimRequest.StorageType (*OnboardConsumerRequest)(nil), // 1: provider.OnboardConsumerRequest @@ -1319,6 +1429,8 @@ var file_provider_proto_goTypes = []interface{}{ (*ReportStatusResponse)(nil), // 17: provider.ReportStatusResponse (*PeerBlockPoolRequest)(nil), // 18: provider.PeerBlockPoolRequest (*PeerBlockPoolResponse)(nil), // 19: provider.PeerBlockPoolResponse + (*RevokeBlockPoolPeeringRequest)(nil), // 20: provider.RevokeBlockPoolPeeringRequest + (*RevokeBlockPoolPeeringResponse)(nil), // 21: provider.RevokeBlockPoolPeeringResponse } var file_provider_proto_depIdxs = []int32{ 4, // 0: provider.StorageConfigResponse.externalResource:type_name -> provider.ExternalResource @@ -1333,17 +1445,19 @@ var file_provider_proto_depIdxs = []int32{ 14, // 9: provider.OCSProvider.GetStorageClaimConfig:input_type -> provider.StorageClaimConfigRequest 16, // 10: provider.OCSProvider.ReportStatus:input_type -> provider.ReportStatusRequest 18, // 11: provider.OCSProvider.PeerBlockPool:input_type -> provider.PeerBlockPoolRequest - 2, // 12: provider.OCSProvider.OnboardConsumer:output_type -> provider.OnboardConsumerResponse - 5, // 13: provider.OCSProvider.GetStorageConfig:output_type -> provider.StorageConfigResponse - 7, // 14: provider.OCSProvider.OffboardConsumer:output_type -> provider.OffboardConsumerResponse - 9, // 15: provider.OCSProvider.AcknowledgeOnboarding:output_type -> provider.AcknowledgeOnboardingResponse - 11, // 16: provider.OCSProvider.FulfillStorageClaim:output_type -> provider.FulfillStorageClaimResponse - 13, // 17: provider.OCSProvider.RevokeStorageClaim:output_type -> provider.RevokeStorageClaimResponse - 15, // 18: provider.OCSProvider.GetStorageClaimConfig:output_type -> provider.StorageClaimConfigResponse - 17, // 19: provider.OCSProvider.ReportStatus:output_type -> provider.ReportStatusResponse - 19, // 20: provider.OCSProvider.PeerBlockPool:output_type -> provider.PeerBlockPoolResponse - 12, // [12:21] is the sub-list for method output_type - 3, // [3:12] is the sub-list for method input_type + 20, // 12: provider.OCSProvider.RevokeBlockPoolPeering:input_type -> provider.RevokeBlockPoolPeeringRequest + 2, // 13: provider.OCSProvider.OnboardConsumer:output_type -> provider.OnboardConsumerResponse + 5, // 14: provider.OCSProvider.GetStorageConfig:output_type -> provider.StorageConfigResponse + 7, // 15: provider.OCSProvider.OffboardConsumer:output_type -> provider.OffboardConsumerResponse + 9, // 16: provider.OCSProvider.AcknowledgeOnboarding:output_type -> provider.AcknowledgeOnboardingResponse + 11, // 17: provider.OCSProvider.FulfillStorageClaim:output_type -> provider.FulfillStorageClaimResponse + 13, // 18: provider.OCSProvider.RevokeStorageClaim:output_type -> provider.RevokeStorageClaimResponse + 15, // 19: provider.OCSProvider.GetStorageClaimConfig:output_type -> provider.StorageClaimConfigResponse + 17, // 20: provider.OCSProvider.ReportStatus:output_type -> provider.ReportStatusResponse + 19, // 21: provider.OCSProvider.PeerBlockPool:output_type -> provider.PeerBlockPoolResponse + 21, // 22: provider.OCSProvider.RevokeBlockPoolPeering:output_type -> provider.RevokeBlockPoolPeeringResponse + 13, // [13:23] is the sub-list for method output_type + 3, // [3:13] 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 @@ -1583,6 +1697,30 @@ func file_provider_proto_init() { return nil } } + file_provider_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RevokeBlockPoolPeeringRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_provider_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RevokeBlockPoolPeeringResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1590,7 +1728,7 @@ func file_provider_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_provider_proto_rawDesc, NumEnums: 1, - NumMessages: 19, + NumMessages: 21, NumExtensions: 0, NumServices: 1, }, diff --git a/services/provider/pb/provider_grpc.pb.go b/services/provider/pb/provider_grpc.pb.go index f1bf52fd9f..1551e16d6f 100644 --- a/services/provider/pb/provider_grpc.pb.go +++ b/services/provider/pb/provider_grpc.pb.go @@ -39,6 +39,8 @@ type OCSProviderClient interface { ReportStatus(ctx context.Context, in *ReportStatusRequest, opts ...grpc.CallOption) (*ReportStatusResponse, error) // PeerBlockPool RPC call to send the bootstrap secret for the pool PeerBlockPool(ctx context.Context, in *PeerBlockPoolRequest, opts ...grpc.CallOption) (*PeerBlockPoolResponse, error) + // RevokeBlockPoolPeering RPC call to delete the bootstrap secret to stop peering + RevokeBlockPoolPeering(ctx context.Context, in *RevokeBlockPoolPeeringRequest, opts ...grpc.CallOption) (*RevokeBlockPoolPeeringResponse, error) } type oCSProviderClient struct { @@ -130,6 +132,15 @@ func (c *oCSProviderClient) PeerBlockPool(ctx context.Context, in *PeerBlockPool return out, nil } +func (c *oCSProviderClient) RevokeBlockPoolPeering(ctx context.Context, in *RevokeBlockPoolPeeringRequest, opts ...grpc.CallOption) (*RevokeBlockPoolPeeringResponse, error) { + out := new(RevokeBlockPoolPeeringResponse) + err := c.cc.Invoke(ctx, "/provider.OCSProvider/RevokeBlockPoolPeering", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // OCSProviderServer is the server API for OCSProvider service. // All implementations must embed UnimplementedOCSProviderServer // for forward compatibility @@ -155,6 +166,8 @@ type OCSProviderServer interface { ReportStatus(context.Context, *ReportStatusRequest) (*ReportStatusResponse, error) // PeerBlockPool RPC call to send the bootstrap secret for the pool PeerBlockPool(context.Context, *PeerBlockPoolRequest) (*PeerBlockPoolResponse, error) + // RevokeBlockPoolPeering RPC call to delete the bootstrap secret to stop peering + RevokeBlockPoolPeering(context.Context, *RevokeBlockPoolPeeringRequest) (*RevokeBlockPoolPeeringResponse, error) mustEmbedUnimplementedOCSProviderServer() } @@ -189,6 +202,9 @@ func (UnimplementedOCSProviderServer) ReportStatus(context.Context, *ReportStatu func (UnimplementedOCSProviderServer) PeerBlockPool(context.Context, *PeerBlockPoolRequest) (*PeerBlockPoolResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PeerBlockPool not implemented") } +func (UnimplementedOCSProviderServer) RevokeBlockPoolPeering(context.Context, *RevokeBlockPoolPeeringRequest) (*RevokeBlockPoolPeeringResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RevokeBlockPoolPeering not implemented") +} func (UnimplementedOCSProviderServer) mustEmbedUnimplementedOCSProviderServer() {} // UnsafeOCSProviderServer may be embedded to opt out of forward compatibility for this service. @@ -364,6 +380,24 @@ func _OCSProvider_PeerBlockPool_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _OCSProvider_RevokeBlockPoolPeering_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RevokeBlockPoolPeeringRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OCSProviderServer).RevokeBlockPoolPeering(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/provider.OCSProvider/RevokeBlockPoolPeering", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OCSProviderServer).RevokeBlockPoolPeering(ctx, req.(*RevokeBlockPoolPeeringRequest)) + } + return interceptor(ctx, in, info, handler) +} + // OCSProvider_ServiceDesc is the grpc.ServiceDesc for OCSProvider service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -407,6 +441,10 @@ var OCSProvider_ServiceDesc = grpc.ServiceDesc{ MethodName: "PeerBlockPool", Handler: _OCSProvider_PeerBlockPool_Handler, }, + { + MethodName: "RevokeBlockPoolPeering", + Handler: _OCSProvider_RevokeBlockPoolPeering_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "provider.proto", diff --git a/services/provider/proto/provider.proto b/services/provider/proto/provider.proto index 24c41cf25e..1ac2d923ac 100644 --- a/services/provider/proto/provider.proto +++ b/services/provider/proto/provider.proto @@ -41,6 +41,9 @@ service OCSProvider { // PeerBlockPool RPC call to send the bootstrap secret for the pool rpc PeerBlockPool(PeerBlockPoolRequest) returns (PeerBlockPoolResponse){} + // RevokeBlockPoolPeering RPC call to delete the bootstrap secret to stop peering + rpc RevokeBlockPoolPeering(RevokeBlockPoolPeeringRequest) + returns (RevokeBlockPoolPeeringResponse){} } // OnboardConsumerRequest holds the required information to validate the consumer and create StorageConsumer @@ -186,3 +189,12 @@ message PeerBlockPoolRequest{ } message PeerBlockPoolResponse{} + +message RevokeBlockPoolPeeringRequest{ + // secretName is the name of the bootstrap secret + string secretName = 1; + // pool base64 encoded name of the block pool + bytes pool = 2; +} + +message RevokeBlockPoolPeeringResponse{} From 24fb2fb17ea7d280959574a3a2b15a602a20e1e7 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 5 Mar 2024 12:59:54 +0530 Subject: [PATCH 5/9] add client implementation for revokeBlockPoolPeering rpc call Signed-off-by: Rewant Soni --- services/provider/client/client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/services/provider/client/client.go b/services/provider/client/client.go index 214522eba8..2c26afde4a 100644 --- a/services/provider/client/client.go +++ b/services/provider/client/client.go @@ -224,3 +224,19 @@ func (cc *OCSProviderClient) PeerBlockPool(ctx context.Context, secretName strin return cc.Client.PeerBlockPool(apiCtx, req) } + +func (cc *OCSProviderClient) RevokeBlockPoolPeering(ctx context.Context, secretName string, pool []byte) (*pb.RevokeBlockPoolPeeringResponse, error) { + if cc.Client == nil || cc.clientConn == nil { + return nil, fmt.Errorf("OCS client is closed") + } + + req := &pb.RevokeBlockPoolPeeringRequest{ + SecretName: secretName, + Pool: pool, + } + + apiCtx, cancel := context.WithTimeout(ctx, cc.timeout) + defer cancel() + + return cc.Client.RevokeBlockPoolPeering(apiCtx, req) +} From 321868aa0d1d6d9060c06df086485feb234152ee Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 5 Mar 2024 13:00:29 +0530 Subject: [PATCH 6/9] add server implementation for revokeBlockPoolPeering rpc call Signed-off-by: Rewant Soni --- .../ocs-operator/manifests/provider-role.yaml | 3 + rbac/provider-role.yaml | 3 + services/provider/server/cephblockpool.go | 64 +++++++++++++++++++ services/provider/server/cephrbdmirror.go | 17 +++++ services/provider/server/server.go | 38 +++++++++++ 5 files changed, 125 insertions(+) diff --git a/deploy/ocs-operator/manifests/provider-role.yaml b/deploy/ocs-operator/manifests/provider-role.yaml index 299f6cbf3e..ba6950459f 100644 --- a/deploy/ocs-operator/manifests/provider-role.yaml +++ b/deploy/ocs-operator/manifests/provider-role.yaml @@ -18,6 +18,7 @@ rules: - get - create - update + - delete - apiGroups: - ceph.rook.io resources: @@ -38,6 +39,7 @@ rules: - cephblockpools verbs: - get + - list - update - apiGroups: - ocs.openshift.io @@ -88,3 +90,4 @@ rules: verbs: - get - create + - delete diff --git a/rbac/provider-role.yaml b/rbac/provider-role.yaml index 299f6cbf3e..ba6950459f 100644 --- a/rbac/provider-role.yaml +++ b/rbac/provider-role.yaml @@ -18,6 +18,7 @@ rules: - get - create - update + - delete - apiGroups: - ceph.rook.io resources: @@ -38,6 +39,7 @@ rules: - cephblockpools verbs: - get + - list - update - apiGroups: - ocs.openshift.io @@ -88,3 +90,4 @@ rules: verbs: - get - create + - delete diff --git a/services/provider/server/cephblockpool.go b/services/provider/server/cephblockpool.go index 3360076df0..9ec44537eb 100644 --- a/services/provider/server/cephblockpool.go +++ b/services/provider/server/cephblockpool.go @@ -7,6 +7,7 @@ import ( rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" corev1 "k8s.io/api/core/v1" + kerrors "k8s.io/apimachinery/pkg/api/errors" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -69,6 +70,52 @@ func (c *cephBlockPoolManager) SetBootstrapSecretRef(ctx context.Context, cephBl return nil } +func (c *cephBlockPoolManager) UnSetAndDeleteBootstrapSecret(ctx context.Context, secretName string, cephBlockPool *rookCephv1.CephBlockPool) error { + + // remove the secret ref + index := slices.IndexFunc(cephBlockPool.Spec.Mirroring.Peers.SecretNames, func(s string) bool { + return s == secretName + }) + if index >= 0 { + cephBlockPool.Spec.Mirroring.Peers.SecretNames = append( + cephBlockPool.Spec.Mirroring.Peers.SecretNames[:index], + cephBlockPool.Spec.Mirroring.Peers.SecretNames[index+1:]...) + } + + err := c.client.Update(ctx, cephBlockPool) + if err != nil { + return fmt.Errorf("failed to unset bootstrap secret ref on CephBlockPool resource with name %q: %v", cephBlockPool.Name, err) + } + + // delete secret + bootstrapSecret := &corev1.Secret{} + bootstrapSecret.Name = secretName + bootstrapSecret.Namespace = c.namespace + err = c.client.Delete(ctx, bootstrapSecret) + // there might be a case where the bootstrap secret was deleted but request failed after this and there was a retry, + // if error is IsNotFound, that means it is safe to proceed as we have deleted the bootstrap secret + if err != nil && !kerrors.IsNotFound(err) { + return fmt.Errorf("failed to delete the bootstrap secret %q: %v", secretName, err) + } + return nil +} + +func (c *cephBlockPoolManager) DisableBlockPoolMirroring(ctx context.Context, cephBlockPool *rookCephv1.CephBlockPool) error { + + // disable only if no bootstrap secret has been set + if cephBlockPool.Spec.Mirroring.Peers == nil || len(cephBlockPool.Spec.Mirroring.Peers.SecretNames) == 0 { + cephBlockPool.Spec.Mirroring.Enabled = false + cephBlockPool.Spec.Mirroring.Mode = "" + } + + err := c.client.Update(ctx, cephBlockPool) + if err != nil { + return fmt.Errorf("failed to disable mirroring on CephBlockPool resource with name %q: %v", cephBlockPool.Name, err) + } + + return nil +} + func (c *cephBlockPoolManager) GetBlockPoolByName(ctx context.Context, blockPoolName string) (*rookCephv1.CephBlockPool, error) { blockPool := &rookCephv1.CephBlockPool{} blockPool.Name = blockPoolName @@ -79,3 +126,20 @@ func (c *cephBlockPoolManager) GetBlockPoolByName(ctx context.Context, blockPool } return blockPool, nil } + +// IsRBDMirrorRequired checks if we require RBDMirror to be deployed or not +func (c *cephBlockPoolManager) IsRBDMirrorRequired(ctx context.Context) (bool, error) { + cephBlockPoolList := &rookCephv1.CephBlockPoolList{} + err := c.client.List(ctx, cephBlockPoolList, client.InNamespace(c.namespace)) + if err != nil { + return true, err + } + + // if we find a bootstrap secret in any of the blockPools, we require RBDMirror to be deployed + for _, cephBlockPool := range cephBlockPoolList.Items { + if cephBlockPool.Spec.Mirroring.Peers != nil && len(cephBlockPool.Spec.Mirroring.Peers.SecretNames) > 0 { + return true, nil + } + } + return false, nil +} diff --git a/services/provider/server/cephrbdmirror.go b/services/provider/server/cephrbdmirror.go index ebafc0becd..3fcff5a609 100644 --- a/services/provider/server/cephrbdmirror.go +++ b/services/provider/server/cephrbdmirror.go @@ -5,6 +5,7 @@ import ( rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -41,3 +42,19 @@ func (c *cephRBDMirrorManager) Create(ctx context.Context) error { // if any other err/nil return it return err } + +func (c *cephRBDMirrorManager) Delete(ctx context.Context) error { + cephRBDMirrorObj := &rookCephv1.CephRBDMirror{ + ObjectMeta: metav1.ObjectMeta{ + Name: rBDMirrorName, + Namespace: c.namespace, + }, + } + err := c.client.Delete(ctx, cephRBDMirrorObj) + // there might be a case where the RBDMirror was deleted but request failed after this and there was a retry, + // if error is IsNotFound, that means it is safe to proceed as we have deleted the RBDMirror instance + if err != nil && !kerrors.IsNotFound(err) { + return err + } + return nil +} diff --git a/services/provider/server/server.go b/services/provider/server/server.go index f8756de104..de0714b084 100644 --- a/services/provider/server/server.go +++ b/services/provider/server/server.go @@ -768,3 +768,41 @@ func (s *OCSProviderServer) PeerBlockPool(ctx context.Context, req *pb.PeerBlock } return &pb.PeerBlockPoolResponse{}, nil } + +// RevokeBlockPoolPeering RPC call to delete the bootstrap secret to stop peering +func (s *OCSProviderServer) RevokeBlockPoolPeering(ctx context.Context, req *pb.RevokeBlockPoolPeeringRequest) (*pb.RevokeBlockPoolPeeringResponse, error) { + + klog.Infof("RevokeBlockPoolPeering request received for CephBlockPool %s and bootstrap secret %s", req.Pool, req.SecretName) + + cephBlockPool, err := s.cephBlockPoolManager.GetBlockPoolByName(ctx, string(req.Pool)) + if err != nil { + return nil, status.Errorf(codes.NotFound, "Failed to find CephBlockPool resource %s: %v", req.Pool, err) + } + + // delete secret and unset ref on the blockPool + err = s.cephBlockPoolManager.UnSetAndDeleteBootstrapSecret(ctx, req.SecretName, cephBlockPool) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to unset bootstrap secret ref for CephBlockPool resource %s: %v", req.Pool, err) + } + + // disable mirroring on blockPool in the req + err = s.cephBlockPoolManager.DisableBlockPoolMirroring(ctx, cephBlockPool) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to disable mirroring for CephBlockPool resource %s: %v", req.Pool, err) + } + + isRBDMirrorRequired, err := s.cephBlockPoolManager.IsRBDMirrorRequired(ctx) + if err != nil { + return nil, status.Errorf(codes.Internal, "Failed to get if rbd mirror is required: %v,", err) + } + + if !isRBDMirrorRequired { + klog.Infof("No bootstrap secret found for any block pools, removing the rbd mirror instance") + err := s.cephRBDMirrorManager.Delete(ctx) + if err != nil { + klog.Errorf("Failed to delete CephRBDMirror instance: %v", err) + return nil, status.Errorf(codes.Internal, "Failed to delete CephRBDMirror instance: %v", err) + } + } + return &pb.RevokeBlockPoolPeeringResponse{}, nil +} From f20f5987b837661aac198e3f14016e84a83cd7da Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 23 Jan 2024 11:42:15 +0530 Subject: [PATCH 7/9] Add new CR and controller for storageClusterPeer ran the command: operator-sdk create api --group ocs --version v1 --kind StorageClusterPeer --resource --controller Signed-off-by: Rewant Soni --- PROJECT | 9 ++ api/v1/storageclusterpeer_types.go | 88 +++++++++++++++++++ config/crd/kustomization.yaml | 3 + .../cainjection_in_storageclusterpeers.yaml | 7 ++ .../webhook_in_storageclusterpeers.yaml | 16 ++++ .../rbac/storageclusterpeer_editor_role.yaml | 31 +++++++ .../rbac/storageclusterpeer_viewer_role.yaml | 27 ++++++ config/samples/kustomization.yaml | 1 + config/samples/ocs_v1_storageclusterpeer.yaml | 7 ++ .../storageclusterpeer_controller.go | 62 +++++++++++++ main.go | 9 ++ 11 files changed, 260 insertions(+) create mode 100644 api/v1/storageclusterpeer_types.go create mode 100644 config/crd/patches/cainjection_in_storageclusterpeers.yaml create mode 100644 config/crd/patches/webhook_in_storageclusterpeers.yaml create mode 100644 config/rbac/storageclusterpeer_editor_role.yaml create mode 100644 config/rbac/storageclusterpeer_viewer_role.yaml create mode 100644 config/samples/ocs_v1_storageclusterpeer.yaml create mode 100644 controllers/storageclusterpeer/storageclusterpeer_controller.go diff --git a/PROJECT b/PROJECT index 4f3863cc80..b97ad022e0 100644 --- a/PROJECT +++ b/PROJECT @@ -51,4 +51,13 @@ resources: kind: StorageRequest path: github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1 version: v1alpha1 +- api: + crdVersion: v1 + namespaced: true + controller: true + domain: openshift.io + group: ocs + kind: StorageClusterPeer + path: github.com/red-hat-storage/ocs-operator/api/v4/v1 + version: v1 version: "3" diff --git a/api/v1/storageclusterpeer_types.go b/api/v1/storageclusterpeer_types.go new file mode 100644 index 0000000000..a7eb66ec39 --- /dev/null +++ b/api/v1/storageclusterpeer_types.go @@ -0,0 +1,88 @@ +/* +Copyright 2020 Red Hat OpenShift Container Storage. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +type StorageClusterPeerState string + +const ( + // StorageClusterPeerInitializing represents Initializing state of StorageClusterPeerState + StorageClusterPeerInitializing StorageClusterPeerState = "Initializing" + // StorageClusterPeerValidating represents Validating state of StorageClusterPeerState + StorageClusterPeerValidating StorageClusterPeerState = "Validating" + // StorageClusterPeerFailed represents Failed state of StorageClusterPeerState + StorageClusterPeerFailed StorageClusterPeerState = "Failed" + // StorageClusterPeerCreating represents Configuring state of StorageClusterPeerState + StorageClusterPeerCreating StorageClusterPeerState = "Creating" + // StorageClusterPeerConfiguring represents Configuring state of StorageClusterPeerState + StorageClusterPeerConfiguring StorageClusterPeerState = "Configuring" + // StorageClusterPeerReady represents Ready state of StorageClusterPeerState + StorageClusterPeerReady StorageClusterPeerState = "Ready" + // StorageClusterPeerDeleting represents Deleting state of StorageClusterPeerState + StorageClusterPeerDeleting StorageClusterPeerState = "Deleting" +) + +const ( + StorageClusterPeerFinalizer = "storageclusterpeer.ocs.openshift.io" +) + +// StorageClusterPeerSpec defines the desired state of StorageClusterPeer +type StorageClusterPeerSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // OCSAPIServerURI is the URI of the secondary ocs api server + OCSAPIServerURI string `json:"ocsApiServerUri,omitempty"` +} + +// StorageClusterPeerStatus defines the observed state of StorageClusterPeer +type StorageClusterPeerStatus struct { + + // Phase describes the Phase of StorageClusterPeer + // This is used by OLM UI to provide status information to the user + Phase StorageClusterPeerState `json:"phase,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=.metadata.creationTimestamp +//+kubebuilder:printcolumn:name="Phase",type=string,JSONPath=.status.phase,description="Current Phase" +//+operator-sdk:csv:customresourcedefinitions:displayName="Storage Cluster Peer" + +// StorageClusterPeer is the Schema for the storageclusterpeers API +type StorageClusterPeer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec StorageClusterPeerSpec `json:"spec,omitempty"` + Status StorageClusterPeerStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// StorageClusterPeerList contains a list of StorageClusterPeer +type StorageClusterPeerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []StorageClusterPeer `json:"items"` +} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 23ef658b01..1a6367a70b 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -7,6 +7,7 @@ resources: - bases/ocs.openshift.io_storageconsumers.yaml - bases/ocs.openshift.io_storagerequests.yaml - bases/ocs.openshift.io_storageprofiles.yaml +- bases/ocs.openshift.io_storageclusterpeers.yaml # +kubebuilder:scaffold:crdkustomizeresource # patchesStrategicMerge: @@ -17,6 +18,7 @@ resources: #- patches/webhook_in_storageconsumers.yaml #- patches/webhook_in_storagerequests.yaml #- patches/webhook_in_storageprofiles.yaml +#- patches/webhook_in_storageclusterpeers.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. @@ -26,6 +28,7 @@ resources: #- patches/cainjection_in_storageconsumers.yaml #- patches/cainjection_in_storagerequests.yaml #- patches/cainjection_in_storageprofiles.yaml +#- patches/cainjection_in_storageclusterpeers.yaml # +kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_storageclusterpeers.yaml b/config/crd/patches/cainjection_in_storageclusterpeers.yaml new file mode 100644 index 0000000000..49fa87e731 --- /dev/null +++ b/config/crd/patches/cainjection_in_storageclusterpeers.yaml @@ -0,0 +1,7 @@ +# The following patch adds a directive for certmanager to inject CA into the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + name: storageclusterpeers.ocs.openshift.io diff --git a/config/crd/patches/webhook_in_storageclusterpeers.yaml b/config/crd/patches/webhook_in_storageclusterpeers.yaml new file mode 100644 index 0000000000..23f3724556 --- /dev/null +++ b/config/crd/patches/webhook_in_storageclusterpeers.yaml @@ -0,0 +1,16 @@ +# The following patch enables a conversion webhook for the CRD +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: storageclusterpeers.ocs.openshift.io +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + namespace: system + name: webhook-service + path: /convert + conversionReviewVersions: + - v1 diff --git a/config/rbac/storageclusterpeer_editor_role.yaml b/config/rbac/storageclusterpeer_editor_role.yaml new file mode 100644 index 0000000000..5a7bbfbc51 --- /dev/null +++ b/config/rbac/storageclusterpeer_editor_role.yaml @@ -0,0 +1,31 @@ +# permissions for end users to edit storageclusterpeers. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: storageclusterpeer-editor-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: ocs-operator + app.kubernetes.io/part-of: ocs-operator + app.kubernetes.io/managed-by: kustomize + name: storageclusterpeer-editor-role +rules: +- apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/status + verbs: + - get diff --git a/config/rbac/storageclusterpeer_viewer_role.yaml b/config/rbac/storageclusterpeer_viewer_role.yaml new file mode 100644 index 0000000000..e616824491 --- /dev/null +++ b/config/rbac/storageclusterpeer_viewer_role.yaml @@ -0,0 +1,27 @@ +# permissions for end users to view storageclusterpeers. +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/name: clusterrole + app.kubernetes.io/instance: storageclusterpeer-viewer-role + app.kubernetes.io/component: rbac + app.kubernetes.io/created-by: ocs-operator + app.kubernetes.io/part-of: ocs-operator + app.kubernetes.io/managed-by: kustomize + name: storageclusterpeer-viewer-role +rules: +- apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers + verbs: + - get + - list + - watch +- apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/status + verbs: + - get diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index bff9db7c1e..556d0eaba0 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -4,4 +4,5 @@ resources: - ocs_v1_storagecluster.yaml - ocs_v1alpha1_storageconsumer.yaml - ocs_v1_storageprofile.yaml +- ocs_v1_storageclusterpeer.yaml # +kubebuilder:scaffold:manifestskustomizesamples diff --git a/config/samples/ocs_v1_storageclusterpeer.yaml b/config/samples/ocs_v1_storageclusterpeer.yaml new file mode 100644 index 0000000000..567f70051d --- /dev/null +++ b/config/samples/ocs_v1_storageclusterpeer.yaml @@ -0,0 +1,7 @@ +apiVersion: ocs.openshift.io/v1 +kind: StorageClusterPeer +metadata: + labels: + name: storageclusterpeer-sample +spec: + ocsApiServerUri: 10.0.0.0:31659 diff --git a/controllers/storageclusterpeer/storageclusterpeer_controller.go b/controllers/storageclusterpeer/storageclusterpeer_controller.go new file mode 100644 index 0000000000..b6e4d86a08 --- /dev/null +++ b/controllers/storageclusterpeer/storageclusterpeer_controller.go @@ -0,0 +1,62 @@ +/* +Copyright 2020 Red Hat OpenShift Container Storage. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package storageclusterpeer + +import ( + "context" + + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/log" + + ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1" +) + +// StorageClusterPeerReconciler reconciles a StorageClusterPeer object +type StorageClusterPeerReconciler struct { + client.Client + Scheme *runtime.Scheme +} + +//+kubebuilder:rbac:groups=ocs.openshift.io,resources=storageclusterpeers,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=ocs.openshift.io,resources=storageclusterpeers/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=ocs.openshift.io,resources=storageclusterpeers/finalizers,verbs=update + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +// TODO(user): Modify the Reconcile function to compare the state specified by +// the StorageClusterPeer object against the actual cluster state, and then +// perform operations to make the cluster state reflect the state specified by +// the user. +// +// For more details, check Reconcile and its Result here: +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile +func (r *StorageClusterPeerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + _ = log.FromContext(ctx) + + // TODO(user): your logic here + + return ctrl.Result{}, nil +} + +// SetupWithManager sets up the controller with the Manager. +func (r *StorageClusterPeerReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&ocsv1.StorageClusterPeer{}). + Complete(r) +} diff --git a/main.go b/main.go index 92c8725c75..bd63ac9d1b 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,7 @@ import ( "github.com/red-hat-storage/ocs-operator/v4/controllers/ocsinitialization" "github.com/red-hat-storage/ocs-operator/v4/controllers/platform" "github.com/red-hat-storage/ocs-operator/v4/controllers/storagecluster" + "github.com/red-hat-storage/ocs-operator/v4/controllers/storageclusterpeer" controllers "github.com/red-hat-storage/ocs-operator/v4/controllers/storageconsumer" "github.com/red-hat-storage/ocs-operator/v4/controllers/storagerequest" "github.com/red-hat-storage/ocs-operator/v4/controllers/util" @@ -63,6 +64,7 @@ import ( apiclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log/zap" metrics "sigs.k8s.io/controller-runtime/pkg/metrics/server" + // +kubebuilder:scaffold:imports ) @@ -207,6 +209,13 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "StorageRequest") os.Exit(1) } + if err = (&storageclusterpeer.StorageClusterPeerReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "StorageClusterPeer") + os.Exit(1) + } // +kubebuilder:scaffold:builder // Create OCSInitialization CR if it's not present From 4d4f47e97392845f0255fe9e020cd5f8d7e0bed4 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Wed, 28 Feb 2024 16:26:42 +0530 Subject: [PATCH 8/9] add generated changes for storageClusterPeer Signed-off-by: Rewant Soni --- api/v1/groupversion_info.go | 1 + api/v1/zz_generated.deepcopy.go | 89 +++++++++++++++++++ .../ocs.openshift.io_storageclusterpeers.yaml | 63 +++++++++++++ .../ocs-operator.clusterserviceversion.yaml | 5 ++ config/rbac/role.yaml | 26 ++++++ .../ocs.openshift.io_storageclusterpeers.yaml | 63 +++++++++++++ deploy/csv-templates/ocs-operator.csv.yaml.in | 42 +++++++++ .../ocs-operator.clusterserviceversion.yaml | 33 ++++++- .../manifests/storageclusterpeer.crd.yaml | 62 +++++++++++++ .../api/v4/v1/groupversion_info.go | 1 + .../api/v4/v1/storageclusterpeer_types.go | 88 ++++++++++++++++++ .../api/v4/v1/zz_generated.deepcopy.go | 89 +++++++++++++++++++ .../api/v4/v1/groupversion_info.go | 1 + .../api/v4/v1/storageclusterpeer_types.go | 88 ++++++++++++++++++ .../api/v4/v1/zz_generated.deepcopy.go | 89 +++++++++++++++++++ 15 files changed, 739 insertions(+), 1 deletion(-) create mode 100644 config/crd/bases/ocs.openshift.io_storageclusterpeers.yaml create mode 100644 deploy/csv-templates/crds/ocs/ocs.openshift.io_storageclusterpeers.yaml create mode 100644 deploy/ocs-operator/manifests/storageclusterpeer.crd.yaml create mode 100644 metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go create mode 100644 vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go diff --git a/api/v1/groupversion_info.go b/api/v1/groupversion_info.go index af76991754..0bd23f33b4 100644 --- a/api/v1/groupversion_info.go +++ b/api/v1/groupversion_info.go @@ -44,6 +44,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &OCSInitialization{}, &OCSInitializationList{}, &StorageCluster{}, &StorageClusterList{}, &StorageProfile{}, &StorageProfileList{}, + &StorageClusterPeer{}, &StorageClusterPeerList{}, ) metav1.AddToGroupVersion(scheme, GroupVersion) return nil diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 14a373a70c..6e035928e3 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -801,6 +801,95 @@ func (in *StorageClusterList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeer) DeepCopyInto(out *StorageClusterPeer) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeer. +func (in *StorageClusterPeer) DeepCopy() *StorageClusterPeer { + if in == nil { + return nil + } + out := new(StorageClusterPeer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageClusterPeer) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerList) DeepCopyInto(out *StorageClusterPeerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]StorageClusterPeer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerList. +func (in *StorageClusterPeerList) DeepCopy() *StorageClusterPeerList { + if in == nil { + return nil + } + out := new(StorageClusterPeerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageClusterPeerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerSpec) DeepCopyInto(out *StorageClusterPeerSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerSpec. +func (in *StorageClusterPeerSpec) DeepCopy() *StorageClusterPeerSpec { + if in == nil { + return nil + } + out := new(StorageClusterPeerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerStatus) DeepCopyInto(out *StorageClusterPeerStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerStatus. +func (in *StorageClusterPeerStatus) DeepCopy() *StorageClusterPeerStatus { + if in == nil { + return nil + } + out := new(StorageClusterPeerStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageClusterSpec) DeepCopyInto(out *StorageClusterSpec) { *out = *in diff --git a/config/crd/bases/ocs.openshift.io_storageclusterpeers.yaml b/config/crd/bases/ocs.openshift.io_storageclusterpeers.yaml new file mode 100644 index 0000000000..576e0b1eb1 --- /dev/null +++ b/config/crd/bases/ocs.openshift.io_storageclusterpeers.yaml @@ -0,0 +1,63 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.2 + creationTimestamp: null + name: storageclusterpeers.ocs.openshift.io +spec: + group: ocs.openshift.io + names: + kind: StorageClusterPeer + listKind: StorageClusterPeerList + plural: storageclusterpeers + singular: storageclusterpeer + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: Current Phase + jsonPath: .status.phase + name: Phase + type: string + name: v1 + schema: + openAPIV3Schema: + description: StorageClusterPeer is the Schema for the storageclusterpeers + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: StorageClusterPeerSpec defines the desired state of StorageClusterPeer + properties: + ocsApiServerUri: + description: OCSAPIServerURI is the URI of the secondary ocs api server + type: string + type: object + status: + description: StorageClusterPeerStatus defines the observed state of StorageClusterPeer + properties: + phase: + description: Phase describes the Phase of StorageClusterPeer This + is used by OLM UI to provide status information to the user + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/manifests/ocs-operator/bases/ocs-operator.clusterserviceversion.yaml b/config/manifests/ocs-operator/bases/ocs-operator.clusterserviceversion.yaml index 074c0cd942..1b7fb433b4 100644 --- a/config/manifests/ocs-operator/bases/ocs-operator.clusterserviceversion.yaml +++ b/config/manifests/ocs-operator/bases/ocs-operator.clusterserviceversion.yaml @@ -21,6 +21,11 @@ spec: kind: OCSInitialization name: ocsinitializations.ocs.openshift.io version: v1 + - description: StorageClusterPeer is the Schema for the storageclusterpeers API + displayName: Storage Cluster Peer + kind: StorageClusterPeer + name: storageclusterpeers.ocs.openshift.io + version: v1 - description: StorageCluster represents a cluster including Ceph Cluster, NooBaa and all the storage and compute resources required. displayName: Storage Cluster diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index a1acafd520..dfc199ec12 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -227,6 +227,32 @@ rules: - patch - update - watch +- apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/finalizers + verbs: + - update +- apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/status + verbs: + - get + - patch + - update - apiGroups: - ocs.openshift.io resources: diff --git a/deploy/csv-templates/crds/ocs/ocs.openshift.io_storageclusterpeers.yaml b/deploy/csv-templates/crds/ocs/ocs.openshift.io_storageclusterpeers.yaml new file mode 100644 index 0000000000..576e0b1eb1 --- /dev/null +++ b/deploy/csv-templates/crds/ocs/ocs.openshift.io_storageclusterpeers.yaml @@ -0,0 +1,63 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.2 + creationTimestamp: null + name: storageclusterpeers.ocs.openshift.io +spec: + group: ocs.openshift.io + names: + kind: StorageClusterPeer + listKind: StorageClusterPeerList + plural: storageclusterpeers + singular: storageclusterpeer + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: Current Phase + jsonPath: .status.phase + name: Phase + type: string + name: v1 + schema: + openAPIV3Schema: + description: StorageClusterPeer is the Schema for the storageclusterpeers + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: StorageClusterPeerSpec defines the desired state of StorageClusterPeer + properties: + ocsApiServerUri: + description: OCSAPIServerURI is the URI of the secondary ocs api server + type: string + type: object + status: + description: StorageClusterPeerStatus defines the observed state of StorageClusterPeer + properties: + phase: + description: Phase describes the Phase of StorageClusterPeer This + is used by OLM UI to provide status information to the user + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/deploy/csv-templates/ocs-operator.csv.yaml.in b/deploy/csv-templates/ocs-operator.csv.yaml.in index 777ebb4570..5943df2acc 100644 --- a/deploy/csv-templates/ocs-operator.csv.yaml.in +++ b/deploy/csv-templates/ocs-operator.csv.yaml.in @@ -59,6 +59,17 @@ metadata: ] } }, + { + "apiVersion": "ocs.openshift.io/v1", + "kind": "StorageClusterPeer", + "metadata": { + "labels": null, + "name": "storageclusterpeer-sample" + }, + "spec": { + "ocsApiServerUri": "10.0.0.0:31659" + } + }, { "apiVersion": "ocs.openshift.io/v1", "kind": "StorageProfile", @@ -96,6 +107,11 @@ spec: kind: OCSInitialization name: ocsinitializations.ocs.openshift.io version: v1 + - description: StorageClusterPeer is the Schema for the storageclusterpeers API + displayName: Storage Cluster Peer + kind: StorageClusterPeer + name: storageclusterpeers.ocs.openshift.io + version: v1 - description: StorageCluster represents a cluster including Ceph Cluster, NooBaa and all the storage and compute resources required. displayName: Storage Cluster @@ -380,6 +396,32 @@ spec: - patch - update - watch + - apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/finalizers + verbs: + - update + - apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/status + verbs: + - get + - patch + - update - apiGroups: - ocs.openshift.io resources: diff --git a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml index eedb152cca..694817bdad 100644 --- a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml +++ b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml @@ -94,7 +94,7 @@ metadata: operatorframework.io/suggested-namespace: openshift-storage operators.openshift.io/infrastructure-features: '["disconnected"]' operators.operatorframework.io/builder: operator-sdk-v1.25.4 - operators.operatorframework.io/internal-objects: '["ocsinitializations.ocs.openshift.io","storageconsumers.ocs.openshift.io","storageprofiles.ocs.openshift.io","storagerequests.ocs.openshift.io"]' + operators.operatorframework.io/internal-objects: '["ocsinitializations.ocs.openshift.io","storageclusterpeers.ocs.openshift.io","storageconsumers.ocs.openshift.io","storageprofiles.ocs.openshift.io","storagerequests.ocs.openshift.io"]' operators.operatorframework.io/operator-type: non-standalone operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/red-hat-storage/ocs-operator @@ -117,6 +117,11 @@ spec: kind: OCSInitialization name: ocsinitializations.ocs.openshift.io version: v1 + - description: StorageClusterPeer is the Schema for the storageclusterpeers API + displayName: Storage Cluster Peer + kind: StorageClusterPeer + name: storageclusterpeers.ocs.openshift.io + version: v1 - description: StorageCluster represents a cluster including Ceph Cluster, NooBaa and all the storage and compute resources required. displayName: Storage Cluster @@ -401,6 +406,32 @@ spec: - patch - update - watch + - apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/finalizers + verbs: + - update + - apiGroups: + - ocs.openshift.io + resources: + - storageclusterpeers/status + verbs: + - get + - patch + - update - apiGroups: - ocs.openshift.io resources: diff --git a/deploy/ocs-operator/manifests/storageclusterpeer.crd.yaml b/deploy/ocs-operator/manifests/storageclusterpeer.crd.yaml new file mode 100644 index 0000000000..2a42669e0a --- /dev/null +++ b/deploy/ocs-operator/manifests/storageclusterpeer.crd.yaml @@ -0,0 +1,62 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.2 + name: storageclusterpeers.ocs.openshift.io +spec: + group: ocs.openshift.io + names: + kind: StorageClusterPeer + listKind: StorageClusterPeerList + plural: storageclusterpeers + singular: storageclusterpeer + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: Current Phase + jsonPath: .status.phase + name: Phase + type: string + name: v1 + schema: + openAPIV3Schema: + description: StorageClusterPeer is the Schema for the storageclusterpeers + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: StorageClusterPeerSpec defines the desired state of StorageClusterPeer + properties: + ocsApiServerUri: + description: OCSAPIServerURI is the URI of the secondary ocs api server + type: string + type: object + status: + description: StorageClusterPeerStatus defines the observed state of StorageClusterPeer + properties: + phase: + description: Phase describes the Phase of StorageClusterPeer This + is used by OLM UI to provide status information to the user + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go index af76991754..0bd23f33b4 100644 --- a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go +++ b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go @@ -44,6 +44,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &OCSInitialization{}, &OCSInitializationList{}, &StorageCluster{}, &StorageClusterList{}, &StorageProfile{}, &StorageProfileList{}, + &StorageClusterPeer{}, &StorageClusterPeerList{}, ) metav1.AddToGroupVersion(scheme, GroupVersion) return nil diff --git a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go new file mode 100644 index 0000000000..a7eb66ec39 --- /dev/null +++ b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go @@ -0,0 +1,88 @@ +/* +Copyright 2020 Red Hat OpenShift Container Storage. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +type StorageClusterPeerState string + +const ( + // StorageClusterPeerInitializing represents Initializing state of StorageClusterPeerState + StorageClusterPeerInitializing StorageClusterPeerState = "Initializing" + // StorageClusterPeerValidating represents Validating state of StorageClusterPeerState + StorageClusterPeerValidating StorageClusterPeerState = "Validating" + // StorageClusterPeerFailed represents Failed state of StorageClusterPeerState + StorageClusterPeerFailed StorageClusterPeerState = "Failed" + // StorageClusterPeerCreating represents Configuring state of StorageClusterPeerState + StorageClusterPeerCreating StorageClusterPeerState = "Creating" + // StorageClusterPeerConfiguring represents Configuring state of StorageClusterPeerState + StorageClusterPeerConfiguring StorageClusterPeerState = "Configuring" + // StorageClusterPeerReady represents Ready state of StorageClusterPeerState + StorageClusterPeerReady StorageClusterPeerState = "Ready" + // StorageClusterPeerDeleting represents Deleting state of StorageClusterPeerState + StorageClusterPeerDeleting StorageClusterPeerState = "Deleting" +) + +const ( + StorageClusterPeerFinalizer = "storageclusterpeer.ocs.openshift.io" +) + +// StorageClusterPeerSpec defines the desired state of StorageClusterPeer +type StorageClusterPeerSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // OCSAPIServerURI is the URI of the secondary ocs api server + OCSAPIServerURI string `json:"ocsApiServerUri,omitempty"` +} + +// StorageClusterPeerStatus defines the observed state of StorageClusterPeer +type StorageClusterPeerStatus struct { + + // Phase describes the Phase of StorageClusterPeer + // This is used by OLM UI to provide status information to the user + Phase StorageClusterPeerState `json:"phase,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=.metadata.creationTimestamp +//+kubebuilder:printcolumn:name="Phase",type=string,JSONPath=.status.phase,description="Current Phase" +//+operator-sdk:csv:customresourcedefinitions:displayName="Storage Cluster Peer" + +// StorageClusterPeer is the Schema for the storageclusterpeers API +type StorageClusterPeer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec StorageClusterPeerSpec `json:"spec,omitempty"` + Status StorageClusterPeerStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// StorageClusterPeerList contains a list of StorageClusterPeer +type StorageClusterPeerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []StorageClusterPeer `json:"items"` +} diff --git a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go index 14a373a70c..6e035928e3 100644 --- a/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go +++ b/metrics/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go @@ -801,6 +801,95 @@ func (in *StorageClusterList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeer) DeepCopyInto(out *StorageClusterPeer) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeer. +func (in *StorageClusterPeer) DeepCopy() *StorageClusterPeer { + if in == nil { + return nil + } + out := new(StorageClusterPeer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageClusterPeer) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerList) DeepCopyInto(out *StorageClusterPeerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]StorageClusterPeer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerList. +func (in *StorageClusterPeerList) DeepCopy() *StorageClusterPeerList { + if in == nil { + return nil + } + out := new(StorageClusterPeerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageClusterPeerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerSpec) DeepCopyInto(out *StorageClusterPeerSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerSpec. +func (in *StorageClusterPeerSpec) DeepCopy() *StorageClusterPeerSpec { + if in == nil { + return nil + } + out := new(StorageClusterPeerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerStatus) DeepCopyInto(out *StorageClusterPeerStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerStatus. +func (in *StorageClusterPeerStatus) DeepCopy() *StorageClusterPeerStatus { + if in == nil { + return nil + } + out := new(StorageClusterPeerStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageClusterSpec) DeepCopyInto(out *StorageClusterSpec) { *out = *in diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go index af76991754..0bd23f33b4 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/groupversion_info.go @@ -44,6 +44,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &OCSInitialization{}, &OCSInitializationList{}, &StorageCluster{}, &StorageClusterList{}, &StorageProfile{}, &StorageProfileList{}, + &StorageClusterPeer{}, &StorageClusterPeerList{}, ) metav1.AddToGroupVersion(scheme, GroupVersion) return nil diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go new file mode 100644 index 0000000000..a7eb66ec39 --- /dev/null +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/storageclusterpeer_types.go @@ -0,0 +1,88 @@ +/* +Copyright 2020 Red Hat OpenShift Container Storage. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +type StorageClusterPeerState string + +const ( + // StorageClusterPeerInitializing represents Initializing state of StorageClusterPeerState + StorageClusterPeerInitializing StorageClusterPeerState = "Initializing" + // StorageClusterPeerValidating represents Validating state of StorageClusterPeerState + StorageClusterPeerValidating StorageClusterPeerState = "Validating" + // StorageClusterPeerFailed represents Failed state of StorageClusterPeerState + StorageClusterPeerFailed StorageClusterPeerState = "Failed" + // StorageClusterPeerCreating represents Configuring state of StorageClusterPeerState + StorageClusterPeerCreating StorageClusterPeerState = "Creating" + // StorageClusterPeerConfiguring represents Configuring state of StorageClusterPeerState + StorageClusterPeerConfiguring StorageClusterPeerState = "Configuring" + // StorageClusterPeerReady represents Ready state of StorageClusterPeerState + StorageClusterPeerReady StorageClusterPeerState = "Ready" + // StorageClusterPeerDeleting represents Deleting state of StorageClusterPeerState + StorageClusterPeerDeleting StorageClusterPeerState = "Deleting" +) + +const ( + StorageClusterPeerFinalizer = "storageclusterpeer.ocs.openshift.io" +) + +// StorageClusterPeerSpec defines the desired state of StorageClusterPeer +type StorageClusterPeerSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // OCSAPIServerURI is the URI of the secondary ocs api server + OCSAPIServerURI string `json:"ocsApiServerUri,omitempty"` +} + +// StorageClusterPeerStatus defines the observed state of StorageClusterPeer +type StorageClusterPeerStatus struct { + + // Phase describes the Phase of StorageClusterPeer + // This is used by OLM UI to provide status information to the user + Phase StorageClusterPeerState `json:"phase,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=.metadata.creationTimestamp +//+kubebuilder:printcolumn:name="Phase",type=string,JSONPath=.status.phase,description="Current Phase" +//+operator-sdk:csv:customresourcedefinitions:displayName="Storage Cluster Peer" + +// StorageClusterPeer is the Schema for the storageclusterpeers API +type StorageClusterPeer struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec StorageClusterPeerSpec `json:"spec,omitempty"` + Status StorageClusterPeerStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// StorageClusterPeerList contains a list of StorageClusterPeer +type StorageClusterPeerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []StorageClusterPeer `json:"items"` +} diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go index 14a373a70c..6e035928e3 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1/zz_generated.deepcopy.go @@ -801,6 +801,95 @@ func (in *StorageClusterList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeer) DeepCopyInto(out *StorageClusterPeer) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeer. +func (in *StorageClusterPeer) DeepCopy() *StorageClusterPeer { + if in == nil { + return nil + } + out := new(StorageClusterPeer) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageClusterPeer) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerList) DeepCopyInto(out *StorageClusterPeerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]StorageClusterPeer, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerList. +func (in *StorageClusterPeerList) DeepCopy() *StorageClusterPeerList { + if in == nil { + return nil + } + out := new(StorageClusterPeerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *StorageClusterPeerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerSpec) DeepCopyInto(out *StorageClusterPeerSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerSpec. +func (in *StorageClusterPeerSpec) DeepCopy() *StorageClusterPeerSpec { + if in == nil { + return nil + } + out := new(StorageClusterPeerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StorageClusterPeerStatus) DeepCopyInto(out *StorageClusterPeerStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StorageClusterPeerStatus. +func (in *StorageClusterPeerStatus) DeepCopy() *StorageClusterPeerStatus { + if in == nil { + return nil + } + out := new(StorageClusterPeerStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StorageClusterSpec) DeepCopyInto(out *StorageClusterSpec) { *out = *in From e9b03f3dde0d624cc01a1b7e96d6f25e469d5783 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Wed, 28 Feb 2024 17:43:33 +0530 Subject: [PATCH 9/9] storageclusterpeer: setup the reconciler Signed-off-by: Rewant Soni --- config/rbac/role.yaml | 14 + .../storageclusterpeer_controller.go | 278 +++++++++++++++++- deploy/csv-templates/ocs-operator.csv.yaml.in | 14 + .../ocs-operator.clusterserviceversion.yaml | 14 + main.go | 4 +- 5 files changed, 312 insertions(+), 12 deletions(-) diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index dfc199ec12..0e5d58e046 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -60,6 +60,14 @@ rules: - cephrbdmirrors verbs: - '*' +- apiGroups: + - ceph.rook.io + resources: + - cephblockpools + verbs: + - create + - list + - update - apiGroups: - ceph.rook.io resources: @@ -155,6 +163,12 @@ rules: - get - list - watch +- apiGroups: + - "" + resources: + - secrets + verbs: + - get - apiGroups: - k8s.cni.cncf.io resources: diff --git a/controllers/storageclusterpeer/storageclusterpeer_controller.go b/controllers/storageclusterpeer/storageclusterpeer_controller.go index b6e4d86a08..cff59189a8 100644 --- a/controllers/storageclusterpeer/storageclusterpeer_controller.go +++ b/controllers/storageclusterpeer/storageclusterpeer_controller.go @@ -18,45 +18,301 @@ package storageclusterpeer import ( "context" + "crypto/md5" + "encoding/hex" + "fmt" + "time" + "github.com/go-logr/logr" + ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1" + "github.com/red-hat-storage/ocs-operator/v4/controllers/util" + providerClient "github.com/red-hat-storage/ocs-operator/v4/services/provider/client" + rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + "sigs.k8s.io/controller-runtime/pkg/handler" + ctrllog "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/reconcile" +) - ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1" +const ( + rbdMirrorBootstrapPeerSecretName = "rbdMirrorBootstrapPeerSecretName" ) // StorageClusterPeerReconciler reconciles a StorageClusterPeer object +// nolint:revive type StorageClusterPeerReconciler struct { client.Client Scheme *runtime.Scheme + Log logr.Logger + + ctx context.Context + storageClusterPeer *ocsv1.StorageClusterPeer + cephBlockPoolList *rookCephv1.CephBlockPoolList + clusterID string + ocsClient *providerClient.OCSProviderClient } //+kubebuilder:rbac:groups=ocs.openshift.io,resources=storageclusterpeers,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=ocs.openshift.io,resources=storageclusterpeers/status,verbs=get;update;patch //+kubebuilder:rbac:groups=ocs.openshift.io,resources=storageclusterpeers/finalizers,verbs=update +//+kubebuilder:rbac:groups=ceph.rook.io,resources=cephblockpools;,verbs=list;create;update +//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the StorageClusterPeer object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. // // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile -func (r *StorageClusterPeerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) +func (r *StorageClusterPeerReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) { + + r.ctx = ctrllog.IntoContext(ctx, r.Log) + r.Log.Info("Reconciling StorageClusterPeer.") + + // Fetch the StorageClusterPeer instance + r.storageClusterPeer = &ocsv1.StorageClusterPeer{} + r.storageClusterPeer.Name = request.Name + r.storageClusterPeer.Namespace = request.Namespace + + if err := r.get(r.storageClusterPeer); err != nil { + if errors.IsNotFound(err) { + r.Log.Info("StorageClusterPeer resource not found. Ignoring since object must be deleted.") + return reconcile.Result{}, nil + } + r.Log.Error(err, "Failed to get StorageClusterPeer.") + return reconcile.Result{}, err + } + + r.storageClusterPeer.Status.Phase = ocsv1.StorageClusterPeerInitializing + + r.cephBlockPoolList = &rookCephv1.CephBlockPoolList{} + if err := r.list(r.cephBlockPoolList, client.InNamespace(r.storageClusterPeer.Namespace)); err != nil { + return reconcile.Result{}, err + } + + r.clusterID = util.GetClusterID(r.ctx, r.Client, &r.Log) + if r.clusterID == "" { + err := fmt.Errorf("failed to get clusterID from the ClusterVersion CR") + r.Log.Error(err, "failed to get ClusterVersion of the OCP Cluster") + return reconcile.Result{}, err + } + var err error + + r.ocsClient, err = r.newExternalClient() + if err != nil { + return reconcile.Result{}, err + } + defer r.ocsClient.Close() + + var result reconcile.Result + var reconcileError error + + result, reconcileError = r.reconcilePhases() + + // Apply status changes to the StorageClusterPeer + statusError := r.Client.Status().Update(r.ctx, r.storageClusterPeer) + if statusError != nil { + r.Log.Info("Failed to update StorageClusterPeer status.") + } + + // Reconcile errors have higher priority than status update errors + if reconcileError != nil { + return result, reconcileError + } - // TODO(user): your logic here + if statusError != nil { + return result, statusError + } - return ctrl.Result{}, nil + return result, nil } // SetupWithManager sets up the controller with the Manager. func (r *StorageClusterPeerReconciler) SetupWithManager(mgr ctrl.Manager) error { + + enqueueStorageClusterPeerRequest := handler.EnqueueRequestsFromMapFunc( + func(ctx context.Context, obj client.Object) []reconcile.Request { + // Get the StorageClusterPeer objects + scpList := &ocsv1.StorageClusterPeerList{} + err := r.Client.List(ctx, scpList, &client.ListOptions{Namespace: obj.GetNamespace()}) + if err != nil { + r.Log.Error(err, "Unable to list StorageClusterPeer objects") + return []reconcile.Request{} + } + + // Return name and namespace of the StorageClusterPeers object + request := []reconcile.Request{} + for _, scp := range scpList.Items { + request = append(request, reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: scp.Namespace, + Name: scp.Name, + }, + }) + } + + return request + }, + ) + return ctrl.NewControllerManagedBy(mgr). - For(&ocsv1.StorageClusterPeer{}). + For(&ocsv1.StorageClusterPeer{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). + Watches(&rookCephv1.CephBlockPool{}, enqueueStorageClusterPeerRequest). Complete(r) } + +func (r *StorageClusterPeerReconciler) reconcilePhases() (reconcile.Result, error) { + r.Log.Info("Running StorageClusterPeer controller") + + //marked for deletion + if !r.storageClusterPeer.GetDeletionTimestamp().IsZero() { + r.storageClusterPeer.Status.Phase = ocsv1.StorageClusterPeerDeleting + + if err := r.reconcileRevokeBlockPoolPeering(); err != nil { + return reconcile.Result{}, err + } + + //remove finalizer + if controllerutil.RemoveFinalizer(r.storageClusterPeer, ocsv1.StorageClusterPeerFinalizer) { + r.Log.Info("removing finalizer from the StorageClusterPeer, ", "StorageClusterPeer", r.storageClusterPeer.Name) + + if err := r.update(r.storageClusterPeer); err != nil { + r.Log.Info("Failed to remove finalizer from StorageClusterPeer", "StorageClusterPeer", r.storageClusterPeer.Name) + return reconcile.Result{}, fmt.Errorf("failed to update StorageClusterPeer %q: %v", r.storageClusterPeer.Name, err) + } + } + r.Log.Info("finalizer removed successfully") + return reconcile.Result{}, nil + } + //not marked for deletion + + // add finalizer + if controllerutil.AddFinalizer(r.storageClusterPeer, ocsv1.StorageClusterPeerFinalizer) { + r.storageClusterPeer.Status.Phase = ocsv1.StorageClusterPeerInitializing + r.Log.Info("Finalizer not found for StorageClusterPeer. Adding finalizer.", "StorageClusterPeer", r.storageClusterPeer.Name) + if err := r.update(r.storageClusterPeer); err != nil { + return reconcile.Result{}, fmt.Errorf("failed to update StorageClusterPeer %q: %v", r.storageClusterPeer.Name, err) + } + } + + r.storageClusterPeer.Status.Phase = ocsv1.StorageClusterPeerConfiguring + + if err := r.reconcileLocalBlockPools(); err != nil { + return reconcile.Result{}, err + } + + if err := r.reconcilePeerBlockPools(); err != nil { + return reconcile.Result{}, err + } + + r.storageClusterPeer.Status.Phase = ocsv1.StorageClusterPeerReady + + return reconcile.Result{}, nil +} + +func (r *StorageClusterPeerReconciler) newExternalClient() (*providerClient.OCSProviderClient, error) { + ocsClient, err := providerClient.NewProviderClient(r.ctx, r.storageClusterPeer.Spec.OCSAPIServerURI, time.Second*10) + if err != nil { + return nil, fmt.Errorf("failed to create a new ocs client: %v", err) + } + return ocsClient, nil +} + +func (r *StorageClusterPeerReconciler) reconcileLocalBlockPools() error { + + for _, cephBlockPool := range r.cephBlockPoolList.Items { + + _, err := ctrl.CreateOrUpdate(r.ctx, r.Client, &cephBlockPool, func() error { + cephBlockPool.Spec.Mirroring.Enabled = true + cephBlockPool.Spec.Mirroring.Mode = "image" + return nil + }) + if err != nil { + r.Log.Error(err, "unable to enable mirroring on the cephBlockPool", + "CephBlockPool", klog.KRef(cephBlockPool.Namespace, cephBlockPool.Name)) + return err + } + } + return nil +} + +func (r *StorageClusterPeerReconciler) reconcilePeerBlockPools() error { + + for _, cephBlockPool := range r.cephBlockPoolList.Items { + + if cephBlockPool.Status.Info == nil || cephBlockPool.Status.Info[rbdMirrorBootstrapPeerSecretName] == "" { + r.Log.Info("waiting for bootstrap secret to be generated", + "CephBlockPool", klog.KRef(cephBlockPool.Namespace, cephBlockPool.Name)) + return fmt.Errorf("waiting for bootstrap secret for %s blockpool in %s namespace to be generated", + cephBlockPool.Name, cephBlockPool.Namespace) + } + + secret := &v1.Secret{} + secret.Name = cephBlockPool.Status.Info[rbdMirrorBootstrapPeerSecretName] + secret.Namespace = cephBlockPool.Namespace + + if err := r.get(secret); err != nil { + r.Log.Error(err, "unable to fetch the bootstrap secret for blockPool", + "CephBlockPool", klog.KRef(cephBlockPool.Namespace, cephBlockPool.Name)) + return err + } + + _, err := r.ocsClient.PeerBlockPool(r.ctx, generateSecretName(cephBlockPool.Name, r.clusterID), secret.Data["pool"], secret.Data["token"]) + if err != nil { + return err + } + } + return nil +} + +func (r *StorageClusterPeerReconciler) reconcileRevokeBlockPoolPeering() error { + + for _, cephBlockPool := range r.cephBlockPoolList.Items { + + _, err := r.ocsClient.RevokeBlockPoolPeering(r.ctx, generateSecretName(cephBlockPool.Name, r.clusterID), []byte(cephBlockPool.Name)) + if err != nil { + return err + } + + _, err = ctrl.CreateOrUpdate(r.ctx, r.Client, &cephBlockPool, func() error { + // if bootstrap secret is set then it might be used as a backup for some other cluster + if cephBlockPool.Spec.Mirroring.Peers == nil || len(cephBlockPool.Spec.Mirroring.Peers.SecretNames) == 0 { + cephBlockPool.Spec.Mirroring.Enabled = false + cephBlockPool.Spec.Mirroring.Mode = "" + } + return nil + }) + if err != nil { + r.Log.Error(err, "unable to disable mirroring on the cephBlockPool", + "CephBlockPool", klog.KRef(cephBlockPool.Namespace, cephBlockPool.Name)) + return err + } + } + return nil +} + +func (r *StorageClusterPeerReconciler) get(obj client.Object) error { + key := client.ObjectKeyFromObject(obj) + return r.Client.Get(r.ctx, key, obj) +} + +func (r *StorageClusterPeerReconciler) list(obj client.ObjectList, listOptions ...client.ListOption) error { + return r.Client.List(r.ctx, obj, listOptions...) +} + +func (r *StorageClusterPeerReconciler) update(obj client.Object, opts ...client.UpdateOption) error { + return r.Client.Update(r.ctx, obj, opts...) +} + +func generateSecretName(poolName, clusterID string) string { + md5Sum := md5.Sum([]byte(fmt.Sprintf("%s-%s", poolName, clusterID))) + return fmt.Sprintf("bootstrap-secret-%s", hex.EncodeToString(md5Sum[:16])) +} diff --git a/deploy/csv-templates/ocs-operator.csv.yaml.in b/deploy/csv-templates/ocs-operator.csv.yaml.in index 5943df2acc..9c415083a4 100644 --- a/deploy/csv-templates/ocs-operator.csv.yaml.in +++ b/deploy/csv-templates/ocs-operator.csv.yaml.in @@ -229,6 +229,14 @@ spec: - cephrbdmirrors verbs: - '*' + - apiGroups: + - ceph.rook.io + resources: + - cephblockpools + verbs: + - create + - list + - update - apiGroups: - ceph.rook.io resources: @@ -324,6 +332,12 @@ spec: - get - list - watch + - apiGroups: + - "" + resources: + - secrets + verbs: + - get - apiGroups: - k8s.cni.cncf.io resources: diff --git a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml index 694817bdad..d78784868e 100644 --- a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml +++ b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml @@ -239,6 +239,14 @@ spec: - cephrbdmirrors verbs: - '*' + - apiGroups: + - ceph.rook.io + resources: + - cephblockpools + verbs: + - create + - list + - update - apiGroups: - ceph.rook.io resources: @@ -334,6 +342,12 @@ spec: - get - list - watch + - apiGroups: + - "" + resources: + - secrets + verbs: + - get - apiGroups: - k8s.cni.cncf.io resources: diff --git a/main.go b/main.go index bd63ac9d1b..c496a3cc6c 100644 --- a/main.go +++ b/main.go @@ -64,7 +64,6 @@ import ( apiclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/log/zap" metrics "sigs.k8s.io/controller-runtime/pkg/metrics/server" - // +kubebuilder:scaffold:imports ) @@ -209,13 +208,16 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "StorageRequest") os.Exit(1) } + if err = (&storageclusterpeer.StorageClusterPeerReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), + Log: ctrl.Log.WithName("controllers").WithName("StorageClusterPeer"), }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "StorageClusterPeer") os.Exit(1) } + // +kubebuilder:scaffold:builder // Create OCSInitialization CR if it's not present