diff --git a/api/v1alpha1/storageconsumer_types.go b/api/v1alpha1/storageconsumer_types.go index 0874d9e22a..4a3bcab667 100644 --- a/api/v1alpha1/storageconsumer_types.go +++ b/api/v1alpha1/storageconsumer_types.go @@ -72,6 +72,10 @@ type ClientStatus struct { PlatformVersion string `json:"platformVersion"` // StorageClient Operator Version OperatorVersion string `json:"operatorVersion"` + // ClusterID is the id of the openshift cluster + ClusterID string `json:"clusterId"` + // StorageClientNamespacedName is the name and namespace of the StorageClient + StorageClientNamespacedName string `json:"storageClientNamespacedName"` } //+kubebuilder:object:root=true diff --git a/config/crd/bases/ocs.openshift.io_storageconsumers.yaml b/config/crd/bases/ocs.openshift.io_storageconsumers.yaml index fe6bc1d457..cb0469c774 100644 --- a/config/crd/bases/ocs.openshift.io_storageconsumers.yaml +++ b/config/crd/bases/ocs.openshift.io_storageconsumers.yaml @@ -69,15 +69,24 @@ spec: client: description: Information of storage client received from consumer properties: + clusterId: + description: ClusterID is the id of the openshift cluster + type: string operatorVersion: description: StorageClient Operator Version type: string platformVersion: description: StorageClient Platform Version type: string + storageClientNamespacedName: + description: StorageClientNamespacedName is the name and namespace + of the StorageClient + type: string required: + - clusterId - operatorVersion - platformVersion + - storageClientNamespacedName type: object lastHeartbeat: description: Timestamp of last heartbeat received from consumer diff --git a/deploy/csv-templates/crds/ocs/ocs.openshift.io_storageconsumers.yaml b/deploy/csv-templates/crds/ocs/ocs.openshift.io_storageconsumers.yaml index fe6bc1d457..cb0469c774 100644 --- a/deploy/csv-templates/crds/ocs/ocs.openshift.io_storageconsumers.yaml +++ b/deploy/csv-templates/crds/ocs/ocs.openshift.io_storageconsumers.yaml @@ -69,15 +69,24 @@ spec: client: description: Information of storage client received from consumer properties: + clusterId: + description: ClusterID is the id of the openshift cluster + type: string operatorVersion: description: StorageClient Operator Version type: string platformVersion: description: StorageClient Platform Version type: string + storageClientNamespacedName: + description: StorageClientNamespacedName is the name and namespace + of the StorageClient + type: string required: + - clusterId - operatorVersion - platformVersion + - storageClientNamespacedName type: object lastHeartbeat: description: Timestamp of last heartbeat received from consumer diff --git a/deploy/ocs-operator/manifests/storageconsumer.crd.yaml b/deploy/ocs-operator/manifests/storageconsumer.crd.yaml index 2950e94745..94f8c9a80d 100644 --- a/deploy/ocs-operator/manifests/storageconsumer.crd.yaml +++ b/deploy/ocs-operator/manifests/storageconsumer.crd.yaml @@ -68,15 +68,24 @@ spec: client: description: Information of storage client received from consumer properties: + clusterId: + description: ClusterID is the id of the openshift cluster + type: string operatorVersion: description: StorageClient Operator Version type: string platformVersion: description: StorageClient Platform Version type: string + storageClientNamespacedName: + description: StorageClientNamespacedName is the name and namespace + of the StorageClient + type: string required: + - clusterId - operatorVersion - platformVersion + - storageClientNamespacedName type: object lastHeartbeat: description: Timestamp of last heartbeat received from consumer diff --git a/services/provider/interfaces/interfaces.go b/services/provider/interfaces/interfaces.go index 2ece5eabef..0e20bc170c 100644 --- a/services/provider/interfaces/interfaces.go +++ b/services/provider/interfaces/interfaces.go @@ -6,6 +6,8 @@ type StorageClientStatus interface { // no client is using it GetPlatformVersion() string GetOperatorVersion() string + GetClusterId() string + GetStorageClientNamespacedName() string SetPlatformVersion(string) StorageClientStatus SetOperatorVersion(string) StorageClientStatus @@ -16,6 +18,8 @@ type StorageClientOnboarding interface { GetOnboardingTicket() string GetConsumerName() string GetClientOperatorVersion() string + GetClusterId() string + GetStorageClientNamespacedName() string SetOnboardingTicket(string) StorageClientOnboarding SetConsumerName(string) StorageClientOnboarding diff --git a/services/provider/pb/provider.pb.go b/services/provider/pb/provider.pb.go index 1858aa797f..93322fdd22 100644 --- a/services/provider/pb/provider.pb.go +++ b/services/provider/pb/provider.pb.go @@ -81,6 +81,10 @@ type OnboardConsumerRequest struct { ConsumerName string `protobuf:"bytes,2,opt,name=consumerName,proto3" json:"consumerName,omitempty"` // clientOperatorVersion is the semver version of ocs-client-operator ClientOperatorVersion string `protobuf:"bytes,3,opt,name=clientOperatorVersion,proto3" json:"clientOperatorVersion,omitempty"` + // clusterID is the id of the openshift cluster + ClusterId string `protobuf:"bytes,4,opt,name=clusterId,proto3" json:"clusterId,omitempty"` + // storageClientNamespacedName is the name and namespace of the StorageClient + StorageClientNamespacedName string `protobuf:"bytes,5,opt,name=storageClientNamespacedName,proto3" json:"storageClientNamespacedName,omitempty"` } func (x *OnboardConsumerRequest) Reset() { @@ -136,6 +140,20 @@ func (x *OnboardConsumerRequest) GetClientOperatorVersion() string { return "" } +func (x *OnboardConsumerRequest) GetClusterId() string { + if x != nil { + return x.ClusterId + } + return "" +} + +func (x *OnboardConsumerRequest) GetStorageClientNamespacedName() string { + if x != nil { + return x.StorageClientNamespacedName + } + return "" +} + // OnboardConsumerResponse holds the response for OnboardConsumer API request type OnboardConsumerResponse struct { state protoimpl.MessageState @@ -861,9 +879,11 @@ type ReportStatusRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StorageConsumerUUID string `protobuf:"bytes,1,opt,name=storageConsumerUUID,proto3" json:"storageConsumerUUID,omitempty"` - ClientPlatformVersion string `protobuf:"bytes,2,opt,name=clientPlatformVersion,proto3" json:"clientPlatformVersion,omitempty"` - ClientOperatorVersion string `protobuf:"bytes,3,opt,name=clientOperatorVersion,proto3" json:"clientOperatorVersion,omitempty"` + StorageConsumerUUID string `protobuf:"bytes,1,opt,name=storageConsumerUUID,proto3" json:"storageConsumerUUID,omitempty"` + ClientPlatformVersion string `protobuf:"bytes,2,opt,name=clientPlatformVersion,proto3" json:"clientPlatformVersion,omitempty"` + ClientOperatorVersion string `protobuf:"bytes,3,opt,name=clientOperatorVersion,proto3" json:"clientOperatorVersion,omitempty"` + ClusterId string `protobuf:"bytes,4,opt,name=clusterId,proto3" json:"clusterId,omitempty"` + StorageClientNamespacedName string `protobuf:"bytes,5,opt,name=storageClientNamespacedName,proto3" json:"storageClientNamespacedName,omitempty"` } func (x *ReportStatusRequest) Reset() { @@ -919,6 +939,20 @@ func (x *ReportStatusRequest) GetClientOperatorVersion() string { return "" } +func (x *ReportStatusRequest) GetClusterId() string { + if x != nil { + return x.ClusterId + } + return "" +} + +func (x *ReportStatusRequest) GetStorageClientNamespacedName() string { + if x != nil { + return x.StorageClientNamespacedName + } + return "" +} + type ReportStatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -963,7 +997,7 @@ var file_provider_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9e, 0x01, 0x0a, + 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xfe, 0x01, 0x0a, 0x16, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x6f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x54, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, @@ -973,7 +1007,13 @@ var file_provider_proto_rawDesc = []byte{ 0x6d, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x34, 0x0a, 0x15, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, - 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x4b, 0x0a, + 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, + 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x40, 0x0a, 0x1b, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x1b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x4b, 0x0a, 0x17, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x13, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x55, 0x55, 0x49, 0x44, 0x18, @@ -1059,7 +1099,7 @@ var file_provider_proto_rawDesc = []byte{ 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x10, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0xb3, 0x01, 0x0a, 0x13, 0x52, 0x65, 0x70, 0x6f, 0x72, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x93, 0x02, 0x0a, 0x13, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x13, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x55, 0x55, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x73, 0x74, 0x6f, @@ -1070,7 +1110,13 @@ var file_provider_proto_rawDesc = []byte{ 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x34, 0x0a, 0x15, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x16, 0x0a, 0x14, + 0x72, 0x61, 0x74, 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, + 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x40, 0x0a, 0x1b, 0x73, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x1b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x16, 0x0a, 0x14, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb4, 0x06, 0x0a, 0x0b, 0x4f, 0x43, 0x53, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0f, 0x4f, 0x6e, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x43, diff --git a/services/provider/proto/provider.proto b/services/provider/proto/provider.proto index 202a031e33..7a8f689278 100644 --- a/services/provider/proto/provider.proto +++ b/services/provider/proto/provider.proto @@ -49,6 +49,10 @@ message OnboardConsumerRequest{ string consumerName = 2; // clientOperatorVersion is the semver version of ocs-client-operator string clientOperatorVersion = 3; + // clusterID is the id of the openshift cluster + string clusterId = 4; + // storageClientNamespacedName is the name and namespace of the StorageClient + string storageClientNamespacedName = 5; } // OnboardConsumerResponse holds the response for OnboardConsumer API request @@ -159,6 +163,8 @@ message ReportStatusRequest{ string storageConsumerUUID = 1; string clientPlatformVersion = 2; string clientOperatorVersion = 3; + string clusterId = 4; + string storageClientNamespacedName = 5; } message ReportStatusResponse{} diff --git a/services/provider/server/consumer.go b/services/provider/server/consumer.go index 711f27cb4e..f67bf7e7c2 100644 --- a/services/provider/server/consumer.go +++ b/services/provider/server/consumer.go @@ -78,7 +78,9 @@ func (c *ocsConsumerManager) Create(ctx context.Context, onboard ifaces.StorageC }, Status: ocsv1alpha1.StorageConsumerStatus{ Client: ocsv1alpha1.ClientStatus{ - OperatorVersion: onboard.GetClientOperatorVersion(), + OperatorVersion: onboard.GetClientOperatorVersion(), + ClusterID: onboard.GetClusterId(), + StorageClientNamespacedName: onboard.GetStorageClientNamespacedName(), }, }, } @@ -215,6 +217,8 @@ func (c *ocsConsumerManager) UpdateConsumerStatus(ctx context.Context, id string consumerObj.Status.LastHeartbeat = metav1.Now() consumerObj.Status.Client.PlatformVersion = status.GetPlatformVersion() consumerObj.Status.Client.OperatorVersion = status.GetOperatorVersion() + consumerObj.Status.Client.ClusterID = status.GetClusterId() + consumerObj.Status.Client.StorageClientNamespacedName = status.GetStorageClientNamespacedName() if err := c.client.Status().Update(ctx, consumerObj); err != nil { return fmt.Errorf("Failed to patch Status for StorageConsumer %v: %v", consumerObj.Name, err) diff --git a/services/provider/server/server.go b/services/provider/server/server.go index 28b63f0aff..df0c0d6a4f 100644 --- a/services/provider/server/server.go +++ b/services/provider/server/server.go @@ -115,16 +115,16 @@ func (s *OCSProviderServer) OnboardConsumer(ctx context.Context, req *pb.Onboard return nil, status.Errorf(codes.Internal, "failed to create storageConsumer %q. %v", req.ConsumerName, err) } - stoageConsumer, err := s.consumerManager.GetByName(ctx, req.ConsumerName) + storageConsumer, err := s.consumerManager.GetByName(ctx, req.ConsumerName) if err != nil { return nil, status.Errorf(codes.Internal, "Failed to get storageConsumer. %v", err) } - if stoageConsumer.Spec.Enable { + if storageConsumer.Spec.Enable { err = fmt.Errorf("storageconsumers.ocs.openshift.io %s already exists", req.ConsumerName) return nil, status.Errorf(codes.AlreadyExists, "failed to create storageConsumer %q. %v", req.ConsumerName, err) } - storageConsumerUUID = string(stoageConsumer.UID) + storageConsumerUUID = string(storageConsumer.UID) } return &pb.OnboardConsumerResponse{StorageConsumerUUID: storageConsumerUUID}, nil diff --git a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/storageconsumer_types.go b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/storageconsumer_types.go index 0874d9e22a..4a3bcab667 100644 --- a/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/storageconsumer_types.go +++ b/vendor/github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1/storageconsumer_types.go @@ -72,6 +72,10 @@ type ClientStatus struct { PlatformVersion string `json:"platformVersion"` // StorageClient Operator Version OperatorVersion string `json:"operatorVersion"` + // ClusterID is the id of the openshift cluster + ClusterID string `json:"clusterId"` + // StorageClientNamespacedName is the name and namespace of the StorageClient + StorageClientNamespacedName string `json:"storageClientNamespacedName"` } //+kubebuilder:object:root=true