Skip to content

Commit

Permalink
ODF info CM: exporting client info
Browse files Browse the repository at this point in the history
Signed-off-by: raaizik <[email protected]>
  • Loading branch information
raaizik committed Mar 11, 2024
1 parent 35ac7ee commit e55c08b
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 11 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/storageconsumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageconsumers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions deploy/ocs-operator/manifests/storageconsumer.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions services/provider/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,6 +18,8 @@ type StorageClientOnboarding interface {
GetOnboardingTicket() string
GetConsumerName() string
GetClientOperatorVersion() string
GetClusterId() string
GetStorageClientNamespacedName() string

SetOnboardingTicket(string) StorageClientOnboarding
SetConsumerName(string) StorageClientOnboarding
Expand Down
60 changes: 53 additions & 7 deletions services/provider/pb/provider.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions services/provider/proto/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -159,6 +163,8 @@ message ReportStatusRequest{
string storageConsumerUUID = 1;
string clientPlatformVersion = 2;
string clientOperatorVersion = 3;
string clusterId = 4;
string storageClientNamespacedName = 5;
}

message ReportStatusResponse{}
6 changes: 5 additions & 1 deletion services/provider/server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
},
}
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e55c08b

Please sign in to comment.