Skip to content

Commit

Permalink
store client information on storageconsumer status
Browse files Browse the repository at this point in the history
- adds new fields to existing RPC message
- these fields are updated in status of corresponding storageconsumer CRs
- the status will be helpful for exporting new metrics

Signed-off-by: Leela Venkaiah G <[email protected]>
  • Loading branch information
leelavg committed Oct 27, 2023
1 parent ff5e2a3 commit 594fcb6
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 84 deletions.
10 changes: 10 additions & 0 deletions api/v1alpha1/storageconsumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ type CephResourcesSpec struct {
CephClients map[string]string `json:"cephClients,omitempty"`
}

// ClientInfo is the information pushed from connected storage client
type ClientInfo struct {
// StorageClient Cluster Version
ClusterVersion string `json:"clusterVersion,omitempty"`
// StorageClient Operator Version
OperatorVersion string `json:"operatorVersion,omitempty"`
}

// StorageConsumerStatus defines the observed state of StorageConsumer
type StorageConsumerStatus struct {
// State describes the state of StorageConsumer
Expand All @@ -62,6 +70,8 @@ type StorageConsumerStatus struct {
CephResources []*CephResourcesSpec `json:"cephResources,omitempty"`
// Timestamp of last heartbeat received from consumer
LastHeartbeat metav1.Time `json:"lastHeartbeat,omitempty"`
// Information of storage client received from consumer
Info ClientInfo `json:"info,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

10 changes: 10 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageconsumers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ spec:
type: string
type: object
type: array
info:
description: Information of storage client received from consumer
properties:
clusterVersion:
description: StorageClient Cluster Version
type: string
operatorVersion:
description: StorageClient Operator Version
type: string
type: object
lastHeartbeat:
description: Timestamp of last heartbeat received from consumer
format: date-time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ spec:
type: string
type: object
type: array
info:
description: Information of storage client received from consumer
properties:
clusterVersion:
description: StorageClient Cluster Version
type: string
operatorVersion:
description: StorageClient Operator Version
type: string
type: object
lastHeartbeat:
description: Timestamp of last heartbeat received from consumer
format: date-time
Expand Down
10 changes: 10 additions & 0 deletions deploy/ocs-operator/manifests/storageconsumer.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ spec:
type: string
type: object
type: array
info:
description: Information of storage client received from consumer
properties:
clusterVersion:
description: StorageClient Cluster Version
type: string
operatorVersion:
description: StorageClient Operator Version
type: string
type: object
lastHeartbeat:
description: Timestamp of last heartbeat received from consumer
format: date-time
Expand Down
8 changes: 6 additions & 2 deletions services/provider/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"time"

consumerstatus "github.com/red-hat-storage/ocs-operator/v4/services/provider/consumerstatus"
pb "github.com/red-hat-storage/ocs-operator/v4/services/provider/pb"

"google.golang.org/grpc"
Expand Down Expand Up @@ -188,12 +189,15 @@ func (cc *OCSProviderClient) GetStorageClassClaimConfig(ctx context.Context, con
return cc.Client.GetStorageClassClaimConfig(apiCtx, req)
}

func (cc *OCSProviderClient) ReportStatus(ctx context.Context, consumerUUID string) (*pb.ReportStatusResponse, error) {
func (cc *OCSProviderClient) ReportStatus(ctx context.Context, consumerUUID string, status consumerstatus.StatusResponse) (*pb.ReportStatusResponse, error) {
if cc.Client == nil || cc.clientConn == nil {
return nil, fmt.Errorf("Provider client is closed")
}

req := &pb.ReportStatusRequest{
StorageConsumerUUID: consumerUUID,
StorageConsumerUUID: consumerUUID,
ClientClusterVersion: status.GetClusterVersion(),
ClientOperatorVersion: status.GetOperatorVersion(),
}
apiCtx, cancel := context.WithTimeout(ctx, cc.timeout)
defer cancel()
Expand Down
21 changes: 21 additions & 0 deletions services/provider/consumerstatus/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package consumerstatus

type StatusResponse interface {
GetClusterVersion() string
GetOperatorVersion() string
}

type Status struct {
ClusterVersion string
OperatorVersion string
}

var _ StatusResponse = &Status{}

func (s *Status) GetClusterVersion() string {
return s.ClusterVersion
}

func (s *Status) GetOperatorVersion() string {
return s.OperatorVersion
}
139 changes: 81 additions & 58 deletions services/provider/pb/provider.pb.go

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

2 changes: 2 additions & 0 deletions services/provider/proto/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ message StorageClassClaimConfigResponse{

message ReportStatusRequest{
string storageConsumerUUID = 1;
string clientClusterVersion = 2;
string clientOperatorVersion = 3;
}

message ReportStatusResponse{}
Loading

0 comments on commit 594fcb6

Please sign in to comment.