From f95af6aa1846ee1cdbdbb907225d486ce2fe792b Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 6 Nov 2024 10:56:53 +0100 Subject: [PATCH 01/10] rebase: update csiaddons spec updating the csiaddons spec dependency to the latest main. Signed-off-by: Madhu Rajanna --- go.mod | 2 +- go.sum | 4 +- .../csi-addons/spec/lib/go/fence/fence.pb.go | 345 +++++++++++++++--- .../spec/lib/go/fence/fence_grpc.pb.go | 41 +++ .../spec/lib/go/identity/identity.pb.go | 142 +++---- .../lib/go/volumegroup/volumegroup_grpc.pb.go | 4 +- vendor/modules.txt | 2 +- 7 files changed, 420 insertions(+), 120 deletions(-) diff --git a/go.mod b/go.mod index 81628b4a8..8c8696b46 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.9 require ( github.com/container-storage-interface/spec v1.10.0 - github.com/csi-addons/spec v0.2.1-0.20240730084235-3958a5b17d24 + github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5 github.com/go-logr/logr v1.4.2 github.com/kubernetes-csi/csi-lib-utils v0.19.0 github.com/onsi/ginkgo/v2 v2.21.0 diff --git a/go.sum b/go.sum index d75642eb1..dca7b8c04 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/container-storage-interface/spec v1.10.0 h1:YkzWPV39x+ZMTa6Ax2czJLLwpryrQ+dPesB34mrRMXA= github.com/container-storage-interface/spec v1.10.0/go.mod h1:DtUvaQszPml1YJfIK7c00mlv6/g4wNMLanLgiUbKFRI= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/csi-addons/spec v0.2.1-0.20240730084235-3958a5b17d24 h1:tJETaYbnnzlCSaqDXQzbszYyuAtG/sFzm6DargeVzJA= -github.com/csi-addons/spec v0.2.1-0.20240730084235-3958a5b17d24/go.mod h1:Mwq4iLiUV4s+K1bszcWU6aMsR5KPsbIYzzszJ6+56vI= +github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5 h1:j9NaWj5KmzEVarmsjxS/NDAhes6Uzq1qhkUGHvDlVBk= +github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5/go.mod h1:Mwq4iLiUV4s+K1bszcWU6aMsR5KPsbIYzzszJ6+56vI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= diff --git a/vendor/github.com/csi-addons/spec/lib/go/fence/fence.pb.go b/vendor/github.com/csi-addons/spec/lib/go/fence/fence.pb.go index a1cf68475..54915db24 100644 --- a/vendor/github.com/csi-addons/spec/lib/go/fence/fence.pb.go +++ b/vendor/github.com/csi-addons/spec/lib/go/fence/fence.pb.go @@ -402,6 +402,175 @@ func (x *CIDR) GetCidr() string { return "" } +// GetFenceClientsRequest contains the necessary information to identify +// the clients that need fencing. +type GetFenceClientsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Plugin-specific parameters passed in as opaque key-value pairs. + Parameters map[string]string `protobuf:"bytes,1,rep,name=parameters,proto3" json:"parameters,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Secrets required by the plugin to complete the request. + Secrets map[string]string `protobuf:"bytes,2,rep,name=secrets,proto3" json:"secrets,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *GetFenceClientsRequest) Reset() { + *x = GetFenceClientsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_fence_fence_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetFenceClientsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFenceClientsRequest) ProtoMessage() {} + +func (x *GetFenceClientsRequest) ProtoReflect() protoreflect.Message { + mi := &file_fence_fence_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetFenceClientsRequest.ProtoReflect.Descriptor instead. +func (*GetFenceClientsRequest) Descriptor() ([]byte, []int) { + return file_fence_fence_proto_rawDescGZIP(), []int{7} +} + +func (x *GetFenceClientsRequest) GetParameters() map[string]string { + if x != nil { + return x.Parameters + } + return nil +} + +func (x *GetFenceClientsRequest) GetSecrets() map[string]string { + if x != nil { + return x.Secrets + } + return nil +} + +// GetFenceClientsResponse holds the information about clients that require +// fencing. +type GetFenceClientsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // List of clients that need to be fenced. + Clients []*ClientDetails `protobuf:"bytes,1,rep,name=clients,proto3" json:"clients,omitempty"` +} + +func (x *GetFenceClientsResponse) Reset() { + *x = GetFenceClientsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_fence_fence_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetFenceClientsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetFenceClientsResponse) ProtoMessage() {} + +func (x *GetFenceClientsResponse) ProtoReflect() protoreflect.Message { + mi := &file_fence_fence_proto_msgTypes[8] + 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 GetFenceClientsResponse.ProtoReflect.Descriptor instead. +func (*GetFenceClientsResponse) Descriptor() ([]byte, []int) { + return file_fence_fence_proto_rawDescGZIP(), []int{8} +} + +func (x *GetFenceClientsResponse) GetClients() []*ClientDetails { + if x != nil { + return x.Clients + } + return nil +} + +// ClientDetails holds the information about the client that requires fencing. +type ClientDetails struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // id represents the unique identifier of the client. + // Required field. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // list of IP addresses that represent the client's local addresses. + // Required field. + Addresses []*CIDR `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses,omitempty"` +} + +func (x *ClientDetails) Reset() { + *x = ClientDetails{} + if protoimpl.UnsafeEnabled { + mi := &file_fence_fence_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClientDetails) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientDetails) ProtoMessage() {} + +func (x *ClientDetails) ProtoReflect() protoreflect.Message { + mi := &file_fence_fence_proto_msgTypes[9] + 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 ClientDetails.ProtoReflect.Descriptor instead. +func (*ClientDetails) Descriptor() ([]byte, []int) { + return file_fence_fence_proto_rawDescGZIP(), []int{9} +} + +func (x *ClientDetails) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ClientDetails) GetAddresses() []*CIDR { + if x != nil { + return x.Addresses + } + return nil +} + var File_fence_fence_proto protoreflect.FileDescriptor var file_fence_fence_proto_rawDesc = []byte{ @@ -486,29 +655,62 @@ var file_fence_fence_proto_rawDesc = []byte{ 0x32, 0x0b, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x52, 0x05, 0x63, 0x69, 0x64, 0x72, 0x73, 0x22, 0x1a, 0x0a, 0x04, 0x43, 0x49, 0x44, 0x52, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, - 0x32, 0xae, 0x02, 0x0a, 0x0f, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x5e, 0x0a, 0x13, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x21, 0x2e, 0x66, 0x65, - 0x6e, 0x63, 0x65, 0x2e, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, - 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, 0x15, 0x55, 0x6e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x43, - 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x23, 0x2e, - 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x55, 0x6e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x55, 0x6e, 0x66, 0x65, 0x6e, - 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x55, 0x0a, 0x10, 0x4c, 0x69, - 0x73, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1e, - 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, - 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x73, 0x69, 0x2d, 0x61, 0x64, 0x64, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, - 0x6c, 0x69, 0x62, 0x2f, 0x67, 0x6f, 0x2f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0xad, 0x02, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4d, 0x0a, 0x0a, 0x70, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2d, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x65, 0x6e, 0x63, 0x65, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x49, 0x0a, 0x07, 0x73, 0x65, + 0x63, 0x72, 0x65, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x66, 0x65, + 0x6e, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x53, 0x65, 0x63, 0x72, 0x65, + 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x03, 0x98, 0x42, 0x01, 0x52, 0x07, 0x73, 0x65, + 0x63, 0x72, 0x65, 0x74, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3a, 0x0a, 0x0c, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x49, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x66, + 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x73, 0x52, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x4a, 0x0a, 0x0d, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x29, 0x0a, 0x09, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0b, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x52, 0x09, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x32, 0x82, 0x03, 0x0a, 0x0f, 0x46, 0x65, 0x6e, 0x63, + 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x5e, 0x0a, 0x13, 0x46, + 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x12, 0x21, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x46, 0x65, 0x6e, 0x63, 0x65, + 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x46, 0x65, + 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x64, 0x0a, 0x15, 0x55, + 0x6e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x23, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x55, 0x6e, 0x66, + 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x66, 0x65, 0x6e, 0x63, + 0x65, 0x2e, 0x55, 0x6e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x55, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x46, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x4c, 0x69, + 0x73, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x46, + 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x2e, 0x66, 0x65, + 0x6e, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x66, 0x65, 0x6e, + 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x29, 0x5a, 0x27, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x73, 0x69, 0x2d, 0x61, + 0x64, 0x64, 0x6f, 0x6e, 0x73, 0x2f, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x67, + 0x6f, 0x2f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -523,7 +725,7 @@ func file_fence_fence_proto_rawDescGZIP() []byte { return file_fence_fence_proto_rawDescData } -var file_fence_fence_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_fence_fence_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_fence_fence_proto_goTypes = []interface{}{ (*FenceClusterNetworkRequest)(nil), // 0: fence.FenceClusterNetworkRequest (*FenceClusterNetworkResponse)(nil), // 1: fence.FenceClusterNetworkResponse @@ -532,34 +734,45 @@ var file_fence_fence_proto_goTypes = []interface{}{ (*ListClusterFenceRequest)(nil), // 4: fence.ListClusterFenceRequest (*ListClusterFenceResponse)(nil), // 5: fence.ListClusterFenceResponse (*CIDR)(nil), // 6: fence.CIDR - nil, // 7: fence.FenceClusterNetworkRequest.ParametersEntry - nil, // 8: fence.FenceClusterNetworkRequest.SecretsEntry - nil, // 9: fence.UnfenceClusterNetworkRequest.ParametersEntry - nil, // 10: fence.UnfenceClusterNetworkRequest.SecretsEntry - nil, // 11: fence.ListClusterFenceRequest.ParametersEntry - nil, // 12: fence.ListClusterFenceRequest.SecretsEntry + (*GetFenceClientsRequest)(nil), // 7: fence.GetFenceClientsRequest + (*GetFenceClientsResponse)(nil), // 8: fence.GetFenceClientsResponse + (*ClientDetails)(nil), // 9: fence.ClientDetails + nil, // 10: fence.FenceClusterNetworkRequest.ParametersEntry + nil, // 11: fence.FenceClusterNetworkRequest.SecretsEntry + nil, // 12: fence.UnfenceClusterNetworkRequest.ParametersEntry + nil, // 13: fence.UnfenceClusterNetworkRequest.SecretsEntry + nil, // 14: fence.ListClusterFenceRequest.ParametersEntry + nil, // 15: fence.ListClusterFenceRequest.SecretsEntry + nil, // 16: fence.GetFenceClientsRequest.ParametersEntry + nil, // 17: fence.GetFenceClientsRequest.SecretsEntry } var file_fence_fence_proto_depIdxs = []int32{ - 7, // 0: fence.FenceClusterNetworkRequest.parameters:type_name -> fence.FenceClusterNetworkRequest.ParametersEntry - 8, // 1: fence.FenceClusterNetworkRequest.secrets:type_name -> fence.FenceClusterNetworkRequest.SecretsEntry + 10, // 0: fence.FenceClusterNetworkRequest.parameters:type_name -> fence.FenceClusterNetworkRequest.ParametersEntry + 11, // 1: fence.FenceClusterNetworkRequest.secrets:type_name -> fence.FenceClusterNetworkRequest.SecretsEntry 6, // 2: fence.FenceClusterNetworkRequest.cidrs:type_name -> fence.CIDR - 9, // 3: fence.UnfenceClusterNetworkRequest.parameters:type_name -> fence.UnfenceClusterNetworkRequest.ParametersEntry - 10, // 4: fence.UnfenceClusterNetworkRequest.secrets:type_name -> fence.UnfenceClusterNetworkRequest.SecretsEntry + 12, // 3: fence.UnfenceClusterNetworkRequest.parameters:type_name -> fence.UnfenceClusterNetworkRequest.ParametersEntry + 13, // 4: fence.UnfenceClusterNetworkRequest.secrets:type_name -> fence.UnfenceClusterNetworkRequest.SecretsEntry 6, // 5: fence.UnfenceClusterNetworkRequest.cidrs:type_name -> fence.CIDR - 11, // 6: fence.ListClusterFenceRequest.parameters:type_name -> fence.ListClusterFenceRequest.ParametersEntry - 12, // 7: fence.ListClusterFenceRequest.secrets:type_name -> fence.ListClusterFenceRequest.SecretsEntry + 14, // 6: fence.ListClusterFenceRequest.parameters:type_name -> fence.ListClusterFenceRequest.ParametersEntry + 15, // 7: fence.ListClusterFenceRequest.secrets:type_name -> fence.ListClusterFenceRequest.SecretsEntry 6, // 8: fence.ListClusterFenceResponse.cidrs:type_name -> fence.CIDR - 0, // 9: fence.FenceController.FenceClusterNetwork:input_type -> fence.FenceClusterNetworkRequest - 2, // 10: fence.FenceController.UnfenceClusterNetwork:input_type -> fence.UnfenceClusterNetworkRequest - 4, // 11: fence.FenceController.ListClusterFence:input_type -> fence.ListClusterFenceRequest - 1, // 12: fence.FenceController.FenceClusterNetwork:output_type -> fence.FenceClusterNetworkResponse - 3, // 13: fence.FenceController.UnfenceClusterNetwork:output_type -> fence.UnfenceClusterNetworkResponse - 5, // 14: fence.FenceController.ListClusterFence:output_type -> fence.ListClusterFenceResponse - 12, // [12:15] is the sub-list for method output_type - 9, // [9:12] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 16, // 9: fence.GetFenceClientsRequest.parameters:type_name -> fence.GetFenceClientsRequest.ParametersEntry + 17, // 10: fence.GetFenceClientsRequest.secrets:type_name -> fence.GetFenceClientsRequest.SecretsEntry + 9, // 11: fence.GetFenceClientsResponse.clients:type_name -> fence.ClientDetails + 6, // 12: fence.ClientDetails.addresses:type_name -> fence.CIDR + 0, // 13: fence.FenceController.FenceClusterNetwork:input_type -> fence.FenceClusterNetworkRequest + 2, // 14: fence.FenceController.UnfenceClusterNetwork:input_type -> fence.UnfenceClusterNetworkRequest + 4, // 15: fence.FenceController.ListClusterFence:input_type -> fence.ListClusterFenceRequest + 7, // 16: fence.FenceController.GetFenceClients:input_type -> fence.GetFenceClientsRequest + 1, // 17: fence.FenceController.FenceClusterNetwork:output_type -> fence.FenceClusterNetworkResponse + 3, // 18: fence.FenceController.UnfenceClusterNetwork:output_type -> fence.UnfenceClusterNetworkResponse + 5, // 19: fence.FenceController.ListClusterFence:output_type -> fence.ListClusterFenceResponse + 8, // 20: fence.FenceController.GetFenceClients:output_type -> fence.GetFenceClientsResponse + 17, // [17:21] is the sub-list for method output_type + 13, // [13:17] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_fence_fence_proto_init() } @@ -652,6 +865,42 @@ func file_fence_fence_proto_init() { return nil } } + file_fence_fence_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetFenceClientsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_fence_fence_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetFenceClientsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_fence_fence_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClientDetails); 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{ @@ -659,7 +908,7 @@ func file_fence_fence_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_fence_fence_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 18, NumExtensions: 0, NumServices: 1, }, diff --git a/vendor/github.com/csi-addons/spec/lib/go/fence/fence_grpc.pb.go b/vendor/github.com/csi-addons/spec/lib/go/fence/fence_grpc.pb.go index 87043d2ed..1652e235f 100644 --- a/vendor/github.com/csi-addons/spec/lib/go/fence/fence_grpc.pb.go +++ b/vendor/github.com/csi-addons/spec/lib/go/fence/fence_grpc.pb.go @@ -24,6 +24,7 @@ const ( FenceController_FenceClusterNetwork_FullMethodName = "/fence.FenceController/FenceClusterNetwork" FenceController_UnfenceClusterNetwork_FullMethodName = "/fence.FenceController/UnfenceClusterNetwork" FenceController_ListClusterFence_FullMethodName = "/fence.FenceController/ListClusterFence" + FenceController_GetFenceClients_FullMethodName = "/fence.FenceController/GetFenceClients" ) // FenceControllerClient is the client API for FenceController service. @@ -37,6 +38,9 @@ type FenceControllerClient interface { UnfenceClusterNetwork(ctx context.Context, in *UnfenceClusterNetworkRequest, opts ...grpc.CallOption) (*UnfenceClusterNetworkResponse, error) // ListClusterFence RPC call to provide a list of blocklisted/fenced clients. ListClusterFence(ctx context.Context, in *ListClusterFenceRequest, opts ...grpc.CallOption) (*ListClusterFenceResponse, error) + // GetFenceClients RPC calls to get the client information to use in a + // FenceClusterNetwork or UnfenceClusterNetwork RPC. + GetFenceClients(ctx context.Context, in *GetFenceClientsRequest, opts ...grpc.CallOption) (*GetFenceClientsResponse, error) } type fenceControllerClient struct { @@ -74,6 +78,15 @@ func (c *fenceControllerClient) ListClusterFence(ctx context.Context, in *ListCl return out, nil } +func (c *fenceControllerClient) GetFenceClients(ctx context.Context, in *GetFenceClientsRequest, opts ...grpc.CallOption) (*GetFenceClientsResponse, error) { + out := new(GetFenceClientsResponse) + err := c.cc.Invoke(ctx, FenceController_GetFenceClients_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // FenceControllerServer is the server API for FenceController service. // All implementations must embed UnimplementedFenceControllerServer // for forward compatibility @@ -85,6 +98,9 @@ type FenceControllerServer interface { UnfenceClusterNetwork(context.Context, *UnfenceClusterNetworkRequest) (*UnfenceClusterNetworkResponse, error) // ListClusterFence RPC call to provide a list of blocklisted/fenced clients. ListClusterFence(context.Context, *ListClusterFenceRequest) (*ListClusterFenceResponse, error) + // GetFenceClients RPC calls to get the client information to use in a + // FenceClusterNetwork or UnfenceClusterNetwork RPC. + GetFenceClients(context.Context, *GetFenceClientsRequest) (*GetFenceClientsResponse, error) mustEmbedUnimplementedFenceControllerServer() } @@ -101,6 +117,9 @@ func (UnimplementedFenceControllerServer) UnfenceClusterNetwork(context.Context, func (UnimplementedFenceControllerServer) ListClusterFence(context.Context, *ListClusterFenceRequest) (*ListClusterFenceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListClusterFence not implemented") } +func (UnimplementedFenceControllerServer) GetFenceClients(context.Context, *GetFenceClientsRequest) (*GetFenceClientsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetFenceClients not implemented") +} func (UnimplementedFenceControllerServer) mustEmbedUnimplementedFenceControllerServer() {} // UnsafeFenceControllerServer may be embedded to opt out of forward compatibility for this service. @@ -168,6 +187,24 @@ func _FenceController_ListClusterFence_Handler(srv interface{}, ctx context.Cont return interceptor(ctx, in, info, handler) } +func _FenceController_GetFenceClients_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetFenceClientsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FenceControllerServer).GetFenceClients(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: FenceController_GetFenceClients_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FenceControllerServer).GetFenceClients(ctx, req.(*GetFenceClientsRequest)) + } + return interceptor(ctx, in, info, handler) +} + // FenceController_ServiceDesc is the grpc.ServiceDesc for FenceController service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -187,6 +224,10 @@ var FenceController_ServiceDesc = grpc.ServiceDesc{ MethodName: "ListClusterFence", Handler: _FenceController_ListClusterFence_Handler, }, + { + MethodName: "GetFenceClients", + Handler: _FenceController_GetFenceClients_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "fence/fence.proto", diff --git a/vendor/github.com/csi-addons/spec/lib/go/identity/identity.pb.go b/vendor/github.com/csi-addons/spec/lib/go/identity/identity.pb.go index bc102c7c2..fac79ee5d 100644 --- a/vendor/github.com/csi-addons/spec/lib/go/identity/identity.pb.go +++ b/vendor/github.com/csi-addons/spec/lib/go/identity/identity.pb.go @@ -165,6 +165,12 @@ const ( // plugin can invoke RPCs that require access to the storage system, // similar to the CSI Controller (provisioner). Capability_NetworkFence_NETWORK_FENCE Capability_NetworkFence_Type = 1 + // GET_CLIENTS_TO_FENCE indicates that the CSI-driver provides RPCs for a + // GET_CLIENTS_TO_FENCE operation to get the clients to fence. + // The presence of this capability determines whether the CSI-Addons CO + // plugin can invoke RPCs that require access to the storage system, + // similar to the CSI Controller (provisioner). + Capability_NetworkFence_GET_CLIENTS_TO_FENCE Capability_NetworkFence_Type = 2 ) // Enum value maps for Capability_NetworkFence_Type. @@ -172,10 +178,12 @@ var ( Capability_NetworkFence_Type_name = map[int32]string{ 0: "UNKNOWN", 1: "NETWORK_FENCE", + 2: "GET_CLIENTS_TO_FENCE", } Capability_NetworkFence_Type_value = map[string]int32{ - "UNKNOWN": 0, - "NETWORK_FENCE": 1, + "UNKNOWN": 0, + "NETWORK_FENCE": 1, + "GET_CLIENTS_TO_FENCE": 2, } ) @@ -1183,7 +1191,7 @@ var file_identity_identity_proto_rawDesc = []byte{ 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, - 0x73, 0x22, 0xf1, 0x0a, 0x0a, 0x0a, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x73, 0x22, 0x8c, 0x0b, 0x0a, 0x0a, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x38, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x48, @@ -1229,69 +1237,71 @@ var file_identity_identity_proto_rawDesc = []byte{ 0x65, 0x22, 0x2c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x46, 0x46, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4f, 0x4e, 0x4c, 0x49, 0x4e, 0x45, 0x10, 0x02, 0x1a, - 0x72, 0x0a, 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x12, - 0x3a, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, - 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, - 0x69, 0x74, 0x79, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, - 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x26, 0x0a, 0x04, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, - 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x46, 0x45, 0x4e, 0x43, - 0x45, 0x10, 0x01, 0x1a, 0x81, 0x01, 0x0a, 0x11, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2b, 0x0a, 0x04, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, - 0x16, 0x0a, 0x12, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x52, 0x45, 0x50, 0x4c, 0x49, 0x43, - 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x1a, 0x84, 0x02, 0x0a, 0x0b, 0x56, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x39, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x22, 0xb9, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x56, 0x4f, 0x4c, 0x55, - 0x4d, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x01, 0x12, 0x24, 0x0a, 0x20, 0x4c, 0x49, - 0x4d, 0x49, 0x54, 0x5f, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x54, 0x4f, 0x5f, 0x4f, 0x4e, - 0x45, 0x5f, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x02, - 0x12, 0x25, 0x0a, 0x21, 0x44, 0x4f, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, - 0x5f, 0x56, 0x47, 0x5f, 0x54, 0x4f, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x5f, 0x56, 0x4f, - 0x4c, 0x55, 0x4d, 0x45, 0x53, 0x10, 0x03, 0x12, 0x17, 0x0a, 0x13, 0x4d, 0x4f, 0x44, 0x49, 0x46, - 0x59, 0x5f, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x04, - 0x12, 0x14, 0x0a, 0x10, 0x47, 0x45, 0x54, 0x5f, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x47, - 0x52, 0x4f, 0x55, 0x50, 0x10, 0x05, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x49, 0x53, 0x54, 0x5f, 0x56, - 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x53, 0x10, 0x06, 0x1a, 0x8c, - 0x01, 0x0a, 0x15, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, - 0x52, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2f, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x45, 0x6e, 0x63, - 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2e, 0x0a, - 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, - 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x45, 0x4e, 0x43, 0x52, 0x59, 0x50, 0x54, 0x49, 0x4f, 0x4e, - 0x4b, 0x45, 0x59, 0x52, 0x4f, 0x54, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x42, 0x06, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x41, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, - 0x65, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x32, 0xee, 0x01, 0x0a, 0x08, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x4c, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x49, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x74, 0x79, 0x12, 0x1c, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, - 0x47, 0x65, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x47, 0x65, - 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, - 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x74, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, - 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, - 0x05, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x12, 0x16, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, - 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, 0x69, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x8c, 0x01, 0x0a, 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, + 0x12, 0x3a, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, + 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, + 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, + 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x40, 0x0a, 0x04, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, + 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x45, 0x54, 0x57, 0x4f, 0x52, 0x4b, 0x5f, 0x46, 0x45, 0x4e, + 0x43, 0x45, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x47, 0x45, 0x54, 0x5f, 0x43, 0x4c, 0x49, 0x45, + 0x4e, 0x54, 0x53, 0x5f, 0x54, 0x4f, 0x5f, 0x46, 0x45, 0x4e, 0x43, 0x45, 0x10, 0x02, 0x1a, 0x81, + 0x01, 0x0a, 0x11, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x61, + 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, + 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2b, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, + 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x56, 0x4f, + 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x52, 0x45, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, + 0x10, 0x01, 0x1a, 0x84, 0x02, 0x0a, 0x0b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x12, 0x39, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x25, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x61, 0x70, 0x61, + 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xb9, 0x01, + 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, + 0x4e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x47, 0x52, + 0x4f, 0x55, 0x50, 0x10, 0x01, 0x12, 0x24, 0x0a, 0x20, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x5f, 0x56, + 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x54, 0x4f, 0x5f, 0x4f, 0x4e, 0x45, 0x5f, 0x56, 0x4f, 0x4c, + 0x55, 0x4d, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x02, 0x12, 0x25, 0x0a, 0x21, 0x44, + 0x4f, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x56, 0x47, 0x5f, 0x54, + 0x4f, 0x5f, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x5f, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x53, + 0x10, 0x03, 0x12, 0x17, 0x0a, 0x13, 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x59, 0x5f, 0x56, 0x4f, 0x4c, + 0x55, 0x4d, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, 0x04, 0x12, 0x14, 0x0a, 0x10, 0x47, + 0x45, 0x54, 0x5f, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x10, + 0x05, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x49, 0x53, 0x54, 0x5f, 0x56, 0x4f, 0x4c, 0x55, 0x4d, 0x45, + 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x53, 0x10, 0x06, 0x1a, 0x8c, 0x01, 0x0a, 0x15, 0x45, 0x6e, + 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x43, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x2f, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x61, 0x70, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x79, + 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2e, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x19, 0x0a, + 0x15, 0x45, 0x4e, 0x43, 0x52, 0x59, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x4b, 0x45, 0x59, 0x52, 0x4f, + 0x54, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x41, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x30, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x72, 0x65, + 0x61, 0x64, 0x79, 0x32, 0xee, 0x01, 0x0a, 0x08, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x12, 0x4c, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, + 0x1c, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, + 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, + 0x73, 0x12, 0x20, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x47, 0x65, 0x74, + 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x47, + 0x65, 0x74, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x69, 0x65, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x62, + 0x65, 0x12, 0x16, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x50, 0x72, 0x6f, + 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x69, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x3b, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/csi-addons/spec/lib/go/volumegroup/volumegroup_grpc.pb.go b/vendor/github.com/csi-addons/spec/lib/go/volumegroup/volumegroup_grpc.pb.go index d41b597f9..d658ee6f1 100644 --- a/vendor/github.com/csi-addons/spec/lib/go/volumegroup/volumegroup_grpc.pb.go +++ b/vendor/github.com/csi-addons/spec/lib/go/volumegroup/volumegroup_grpc.pb.go @@ -40,7 +40,7 @@ type ControllerClient interface { DeleteVolumeGroup(ctx context.Context, in *DeleteVolumeGroupRequest, opts ...grpc.CallOption) (*DeleteVolumeGroupResponse, error) // ListVolumeGroups RPC call to list volume groups. ListVolumeGroups(ctx context.Context, in *ListVolumeGroupsRequest, opts ...grpc.CallOption) (*ListVolumeGroupsResponse, error) - // CreateVolumeGroup RPC call to get a volume group. + // ControllerGetVolumeGroup RPC call to get a volume group. ControllerGetVolumeGroup(ctx context.Context, in *ControllerGetVolumeGroupRequest, opts ...grpc.CallOption) (*ControllerGetVolumeGroupResponse, error) } @@ -109,7 +109,7 @@ type ControllerServer interface { DeleteVolumeGroup(context.Context, *DeleteVolumeGroupRequest) (*DeleteVolumeGroupResponse, error) // ListVolumeGroups RPC call to list volume groups. ListVolumeGroups(context.Context, *ListVolumeGroupsRequest) (*ListVolumeGroupsResponse, error) - // CreateVolumeGroup RPC call to get a volume group. + // ControllerGetVolumeGroup RPC call to get a volume group. ControllerGetVolumeGroup(context.Context, *ControllerGetVolumeGroupRequest) (*ControllerGetVolumeGroupResponse, error) mustEmbedUnimplementedControllerServer() } diff --git a/vendor/modules.txt b/vendor/modules.txt index af50ebfcd..e9f45acf3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,7 +10,7 @@ github.com/cespare/xxhash/v2 # github.com/container-storage-interface/spec v1.10.0 ## explicit; go 1.18 github.com/container-storage-interface/spec/lib/go/csi -# github.com/csi-addons/spec v0.2.1-0.20240730084235-3958a5b17d24 +# github.com/csi-addons/spec v0.2.1-0.20241104111131-27825f744db5 ## explicit github.com/csi-addons/spec/lib/go/encryptionkeyrotation github.com/csi-addons/spec/lib/go/fence From 023fcf9816c7c85c47592204435dc7b09293527e Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 6 Nov 2024 20:12:11 +0100 Subject: [PATCH 02/10] controller: Implement NetworkFenceClass reconciler Added `NetworkFenceClassReconciler` to manage the reconciliation of `NetworkFenceClass` resources. Fetches `NetworkFenceClass` and lists associated `CSIAddonsNode` objects based on provisioner. Adds or removes labels on csiaddonsnodes with the `NetworkFenceClass` name based on node capabilities and deletion state. Introduced helper functions for label key retrieval and label count management. Set up field indexer for `CSIAddonsNode` to efficiently watch nodes by provisioner/driver name. Signed-off-by: Madhu Rajanna --- .../csiaddons/networkfenceclass_controller.go | 315 +++++++++++++++++- .../networkfenceclass_controller_test.go | 153 +++++---- 2 files changed, 411 insertions(+), 57 deletions(-) diff --git a/internal/controller/csiaddons/networkfenceclass_controller.go b/internal/controller/csiaddons/networkfenceclass_controller.go index e37f05853..7d69e61b4 100644 --- a/internal/controller/csiaddons/networkfenceclass_controller.go +++ b/internal/controller/csiaddons/networkfenceclass_controller.go @@ -18,13 +18,42 @@ package controller import ( "context" + "encoding/json" + stdError "errors" + "fmt" + "slices" + "strings" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" 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/event" + "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/predicate" + "sigs.k8s.io/controller-runtime/pkg/reconcile" csiaddonsv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/csiaddons/v1alpha1" + "github.com/csi-addons/kubernetes-csi-addons/internal/util" + "github.com/go-logr/logr" +) + +const ( + driverName = "spec.driver.name" // FieldIndexer for CSIAddonsNode + provisionerName = "spec.provisioner" // FieldIndexer for NetworkFenceClass + networkFenceClassAnnotationKey = "csiaddons.openshift.io/networkfenceclass-names" + + // NetworkFenceClass Parameters prefixed with networkFenceParameterPrefix are not passed through + // to the driver on RPC calls. Instead these are the parameters used by the + // operator to get the required object from kubernetes and pass it to the + // Driver. + networkFenceParameterPrefix = "csiaddons.openshift.io/" + + prefixedNetworkFenceSecretNameKey = networkFenceParameterPrefix + "networkfence-secret-name" // name key for secret + prefixedNetworkFenceSecretNamespaceKey = networkFenceParameterPrefix + "networkfence-secret-namespace" // namespace key secret ) // NetworkFenceClassReconciler reconciles a NetworkFenceClass object @@ -36,6 +65,7 @@ type NetworkFenceClassReconciler struct { //+kubebuilder:rbac:groups=csiaddons.openshift.io,resources=networkfenceclasses,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=csiaddons.openshift.io,resources=networkfenceclasses/status,verbs=get;update;patch //+kubebuilder:rbac:groups=csiaddons.openshift.io,resources=networkfenceclasses/finalizers,verbs=update +//+kubebuilder:rbac:groups=csiaddons.openshift.io,resources=csiaddonsnodes,verbs=list;watch;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. @@ -47,14 +77,297 @@ type NetworkFenceClassReconciler struct { // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.17.3/pkg/reconcile func (r *NetworkFenceClassReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - _ = log.FromContext(ctx) + logger := log.FromContext(ctx, "Request.Name", req.Name) + + // Fetch NetworkFenceClass instance + instance, err := r.getNetworkFenceClass(ctx, req) + if err != nil { + return ctrl.Result{}, err + } + + // NetworkFenceClass not found + if instance == nil { + return ctrl.Result{}, nil + } + + err = validatePrefixedParameters(instance.Spec.Parameters) + if err != nil { + return ctrl.Result{}, err + } + + nfUnderDeletion := instance.DeletionTimestamp != nil + + if !nfUnderDeletion { + // Add finalizer to NetworkFenceClass + if err := r.addFinalizer(ctx, &logger, instance); err != nil { + return ctrl.Result{}, err + } + } + + // List all relevant CSIAddonsNode objects + csiaddonsNodeList, err := r.listCSIAddonsNodes(ctx, instance.Spec.Provisioner) + if err != nil { + return ctrl.Result{}, err + } + + if csiaddonsNodeList == nil { + return ctrl.Result{}, nil + } + + var errs []string + // Process each CSIAddonsNode + for _, csiaddonsnode := range csiaddonsNodeList.Items { + // skip if the object is being deleted + if csiaddonsnode.DeletionTimestamp == nil { + if err := r.processCSIAddonsNode(ctx, &logger, &csiaddonsnode, instance, nfUnderDeletion); err != nil { + errs = append(errs, fmt.Sprintf("error processing node %s: for NetworkFenceClass %s: %v", csiaddonsnode.Name, instance.Name, err)) + } + } + } + + if len(errs) > 0 { + return ctrl.Result{}, fmt.Errorf("multiple errors occurred: %s", strings.Join(errs, ", ")) + } + + if nfUnderDeletion { + // Remove finalizer to NetworkFenceClass + if err := r.removeFinalizer(ctx, &logger, instance); err != nil { + return ctrl.Result{}, err + } + } return ctrl.Result{}, nil } +// addFinalizer adds finalizer to networkFenceClass if it is not present. +func (r *NetworkFenceClassReconciler) addFinalizer( + ctx context.Context, + logger *logr.Logger, + networkFenceClass *csiaddonsv1alpha1.NetworkFenceClass) error { + + if !slices.Contains(networkFenceClass.Finalizers, csiAddonsNodeFinalizer) { + logger.Info("Adding finalizer") + + networkFenceClass.Finalizers = append(networkFenceClass.Finalizers, csiAddonsNodeFinalizer) + if err := r.Client.Update(ctx, networkFenceClass); err != nil { + logger.Error(err, "Failed to add finalizer") + + return err + } + } + + return nil +} + +// removeFinalizer removes finalizer from networkFenceClass if it is present. +func (r *NetworkFenceClassReconciler) removeFinalizer( + ctx context.Context, + logger *logr.Logger, + networkFenceClass *csiaddonsv1alpha1.NetworkFenceClass) error { + + if slices.Contains(networkFenceClass.Finalizers, csiAddonsNodeFinalizer) { + logger.Info("Removing finalizer") + + networkFenceClass.Finalizers = util.RemoveFromSlice(networkFenceClass.Finalizers, csiAddonsNodeFinalizer) + if err := r.Client.Update(ctx, networkFenceClass); err != nil { + logger.Error(err, "Failed to remove finalizer") + + return err + } + } + + return nil +} + +// getNetworkFenceClass fetches the NetworkFenceClass object. +func (r *NetworkFenceClassReconciler) getNetworkFenceClass(ctx context.Context, req ctrl.Request) (*csiaddonsv1alpha1.NetworkFenceClass, error) { + instance := &csiaddonsv1alpha1.NetworkFenceClass{} + err := r.Client.Get(ctx, req.NamespacedName, instance) + if err != nil { + if errors.IsNotFound(err) { + log.FromContext(ctx).Info("NetworkFenceClass resource not found") + return nil, nil + } + return nil, err + } + + return instance, nil +} + +func (r *NetworkFenceClassReconciler) listCSIAddonsNodes(ctx context.Context, provisioner string) (*csiaddonsv1alpha1.CSIAddonsNodeList, error) { + csiaddonsNodeList := &csiaddonsv1alpha1.CSIAddonsNodeList{} + err := r.Client.List(ctx, csiaddonsNodeList, client.MatchingFields{driverName: provisioner}) + if err != nil { + log.FromContext(ctx).Error(err, "Failed to list CSIAddonsNode objects") + return nil, err + } + return csiaddonsNodeList, nil +} + +func (r *NetworkFenceClassReconciler) processCSIAddonsNode(ctx context.Context, logger *logr.Logger, csiaddonsnode *csiaddonsv1alpha1.CSIAddonsNode, instance *csiaddonsv1alpha1.NetworkFenceClass, nfUnderDeletion bool) error { + if len(csiaddonsnode.Status.Capabilities) == 0 { + return stdError.New("CSIAddonsNode status capabilities not found") + } + + if csiaddonsnode.Annotations == nil { + csiaddonsnode.Annotations = make(map[string]string) + } + + // Retrieve the existing annotation (if any). + classesJSON := csiaddonsnode.Annotations[networkFenceClassAnnotationKey] + var classes []string + if classesJSON != "" { + // Unmarshal the existing JSON into a slice of strings. + if err := json.Unmarshal([]byte(classesJSON), &classes); err != nil { + logger.Error(err, "Failed to unmarshal existing networkFenceClasses annotation", "name", csiaddonsnode.Name) + return err + } + } + + for _, capability := range csiaddonsnode.Status.Capabilities { + if strings.Contains(capability, "GET_CLIENTS_TO_FENCE") { + logger.Info("Found GET_CLIENTS_TO_FENCE capability", "name", csiaddonsnode.Name, "driverName", csiaddonsnode.Spec.Driver.Name, "nodeID", csiaddonsnode.Spec.Driver.NodeID) + + ok := slices.Contains(classes, instance.Name) + if !ok && !nfUnderDeletion { + // If the class is not already in the annotation and the node is not under deletion, add it. + classes = append(classes, instance.Name) + updatedClassesJSON, err := json.Marshal(classes) + if err != nil { + logger.Error(err, "Failed to marshal updated classes into JSON", "name", csiaddonsnode.Name) + return err + } + + // Store the updated JSON in the annotation. + csiaddonsnode.Annotations[networkFenceClassAnnotationKey] = string(updatedClassesJSON) + logger.Info("Adding NetworkFenceClass to csiaddonsnode annotations", "name", csiaddonsnode.Name, "NetworkFenceClass", instance.Name) + return r.Client.Update(ctx, csiaddonsnode) + } + + if ok && nfUnderDeletion { + // Remove the NetworkFenceClass from the annotation (if it exists). + classes = removeClassFromList(classes, instance.Name) + updatedClassesJSON, err := json.Marshal(classes) + if err != nil { + logger.Error(err, "Failed to marshal updated classes after removal into JSON", "name", csiaddonsnode.Name) + return err + } + + if len(classes) == 0 { + // If the list of classes is empty, remove the annotation. + delete(csiaddonsnode.Annotations, networkFenceClassAnnotationKey) + } else { + // Update the annotation with the modified list of classes. + csiaddonsnode.Annotations[networkFenceClassAnnotationKey] = string(updatedClassesJSON) + } + logger.Info("Removing NetworkFenceClass from csiaddonsnode annotation", "name", csiaddonsnode.Name, "NetworkFenceClass", instance.Name) + return r.Client.Update(ctx, csiaddonsnode) + } + } + } + + return nil +} + +// removeClassFromList removes a class name from the list of class names. +func removeClassFromList(classes []string, className string) []string { + for i, c := range classes { + if c == className { + // Remove the element from the slice. + return append(classes[:i], classes[i+1:]...) + } + } + + return classes +} + +// validatePrefixParameters checks for unknown reserved keys in parameters and +// empty values for reserved keys. +func validatePrefixedParameters(param map[string]string) error { + for k, v := range param { + if strings.HasPrefix(k, networkFenceParameterPrefix) { + switch k { + case prefixedNetworkFenceSecretNameKey: + if v == "" { + return stdError.New("secret name cannot be empty") + } + case prefixedNetworkFenceSecretNamespaceKey: + if v == "" { + return stdError.New("secret namespace cannot be empty") + } + // keep adding known prefixes to this list. + default: + return fmt.Errorf("found unknown parameter key %q with reserved prefix %s", k, networkFenceParameterPrefix) + } + } + } + + return nil +} + // SetupWithManager sets up the controller with the Manager. func (r *NetworkFenceClassReconciler) SetupWithManager(mgr ctrl.Manager) error { + ctx := context.Background() + if err := mgr.GetFieldIndexer().IndexField(ctx, &csiaddonsv1alpha1.CSIAddonsNode{}, driverName, func(o client.Object) []string { + if csiAddonsNode, ok := o.(*csiaddonsv1alpha1.CSIAddonsNode); ok && csiAddonsNode.Spec.Driver.Name != "" { + return []string{csiAddonsNode.Spec.Driver.Name} + } + return nil + }); err != nil { + return fmt.Errorf("unable to set up FieldIndexer for CSIAddonsNode Provisioner: %v", err) + } + + if err := mgr.GetFieldIndexer().IndexField(ctx, &csiaddonsv1alpha1.NetworkFenceClass{}, provisionerName, func(o client.Object) []string { + if nfc, ok := o.(*csiaddonsv1alpha1.NetworkFenceClass); ok && nfc.Spec.Provisioner != "" { + return []string{nfc.Spec.Provisioner} + } + return nil + }); err != nil { + return fmt.Errorf("unable to set up FieldIndexer for NetworkFenceClass Provisioner: %v", err) + } + + csiAddonsNodePredicate := predicate.Funcs{ + CreateFunc: func(e event.CreateEvent) bool { + return true + }, + // No need to reconcile the object when it is updated + UpdateFunc: func(e event.UpdateEvent) bool { + return false + }, + // No need to reconcile the object when it is deleted + DeleteFunc: func(e event.DeleteEvent) bool { + return false + }, + } + // Reconcile the OperatorConfigMap object when the cluster's version object is updated + enqueueNFC := handler.EnqueueRequestsFromMapFunc( + func(ctx context.Context, obj client.Object) []reconcile.Request { + // get the object and list of all NetworkFenceClass objects based on the driver name + csiAddonsNode, ok := obj.(*csiaddonsv1alpha1.CSIAddonsNode) + if !ok { + return []reconcile.Request{} + } + networkFenceClaimList := &csiaddonsv1alpha1.NetworkFenceClassList{} + err := r.Client.List(ctx, networkFenceClaimList, client.MatchingFields{provisionerName: csiAddonsNode.Spec.Driver.Name}) + if err != nil { + return []reconcile.Request{} + } + + requests := make([]reconcile.Request, 0, len(networkFenceClaimList.Items)) + for _, networkFenceClaim := range networkFenceClaimList.Items { + requests = append(requests, reconcile.Request{ + NamespacedName: types.NamespacedName{ + Name: networkFenceClaim.Name, + }, + }) + } + + return requests + }, + ) + return ctrl.NewControllerManagedBy(mgr). For(&csiaddonsv1alpha1.NetworkFenceClass{}). + Watches(&csiaddonsv1alpha1.CSIAddonsNode{}, enqueueNFC, builder.WithPredicates(csiAddonsNodePredicate)). Complete(r) } diff --git a/internal/controller/csiaddons/networkfenceclass_controller_test.go b/internal/controller/csiaddons/networkfenceclass_controller_test.go index 5560577a9..377cc2841 100644 --- a/internal/controller/csiaddons/networkfenceclass_controller_test.go +++ b/internal/controller/csiaddons/networkfenceclass_controller_test.go @@ -17,68 +17,109 @@ limitations under the License. package controller import ( - "context" + "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - csiaddonsv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/csiaddons/v1alpha1" + "github.com/stretchr/testify/assert" ) -var _ = Describe("NetworkFenceClass Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - networkfenceclass := &csiaddonsv1alpha1.NetworkFenceClass{} +func TestRemoveClassFromList(t *testing.T) { + tests := []struct { + name string + classes []string + className string + expected []string + }{ + { + name: "Class exists in the middle", + classes: []string{"class1", "class2", "class3"}, + className: "class2", + expected: []string{"class1", "class3"}, + }, + { + name: "Class is the first element", + classes: []string{"class1", "class2", "class3"}, + className: "class1", + expected: []string{"class2", "class3"}, + }, + { + name: "Class is the last element", + classes: []string{"class1", "class2", "class3"}, + className: "class3", + expected: []string{"class1", "class2"}, + }, + { + name: "Class does not exist", + classes: []string{"class1", "class2", "class3"}, + className: "class4", + expected: []string{"class1", "class2", "class3"}, + }, + { + name: "Empty list", + classes: []string{}, + className: "class1", + expected: []string{}, + }, + { + name: "Removing the last class", + classes: []string{"class1"}, + className: "class1", + expected: []string{}, + }, + } - BeforeEach(func() { - By("creating the custom resource for the Kind NetworkFenceClass") - err := k8sClient.Get(ctx, typeNamespacedName, networkfenceclass) - if err != nil && errors.IsNotFound(err) { - resource := &csiaddonsv1alpha1.NetworkFenceClass{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := removeClassFromList(tt.classes, tt.className) + assert.Equal(t, tt.expected, result, "classes should be equal") }) + } +} - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &csiaddonsv1alpha1.NetworkFenceClass{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) +func TestValidatePrefixedParameters(t *testing.T) { + tests := []struct { + name string + param map[string]string + wantErr bool + }{ + { + name: "valid parameters", + param: map[string]string{ + prefixedNetworkFenceSecretNameKey: "secret1", + prefixedNetworkFenceSecretNamespaceKey: "namespace1", + }, + wantErr: false, + }, + { + name: "empty secret name", + param: map[string]string{ + prefixedNetworkFenceSecretNameKey: "", + prefixedNetworkFenceSecretNamespaceKey: "namespace1", + }, + wantErr: true, + }, + { + name: "empty secret namespace", + param: map[string]string{ + prefixedNetworkFenceSecretNameKey: "secret1", + prefixedNetworkFenceSecretNamespaceKey: "", + }, + wantErr: true, + }, + { + name: "unknown parameter key", + param: map[string]string{networkFenceParameterPrefix + "/unknownKey": "value"}, + wantErr: true, + }, + } - By("Cleanup the specific resource instance NetworkFenceClass") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &NetworkFenceClassReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := validatePrefixedParameters(tt.param) + if tt.wantErr { + assert.Error(t, err) + } else { + assert.NoError(t, err) } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. }) - }) -}) + } +} From c278fa64c4579f457ce4500fc61e231f13f98f9d Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 7 Nov 2024 09:34:58 +0100 Subject: [PATCH 03/10] doc: add sample for networkfenceclass CR adding a sample yaml for the networkfenceclass CR. Signed-off-by: Madhu Rajanna --- config/samples/csiaddons_v1alpha1_networkfenceclass.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/samples/csiaddons_v1alpha1_networkfenceclass.yaml b/config/samples/csiaddons_v1alpha1_networkfenceclass.yaml index ee40729f5..8151f96ac 100644 --- a/config/samples/csiaddons_v1alpha1_networkfenceclass.yaml +++ b/config/samples/csiaddons_v1alpha1_networkfenceclass.yaml @@ -6,4 +6,7 @@ metadata: app.kubernetes.io/managed-by: kustomize name: networkfenceclass-sample spec: - # TODO(user): Add fields here + provisioner: driver.example.com + parameters: + csiaddons.openshift.io/networkfence-secret-name: secret + csiaddons.openshift.io/network-secret-namespace: default From 031aa7c79cc4fc08ea11f83ce09d5bfcad549f35 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 7 Nov 2024 09:36:01 +0100 Subject: [PATCH 04/10] api: update the csiaddonsnode status adding a new fields to the csiaddonsnode status to represent the networkfenceclass and its client details. Signed-off-by: Madhu Rajanna --- api/csiaddons/v1alpha1/csiaddonsnode_types.go | 17 +++++++ .../v1alpha1/zz_generated.deepcopy.go | 49 +++++++++++++++++++ ...csiaddons.openshift.io_csiaddonsnodes.yaml | 34 +++++++++++++ deploy/controller/crds.yaml | 34 +++++++++++++ 4 files changed, 134 insertions(+) diff --git a/api/csiaddons/v1alpha1/csiaddonsnode_types.go b/api/csiaddons/v1alpha1/csiaddonsnode_types.go index 36e7a5b30..555ccfd33 100644 --- a/api/csiaddons/v1alpha1/csiaddonsnode_types.go +++ b/api/csiaddons/v1alpha1/csiaddonsnode_types.go @@ -77,6 +77,23 @@ type CSIAddonsNodeStatus struct { // A list of capabilities advertised by the sidecar Capabilities []string `json:"capabilities,omitempty"` + + // NetworkFenceClientStatus contains the status of the clients required for fencing. + NetworkFenceClientStatus []NetworkFenceClientStatus `json:"networkFenceClientStatus,omitempty"` +} + +// NetworkFenceClientStatus contains the status of the clients required for fencing. +type NetworkFenceClientStatus struct { + NetworkFenceClassName string `json:"networkFenceClassName"` + ClientDetails []ClientDetail `json:"ClientDetails"` +} + +// ClientDetail contains the details of the client required for fencing. +type ClientDetail struct { + // Id is the unique identifier of the client where it belongs to. + Id string `json:"id"` + // Cidrs is the list of CIDR blocks that are fenced. + Cidrs []string `json:"cidrs"` } //+kubebuilder:object:root=true diff --git a/api/csiaddons/v1alpha1/zz_generated.deepcopy.go b/api/csiaddons/v1alpha1/zz_generated.deepcopy.go index fbd6b5457..3d5a36a9d 100644 --- a/api/csiaddons/v1alpha1/zz_generated.deepcopy.go +++ b/api/csiaddons/v1alpha1/zz_generated.deepcopy.go @@ -124,6 +124,13 @@ func (in *CSIAddonsNodeStatus) DeepCopyInto(out *CSIAddonsNodeStatus) { *out = make([]string, len(*in)) copy(*out, *in) } + if in.NetworkFenceClientStatus != nil { + in, out := &in.NetworkFenceClientStatus, &out.NetworkFenceClientStatus + *out = make([]NetworkFenceClientStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CSIAddonsNodeStatus. @@ -136,6 +143,26 @@ func (in *CSIAddonsNodeStatus) DeepCopy() *CSIAddonsNodeStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClientDetail) DeepCopyInto(out *ClientDetail) { + *out = *in + if in.Cidrs != nil { + in, out := &in.Cidrs, &out.Cidrs + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClientDetail. +func (in *ClientDetail) DeepCopy() *ClientDetail { + if in == nil { + return nil + } + out := new(ClientDetail) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *EncryptionKeyRotationCronJob) DeepCopyInto(out *EncryptionKeyRotationCronJob) { *out = *in @@ -509,6 +536,28 @@ func (in *NetworkFenceClassStatus) DeepCopy() *NetworkFenceClassStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkFenceClientStatus) DeepCopyInto(out *NetworkFenceClientStatus) { + *out = *in + if in.ClientDetails != nil { + in, out := &in.ClientDetails, &out.ClientDetails + *out = make([]ClientDetail, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkFenceClientStatus. +func (in *NetworkFenceClientStatus) DeepCopy() *NetworkFenceClientStatus { + if in == nil { + return nil + } + out := new(NetworkFenceClientStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NetworkFenceList) DeepCopyInto(out *NetworkFenceList) { *out = *in diff --git a/config/crd/bases/csiaddons.openshift.io_csiaddonsnodes.yaml b/config/crd/bases/csiaddons.openshift.io_csiaddonsnodes.yaml index 58a73fe50..74f4aaf2a 100644 --- a/config/crd/bases/csiaddons.openshift.io_csiaddonsnodes.yaml +++ b/config/crd/bases/csiaddons.openshift.io_csiaddonsnodes.yaml @@ -104,6 +104,40 @@ spec: Message is a human-readable message indicating details about why the CSIAddonsNode is in this state. type: string + networkFenceClientStatus: + description: NetworkFenceClientStatus contains the status of the clients + required for fencing. + items: + description: NetworkFenceClientStatus contains the status of the + clients required for fencing. + properties: + ClientDetails: + items: + description: ClientDetail contains the details of the client + required for fencing. + properties: + cidrs: + description: Cidrs is the list of CIDR blocks that are + fenced. + items: + type: string + type: array + id: + description: Id is the unique identifier of the client + where it belongs to. + type: string + required: + - cidrs + - id + type: object + type: array + networkFenceClassName: + type: string + required: + - ClientDetails + - networkFenceClassName + type: object + type: array reason: description: |- Reason is a brief CamelCase string that describes any failure and is meant diff --git a/deploy/controller/crds.yaml b/deploy/controller/crds.yaml index 7c14b7e10..077b89f67 100644 --- a/deploy/controller/crds.yaml +++ b/deploy/controller/crds.yaml @@ -103,6 +103,40 @@ spec: Message is a human-readable message indicating details about why the CSIAddonsNode is in this state. type: string + networkFenceClientStatus: + description: NetworkFenceClientStatus contains the status of the clients + required for fencing. + items: + description: NetworkFenceClientStatus contains the status of the + clients required for fencing. + properties: + ClientDetails: + items: + description: ClientDetail contains the details of the client + required for fencing. + properties: + cidrs: + description: Cidrs is the list of CIDR blocks that are + fenced. + items: + type: string + type: array + id: + description: Id is the unique identifier of the client + where it belongs to. + type: string + required: + - cidrs + - id + type: object + type: array + networkFenceClassName: + type: string + required: + - ClientDetails + - networkFenceClassName + type: object + type: array reason: description: |- Reason is a brief CamelCase string that describes any failure and is meant From 934304e7bd8fcedaa2045d19ae63b4aa1e04233c Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 7 Nov 2024 09:54:09 +0100 Subject: [PATCH 05/10] proto: generate proto for GetFenceClients generated internal proto for GetFenceClients RPC. Signed-off-by: Madhu Rajanna --- internal/proto/networkfence.pb.go | 267 ++++++++++++++++++++++--- internal/proto/networkfence.proto | 42 +++- internal/proto/networkfence_grpc.pb.go | 42 ++++ 3 files changed, 317 insertions(+), 34 deletions(-) diff --git a/internal/proto/networkfence.pb.go b/internal/proto/networkfence.pb.go index 40c7e1c54..0488e397a 100644 --- a/internal/proto/networkfence.pb.go +++ b/internal/proto/networkfence.pb.go @@ -133,6 +133,177 @@ func (*NetworkFenceResponse) Descriptor() ([]byte, []int) { return file_networkfence_proto_rawDescGZIP(), []int{1} } +// FenceClientsRequest contains the necessary information to identify +// the clients that need fencing. +type FenceClientsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Plugin-specific parameters passed in as opaque key-value pairs. + Parameters map[string]string `protobuf:"bytes,1,rep,name=parameters,proto3" json:"parameters,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // Secrets required by the driver to complete the request. + SecretName string `protobuf:"bytes,2,opt,name=secret_name,json=secretName,proto3" json:"secret_name,omitempty"` + SecretNamespace string `protobuf:"bytes,3,opt,name=secret_namespace,json=secretNamespace,proto3" json:"secret_namespace,omitempty"` +} + +func (x *FenceClientsRequest) Reset() { + *x = FenceClientsRequest{} + mi := &file_networkfence_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FenceClientsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FenceClientsRequest) ProtoMessage() {} + +func (x *FenceClientsRequest) ProtoReflect() protoreflect.Message { + mi := &file_networkfence_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FenceClientsRequest.ProtoReflect.Descriptor instead. +func (*FenceClientsRequest) Descriptor() ([]byte, []int) { + return file_networkfence_proto_rawDescGZIP(), []int{2} +} + +func (x *FenceClientsRequest) GetParameters() map[string]string { + if x != nil { + return x.Parameters + } + return nil +} + +func (x *FenceClientsRequest) GetSecretName() string { + if x != nil { + return x.SecretName + } + return "" +} + +func (x *FenceClientsRequest) GetSecretNamespace() string { + if x != nil { + return x.SecretNamespace + } + return "" +} + +// FenceClientsResponse holds the information about clients that require +// fencing. +type FenceClientsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // List of clients that need to be fenced. + Clients []*ClientDetails `protobuf:"bytes,1,rep,name=clients,proto3" json:"clients,omitempty"` +} + +func (x *FenceClientsResponse) Reset() { + *x = FenceClientsResponse{} + mi := &file_networkfence_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *FenceClientsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FenceClientsResponse) ProtoMessage() {} + +func (x *FenceClientsResponse) ProtoReflect() protoreflect.Message { + mi := &file_networkfence_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FenceClientsResponse.ProtoReflect.Descriptor instead. +func (*FenceClientsResponse) Descriptor() ([]byte, []int) { + return file_networkfence_proto_rawDescGZIP(), []int{3} +} + +func (x *FenceClientsResponse) GetClients() []*ClientDetails { + if x != nil { + return x.Clients + } + return nil +} + +// ClientDetails holds the information about the client that requires fencing. +type ClientDetails struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // id represents the unique identifier of the client. + // Required field. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // list of cidrs that represent the client's local cidrs. + // Required field. + Cidrs []string `protobuf:"bytes,2,rep,name=cidrs,proto3" json:"cidrs,omitempty"` +} + +func (x *ClientDetails) Reset() { + *x = ClientDetails{} + mi := &file_networkfence_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ClientDetails) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientDetails) ProtoMessage() {} + +func (x *ClientDetails) ProtoReflect() protoreflect.Message { + mi := &file_networkfence_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClientDetails.ProtoReflect.Descriptor instead. +func (*ClientDetails) Descriptor() ([]byte, []int) { + return file_networkfence_proto_rawDescGZIP(), []int{4} +} + +func (x *ClientDetails) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ClientDetails) GetCidrs() []string { + if x != nil { + return x.Cidrs + } + return nil +} + var File_networkfence_proto protoreflect.FileDescriptor var file_networkfence_proto_rawDesc = []byte{ @@ -155,23 +326,51 @@ var file_networkfence_proto_rawDesc = []byte{ 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x16, 0x0a, 0x14, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb4, 0x01, 0x0a, 0x0c, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x50, 0x0a, 0x13, 0x46, 0x65, 0x6e, - 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x15, 0x55, - 0x6e, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x73, - 0x69, 0x2d, 0x61, 0x64, 0x64, 0x6f, 0x6e, 0x73, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x65, 0x73, 0x2d, 0x63, 0x73, 0x69, 0x2d, 0x61, 0x64, 0x64, 0x6f, 0x6e, 0x73, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xec, 0x01, 0x0a, 0x13, 0x46, 0x65, 0x6e, + 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x4a, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x65, 0x6e, + 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x1f, 0x0a, 0x0b, + 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, + 0x10, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x46, 0x0a, 0x14, 0x46, 0x65, 0x6e, 0x63, 0x65, + 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x2e, 0x0a, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x07, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0x35, 0x0a, 0x0d, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x14, 0x0a, 0x05, 0x63, 0x69, 0x64, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x05, 0x63, 0x69, 0x64, 0x72, 0x73, 0x32, 0x82, 0x02, 0x0a, 0x0c, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x50, 0x0a, 0x13, 0x46, 0x65, 0x6e, 0x63, 0x65, + 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x1a, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x15, 0x55, 0x6e, 0x46, + 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x46, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4c, 0x0a, + 0x0f, 0x47, 0x65, 0x74, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x73, + 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3c, 0x5a, 0x3a, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x73, 0x69, 0x2d, 0x61, 0x64, + 0x64, 0x6f, 0x6e, 0x73, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x2d, + 0x63, 0x73, 0x69, 0x2d, 0x61, 0x64, 0x64, 0x6f, 0x6e, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -186,23 +385,31 @@ func file_networkfence_proto_rawDescGZIP() []byte { return file_networkfence_proto_rawDescData } -var file_networkfence_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_networkfence_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_networkfence_proto_goTypes = []any{ (*NetworkFenceRequest)(nil), // 0: proto.NetworkFenceRequest (*NetworkFenceResponse)(nil), // 1: proto.NetworkFenceResponse - nil, // 2: proto.NetworkFenceRequest.ParametersEntry + (*FenceClientsRequest)(nil), // 2: proto.FenceClientsRequest + (*FenceClientsResponse)(nil), // 3: proto.FenceClientsResponse + (*ClientDetails)(nil), // 4: proto.ClientDetails + nil, // 5: proto.NetworkFenceRequest.ParametersEntry + nil, // 6: proto.FenceClientsRequest.ParametersEntry } var file_networkfence_proto_depIdxs = []int32{ - 2, // 0: proto.NetworkFenceRequest.parameters:type_name -> proto.NetworkFenceRequest.ParametersEntry - 0, // 1: proto.NetworkFence.FenceClusterNetwork:input_type -> proto.NetworkFenceRequest - 0, // 2: proto.NetworkFence.UnFenceClusterNetwork:input_type -> proto.NetworkFenceRequest - 1, // 3: proto.NetworkFence.FenceClusterNetwork:output_type -> proto.NetworkFenceResponse - 1, // 4: proto.NetworkFence.UnFenceClusterNetwork:output_type -> proto.NetworkFenceResponse - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 5, // 0: proto.NetworkFenceRequest.parameters:type_name -> proto.NetworkFenceRequest.ParametersEntry + 6, // 1: proto.FenceClientsRequest.parameters:type_name -> proto.FenceClientsRequest.ParametersEntry + 4, // 2: proto.FenceClientsResponse.clients:type_name -> proto.ClientDetails + 0, // 3: proto.NetworkFence.FenceClusterNetwork:input_type -> proto.NetworkFenceRequest + 0, // 4: proto.NetworkFence.UnFenceClusterNetwork:input_type -> proto.NetworkFenceRequest + 2, // 5: proto.NetworkFence.GetFenceClients:input_type -> proto.FenceClientsRequest + 1, // 6: proto.NetworkFence.FenceClusterNetwork:output_type -> proto.NetworkFenceResponse + 1, // 7: proto.NetworkFence.UnFenceClusterNetwork:output_type -> proto.NetworkFenceResponse + 3, // 8: proto.NetworkFence.GetFenceClients:output_type -> proto.FenceClientsResponse + 6, // [6:9] is the sub-list for method output_type + 3, // [3:6] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_networkfence_proto_init() } @@ -216,7 +423,7 @@ func file_networkfence_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_networkfence_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/proto/networkfence.proto b/internal/proto/networkfence.proto index 5c866eae5..13f287e27 100644 --- a/internal/proto/networkfence.proto +++ b/internal/proto/networkfence.proto @@ -6,10 +6,17 @@ option go_package = "github.com/csi-addons/kubernetes-csi-addons/internal/proto" // NetworkFence holds the RPC method for allowing the communication between // the CSIAddons controller and the sidecar for fencing operations. service NetworkFence { - // FenceClusterNetwork RPC call to fence the cluster network. - rpc FenceClusterNetwork (NetworkFenceRequest) returns(NetworkFenceResponse) {} - // UnFenceClusterNetwork RPC call to un-fence the cluster network. - rpc UnFenceClusterNetwork (NetworkFenceRequest) returns(NetworkFenceResponse) {} + // FenceClusterNetwork RPC call to fence the cluster network. + rpc FenceClusterNetwork (NetworkFenceRequest) + returns(NetworkFenceResponse) {} + // UnFenceClusterNetwork RPC call to un-fence the cluster network. + rpc UnFenceClusterNetwork (NetworkFenceRequest) + returns(NetworkFenceResponse) {} + + // GetFenceClients RPC calls to get the client information to use in a + // FenceClusterNetwork or UnfenceClusterNetwork RPC. + rpc GetFenceClients(FenceClientsRequest) + returns (FenceClientsResponse){} } // NetworkFenceRequest holds the required information to fence/unfence @@ -30,3 +37,30 @@ message NetworkFenceRequest { message NetworkFenceResponse { // Intentionally empty. } + +// FenceClientsRequest contains the necessary information to identify +// the clients that need fencing. +message FenceClientsRequest { + // Plugin-specific parameters passed in as opaque key-value pairs. + map parameters = 1; + // Secrets required by the driver to complete the request. + string secret_name = 2; + string secret_namespace = 3; +} + +// FenceClientsResponse holds the information about clients that require +// fencing. +message FenceClientsResponse { + // List of clients that need to be fenced. + repeated ClientDetails clients = 1; +} + +// ClientDetails holds the information about the client that requires fencing. +message ClientDetails { + // id represents the unique identifier of the client. + // Required field. + string id = 1; + // list of cidrs that represent the client's local cidrs. + // Required field. + repeated string cidrs = 2; +} diff --git a/internal/proto/networkfence_grpc.pb.go b/internal/proto/networkfence_grpc.pb.go index d1191305f..a5f1237a8 100644 --- a/internal/proto/networkfence_grpc.pb.go +++ b/internal/proto/networkfence_grpc.pb.go @@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion9 const ( NetworkFence_FenceClusterNetwork_FullMethodName = "/proto.NetworkFence/FenceClusterNetwork" NetworkFence_UnFenceClusterNetwork_FullMethodName = "/proto.NetworkFence/UnFenceClusterNetwork" + NetworkFence_GetFenceClients_FullMethodName = "/proto.NetworkFence/GetFenceClients" ) // NetworkFenceClient is the client API for NetworkFence service. @@ -34,6 +35,9 @@ type NetworkFenceClient interface { FenceClusterNetwork(ctx context.Context, in *NetworkFenceRequest, opts ...grpc.CallOption) (*NetworkFenceResponse, error) // UnFenceClusterNetwork RPC call to un-fence the cluster network. UnFenceClusterNetwork(ctx context.Context, in *NetworkFenceRequest, opts ...grpc.CallOption) (*NetworkFenceResponse, error) + // GetFenceClients RPC calls to get the client information to use in a + // FenceClusterNetwork or UnfenceClusterNetwork RPC. + GetFenceClients(ctx context.Context, in *FenceClientsRequest, opts ...grpc.CallOption) (*FenceClientsResponse, error) } type networkFenceClient struct { @@ -64,6 +68,16 @@ func (c *networkFenceClient) UnFenceClusterNetwork(ctx context.Context, in *Netw return out, nil } +func (c *networkFenceClient) GetFenceClients(ctx context.Context, in *FenceClientsRequest, opts ...grpc.CallOption) (*FenceClientsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(FenceClientsResponse) + err := c.cc.Invoke(ctx, NetworkFence_GetFenceClients_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // NetworkFenceServer is the server API for NetworkFence service. // All implementations must embed UnimplementedNetworkFenceServer // for forward compatibility. @@ -75,6 +89,9 @@ type NetworkFenceServer interface { FenceClusterNetwork(context.Context, *NetworkFenceRequest) (*NetworkFenceResponse, error) // UnFenceClusterNetwork RPC call to un-fence the cluster network. UnFenceClusterNetwork(context.Context, *NetworkFenceRequest) (*NetworkFenceResponse, error) + // GetFenceClients RPC calls to get the client information to use in a + // FenceClusterNetwork or UnfenceClusterNetwork RPC. + GetFenceClients(context.Context, *FenceClientsRequest) (*FenceClientsResponse, error) mustEmbedUnimplementedNetworkFenceServer() } @@ -91,6 +108,9 @@ func (UnimplementedNetworkFenceServer) FenceClusterNetwork(context.Context, *Net func (UnimplementedNetworkFenceServer) UnFenceClusterNetwork(context.Context, *NetworkFenceRequest) (*NetworkFenceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UnFenceClusterNetwork not implemented") } +func (UnimplementedNetworkFenceServer) GetFenceClients(context.Context, *FenceClientsRequest) (*FenceClientsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetFenceClients not implemented") +} func (UnimplementedNetworkFenceServer) mustEmbedUnimplementedNetworkFenceServer() {} func (UnimplementedNetworkFenceServer) testEmbeddedByValue() {} @@ -148,6 +168,24 @@ func _NetworkFence_UnFenceClusterNetwork_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _NetworkFence_GetFenceClients_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FenceClientsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NetworkFenceServer).GetFenceClients(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NetworkFence_GetFenceClients_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NetworkFenceServer).GetFenceClients(ctx, req.(*FenceClientsRequest)) + } + return interceptor(ctx, in, info, handler) +} + // NetworkFence_ServiceDesc is the grpc.ServiceDesc for NetworkFence service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -163,6 +201,10 @@ var NetworkFence_ServiceDesc = grpc.ServiceDesc{ MethodName: "UnFenceClusterNetwork", Handler: _NetworkFence_UnFenceClusterNetwork_Handler, }, + { + MethodName: "GetFenceClients", + Handler: _NetworkFence_GetFenceClients_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "networkfence.proto", From 9b09847ced7118a59dc999b9e24af748d21faede Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Thu, 7 Nov 2024 10:12:52 +0100 Subject: [PATCH 06/10] sidecar: add GetFenceClients RPC added GetFenceClients RPC to the sidecar service to make RPC call to the csi driver Signed-off-by: Madhu Rajanna --- internal/sidecar/service/networkfence.go | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/internal/sidecar/service/networkfence.go b/internal/sidecar/service/networkfence.go index 37c15d9be..2e8ce0f17 100644 --- a/internal/sidecar/service/networkfence.go +++ b/internal/sidecar/service/networkfence.go @@ -115,3 +115,48 @@ func getCIDRS(cidr []string) []*fence.CIDR { } return cidrs } + +// GetFenceClients fetches required information from kubernetes cluster and calls +// CSI-Addons GetFenceClients service. +func (ns *NetworkFenceServer) GetFenceClients( + ctx context.Context, + req *proto.FenceClientsRequest) (*proto.FenceClientsResponse, error) { + data := map[string]string{} + var err error + // Get the secrets from the k8s cluster if secret name or namespace is provided + if req.GetSecretName() != "" || req.GetSecretNamespace() != "" { + data, err = kube.GetSecret(ctx, ns.kubeClient, req.GetSecretName(), req.GetSecretNamespace()) + if err != nil { + klog.Errorf("Failed to get secret %s in namespace %s: %v", req.GetSecretName(), req.GetSecretNamespace(), err) + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + } + + getFenceClientRequest := fence.GetFenceClientsRequest{ + Parameters: req.GetParameters(), + Secrets: data, + } + + resp, err := ns.controllerClient.GetFenceClients(ctx, &getFenceClientRequest) + if err != nil { + klog.Errorf("Failed to get fence clients: %v", err) + return nil, err + } + response := &proto.FenceClientsResponse{} + for _, client := range resp.Clients { + response.Clients = append(response.Clients, &proto.ClientDetails{ + Id: client.Id, + Cidrs: cidrsFromFenceCIDR(client.Addresses), + }) + } + + return response, nil +} + +func cidrsFromFenceCIDR(cidr []*fence.CIDR) []string { + cidrs := []string{} + for _, c := range cidr { + cidrs = append(cidrs, c.Cidr) + } + return cidrs +} From 8b8c9aa4f2ca18060c606ba7c91c29a08cf48f2a Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 11 Nov 2024 11:43:12 +0100 Subject: [PATCH 07/10] controller: get the fence client upon registration when a csiaddons is registered, List the NFC CR's matching the provisioner name and send a request to get the client address from the csi driver and update the status with the client details. Signed-off-by: Madhu Rajanna --- .../csiaddons/csiaddonsnode_controller.go | 122 +++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/internal/controller/csiaddons/csiaddonsnode_controller.go b/internal/controller/csiaddons/csiaddonsnode_controller.go index 15b80f4df..50d161b0d 100644 --- a/internal/controller/csiaddons/csiaddonsnode_controller.go +++ b/internal/controller/csiaddons/csiaddonsnode_controller.go @@ -18,6 +18,7 @@ package controller import ( "context" + "encoding/json" "errors" "fmt" "net/url" @@ -26,6 +27,7 @@ import ( csiaddonsv1alpha1 "github.com/csi-addons/kubernetes-csi-addons/api/csiaddons/v1alpha1" "github.com/csi-addons/kubernetes-csi-addons/internal/connection" + "github.com/csi-addons/kubernetes-csi-addons/internal/proto" "github.com/csi-addons/kubernetes-csi-addons/internal/util" "github.com/csi-addons/spec/lib/go/identity" @@ -138,6 +140,13 @@ func (r *CSIAddonsNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reques return ctrl.Result{}, err } + nfsc, err := r.getNetworkFenceClientStatus(ctx, &logger, newConn, csiAddonsNode) + if err != nil { + return ctrl.Result{}, err + } + + csiAddonsNode.Status.NetworkFenceClientStatus = nfsc + logger.Info("Successfully connected to sidecar") r.ConnPool.Put(key, newConn) logger.Info("Added connection to connection pool", "Key", key) @@ -155,11 +164,122 @@ func (r *CSIAddonsNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reques return ctrl.Result{}, nil } +// getNetworkFenceClassesForDriver gets the networkfenceclasses for the driver. +func (r *CSIAddonsNodeReconciler) getNetworkFenceClassesForDriver(ctx context.Context, logger *logr.Logger, + instance *csiaddonsv1alpha1.CSIAddonsNode) ([]csiaddonsv1alpha1.NetworkFenceClass, error) { + // get the networkfenceclasses from the annotation + nfclasses := make([]csiaddonsv1alpha1.NetworkFenceClass, 0) + classesJSON, ok := instance.GetAnnotations()[networkFenceClassAnnotationKey] + if !ok { + logger.Info("No networkfenceclasses found in annotation") + return nfclasses, nil + } + + var classes []string + + // Unmarshal the existing JSON into a slice of strings. + if err := json.Unmarshal([]byte(classesJSON), &classes); err != nil { + logger.Error(err, "Failed to unmarshal existing networkFenceClasses annotation", "name", instance.Name) + return nfclasses, err + } + + for _, class := range classes { + logger.Info("Found networkfenceclass ", "name", class) + nfc := csiaddonsv1alpha1.NetworkFenceClass{} + err := r.Client.Get(ctx, client.ObjectKey{Name: class}, &nfc) + if err != nil { + logger.Error(err, "Failed to get networkfenceclass", "name", class) + return nil, err + } + nfclasses = append(nfclasses, nfc) + } + + return nfclasses, nil +} + +func (r *CSIAddonsNodeReconciler) getNetworkFenceClientStatus(ctx context.Context, logger *logr.Logger, conn *connection.Connection, csiAddonsNode *csiaddonsv1alpha1.CSIAddonsNode) ([]csiaddonsv1alpha1.NetworkFenceClientStatus, error) { + + nfclasses, err := r.getNetworkFenceClassesForDriver(ctx, logger, csiAddonsNode) + if err != nil { + logger.Error(err, "Failed to get network fence classes") + return nil, err + } + + var nfsc []csiaddonsv1alpha1.NetworkFenceClientStatus + + for _, nfc := range nfclasses { + clients, err := getFenceClientDetails(ctx, conn, logger, nfc) + if err != nil { + logger.Error(err, "Failed to get clients to fence", "networkFenceClass", nfc.Name) + return nil, err + } + + // If no clients are found, skip this network fence class + if clients == nil { + continue + } + + // process the client details for this network fence class + clientDetails := r.getClientDetails(clients) + nfsc = append(nfsc, csiaddonsv1alpha1.NetworkFenceClientStatus{ + NetworkFenceClassName: nfc.Name, + ClientDetails: clientDetails, + }) + } + + return nfsc, nil +} + +// getClientDetails processes the client details to create the necessary status +func (r *CSIAddonsNodeReconciler) getClientDetails(clients *proto.FenceClientsResponse) []csiaddonsv1alpha1.ClientDetail { + var clientDetails []csiaddonsv1alpha1.ClientDetail + for _, client := range clients.Clients { + clientDetails = append(clientDetails, csiaddonsv1alpha1.ClientDetail{ + Id: client.Id, + Cidrs: client.Cidrs, + }) + } + return clientDetails +} + +// getFenceClientDetails gets the list of clients to fence from the driver. +func getFenceClientDetails(ctx context.Context, conn *connection.Connection, logger *logr.Logger, nfc csiaddonsv1alpha1.NetworkFenceClass) (*proto.FenceClientsResponse, error) { + + param := nfc.Spec.Parameters + secretName := param[prefixedNetworkFenceSecretNameKey] + secretNamespace := param[prefixedNetworkFenceSecretNamespaceKey] + // Remove secret from the parameters + delete(param, prefixedNetworkFenceSecretNameKey) + delete(param, prefixedNetworkFenceSecretNamespaceKey) + + // check if the driver contains the GET_CLIENTS_TO_FENCE capability + // if it does, we need to get the list of clients to fence + for _, cap := range conn.Capabilities { + if cap.GetNetworkFence() != nil && + cap.GetNetworkFence().GetType() == identity.Capability_NetworkFence_GET_CLIENTS_TO_FENCE { + logger.Info("Driver support GET_CLIENTS_TO_FENCE capability") + client := proto.NewNetworkFenceClient(conn.Client) + req := &proto.FenceClientsRequest{ + Parameters: nfc.Spec.Parameters, + SecretName: secretName, + SecretNamespace: secretNamespace, + } + clients, err := client.GetFenceClients(ctx, req) + if err != nil { + logger.Error(err, "Failed to get clients to fence") + return nil, err + } + return clients, nil + } + } + return nil, nil +} + // SetupWithManager sets up the controller with the Manager. func (r *CSIAddonsNodeReconciler) SetupWithManager(mgr ctrl.Manager, ctrlOptions controller.Options) error { return ctrl.NewControllerManagedBy(mgr). For(&csiaddonsv1alpha1.CSIAddonsNode{}). - WithEventFilter(predicate.GenerationChangedPredicate{}). + WithEventFilter(predicate.Or(predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{})). WithOptions(ctrlOptions). Complete(r) } From 1f0c7af5a1820061937bf2135ff953596081309d Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 11 Nov 2024 12:55:11 +0100 Subject: [PATCH 08/10] ci: run test with verbose flag run tests with verbose flag to get more detailed output. Signed-off-by: Madhu Rajanna --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dbb8de941..35ef530ec 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ vet: ## Run go vet against code. .PHONY: test test: manifests generate docker-generate-protobuf fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -v ./... -coverprofile cover.out .PHONY: check-all-committed check-all-committed: ## Fail in case there are uncommitted changes From 44f5d84ff2188b5964a535931a7ab9f9dd67919a Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 11 Nov 2024 14:25:40 +0100 Subject: [PATCH 09/10] doc: add documentation for nfc adding documentation for the network fence class. Signed-off-by: Madhu Rajanna --- docs/networkfenceclass.md | 61 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 docs/networkfenceclass.md diff --git a/docs/networkfenceclass.md b/docs/networkfenceclass.md new file mode 100644 index 000000000..b0b19d95d --- /dev/null +++ b/docs/networkfenceclass.md @@ -0,0 +1,61 @@ +# NetworkFenceClass + +NetworkFence is a cluster-scoped custom resource that allows Kubernetes to invoke "GetFenceClients" operation on a storage provider. + +The user needs to specify the csi provisioner name, parameters and the secret required to perform GetFenceClients operation. + +## Fence Operation + +```yaml +apiVersion: csiaddons.openshift.io/v1alpha1 +kind: NetworkFenceClass +metadata: + name: network-fence-class +spec: + provisioner: driver.example.com + parameters: + key: value + csiaddons.openshift.io/networkfence-secret-name: secret-name + csiaddons.openshift.io/networkfence-secret-namespace: secret-namespace +``` + +- `provisioner`: specifies the name of storage provisioner. +- `parameters`: specifies storage provider specific parameters. + +Resereved parameters: + +- `csiaddons.openshift.io/networkfence-secret-name`: specifies the name of the secret required for network fencing operation. +- `csiaddons.openshift.io/networkfence-secret-namespace`: specifies the namespace in which the secret is located. + +Once the NetworkFenceClass is processed, the CSI Addons controller will call the GetFenceClients operation on the storage provider associated with the provisioner name that registered the `GET_CLIENTS_TO_FENCE` capability. The resulting data will then be stored in the CSIAddonsNode status. + +The NetworkFenceStatus object will contain the list of clients that need to be fenced. + +```yaml +apiVersion: csiaddons.openshift.io/v1alpha1 +kind: CSIAddonsNode +metadata: + annotations: + csiaddons.openshift.io/networkfenceclass-names: '["network-fence-class"]' + creationTimestamp: "2024-11-11T07:31:20Z" + finalizers: + - csiaddons.openshift.io/csiaddonsnode + generation: 1 + name: plugin + namespace: default + ... +status: + capabilities: + - service.NODE_SERVICE + - reclaim_space.ONLINE + - encryption_key_rotation.ENCRYPTIONKEYROTATION + - network_fence.GET_CLIENTS_TO_FENCE + message: Successfully established connection with sidecar + networkFenceClientStatus: + - networkFenceClassName: network-fence-class + clientDetails: + - cidrs: + - 10.244.0.1/32 + id: a815fe8e-eabd-4e87-a6e8-78cebfb67d08 + state: Connected +``` From 4d025d3c7620f7ad20f6cabda900868f8795bdd1 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 12 Nov 2024 13:50:46 +0100 Subject: [PATCH 10/10] sidecar: dont copy the metadata if we deepcopy the metadata during the update operations all the annotations gets removed. Signed-off-by: Madhu Rajanna --- sidecar/internal/csiaddonsnode/csiaddonsnode.go | 1 - 1 file changed, 1 deletion(-) diff --git a/sidecar/internal/csiaddonsnode/csiaddonsnode.go b/sidecar/internal/csiaddonsnode/csiaddonsnode.go index 3e9ea64e3..402cf7886 100644 --- a/sidecar/internal/csiaddonsnode/csiaddonsnode.go +++ b/sidecar/internal/csiaddonsnode/csiaddonsnode.go @@ -134,7 +134,6 @@ func (mgr *Manager) newCSIAddonsNode(node *csiaddonsv1alpha1.CSIAddonsNode) erro _, err = controllerutil.CreateOrUpdate(ctx, cli, csiaddonNode, func() error { // update the resourceVersion resourceVersion := csiaddonNode.ResourceVersion - node.ObjectMeta.DeepCopyInto(&csiaddonNode.ObjectMeta) if resourceVersion != "" { csiaddonNode.ResourceVersion = resourceVersion }