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 31, 2023
1 parent c97cd5a commit 4686adb
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 106 deletions.
10 changes: 10 additions & 0 deletions api/v1alpha1/storageconsumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ 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
Client ClientStatus `json:"client,omitempty"`
}

// ClientStatus is the information pushed from connected storage client
type ClientStatus struct {
// StorageClient Platform Version
PlatformVersion string `json:"platformVersion"`
// StorageClient Operator Version
OperatorVersion string `json:"operatorVersion"`
}

//+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.

13 changes: 13 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,19 @@ spec:
type: string
type: object
type: array
client:
description: Information of storage client received from consumer
properties:
operatorVersion:
description: StorageClient Operator Version
type: string
platformVersion:
description: StorageClient Platform Version
type: string
required:
- operatorVersion
- platformVersion
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,19 @@ spec:
type: string
type: object
type: array
client:
description: Information of storage client received from consumer
properties:
operatorVersion:
description: StorageClient Operator Version
type: string
platformVersion:
description: StorageClient Platform Version
type: string
required:
- operatorVersion
- platformVersion
type: object
lastHeartbeat:
description: Timestamp of last heartbeat received from consumer
format: date-time
Expand Down
13 changes: 13 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,19 @@ spec:
type: string
type: object
type: array
client:
description: Information of storage client received from consumer
properties:
operatorVersion:
description: StorageClient Operator Version
type: string
platformVersion:
description: StorageClient Platform Version
type: string
required:
- operatorVersion
- platformVersion
type: object
lastHeartbeat:
description: Timestamp of last heartbeat received from consumer
format: date-time
Expand Down
14 changes: 10 additions & 4 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"

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

"google.golang.org/grpc"
Expand Down Expand Up @@ -188,13 +189,18 @@ 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 NewStorageClientStatus() cs.StorageClientStatus {
return &pb.ReportStatusRequest{}
}

func (cc *OCSProviderClient) ReportStatus(ctx context.Context, consumerUUID string, status cs.StorageClientStatus) (*pb.ReportStatusResponse, error) {
if cc.Client == nil || cc.clientConn == nil {
return nil, fmt.Errorf("Provider client is closed")
}
req := &pb.ReportStatusRequest{
StorageConsumerUUID: consumerUUID,
}

// panic if the request wasn't constructed using "NewStorageClientStatus()"
req := status.(*pb.ReportStatusRequest)
req.StorageConsumerUUID = consumerUUID
apiCtx, cancel := context.WithTimeout(ctx, cc.timeout)
defer cancel()

Expand Down
9 changes: 9 additions & 0 deletions services/provider/clientstatus/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package clientstatus

type StorageClientStatus interface {
GetPlatformVersion() string
GetOperatorVersion() string

SetPlatformVersion(string) StorageClientStatus
SetOperatorVersion(string) StorageClientStatus
}
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.

26 changes: 26 additions & 0 deletions services/provider/pb/storageclient_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package providerpb

import (
cs "github.com/red-hat-storage/ocs-operator/v4/services/provider/clientstatus"
)

// ensure ReportStatusRequest satisfies StorageClientStatus interface
var _ cs.StorageClientStatus = &ReportStatusRequest{}

func (r *ReportStatusRequest) GetPlatformVersion() string {
return r.ClientPlatformVersion
}

func (r *ReportStatusRequest) GetOperatorVersion() string {
return r.ClientOperatorVersion
}

func (r *ReportStatusRequest) SetPlatformVersion(version string) cs.StorageClientStatus {
r.ClientPlatformVersion = version
return r
}

func (r *ReportStatusRequest) SetOperatorVersion(version string) cs.StorageClientStatus {
r.ClientOperatorVersion = version
return r
}
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 clientPlatformVersion = 2;
string clientOperatorVersion = 3;
}

message ReportStatusResponse{}
Loading

0 comments on commit 4686adb

Please sign in to comment.