Skip to content

Commit

Permalink
Introduce client csi metrics
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 6, 2023
1 parent d290a42 commit 54dd712
Show file tree
Hide file tree
Showing 13 changed files with 248 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
16 changes: 14 additions & 2 deletions services/provider/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

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

"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -188,12 +189,23 @@ 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, fields ...status.Field) (*pb.ReportStatusResponse, error) {
if cc.Client == nil || cc.clientConn == nil {
return nil, fmt.Errorf("Provider client is closed")
}

var info status.Fields
for _, field := range fields {
err := field(&info)
if err != nil {
return nil, fmt.Errorf("Misformed status fields data: %v", err)

Check failure on line 201 in services/provider/client/client.go

View workflow job for this annotation

GitHub Actions / verify code spellings

Misformed ==> Malformed
}
}

req := &pb.ReportStatusRequest{
StorageConsumerUUID: consumerUUID,
StorageConsumerUUID: consumerUUID,
ClientClusterVersion: info.ClusterVersion,
ClientOperatorVersion: info.OperatorVersion,
}
apiCtx, cancel := context.WithTimeout(ctx, cc.timeout)
defer cancel()
Expand Down
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 54dd712

Please sign in to comment.