Skip to content

Commit

Permalink
client: use storageclient k8s id as the client id
Browse files Browse the repository at this point in the history
Signed-off-by: Rewant Soni <[email protected]>
  • Loading branch information
rewantsoni committed Nov 13, 2024
1 parent 99fdb66 commit c5d8931
Show file tree
Hide file tree
Showing 15 changed files with 210 additions and 149 deletions.
5 changes: 5 additions & 0 deletions api/v1alpha1/storageconsumer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

// StorageConsumerState represent a StorageConsumer's state
Expand Down Expand Up @@ -94,6 +95,10 @@ type ClientStatus struct {
// StorageQuotaUtilizationRatio is the ratio of utilized quota of connected client
// +optional
StorageQuotaUtilizationRatio float64 `json:"storageQuotaUtilizationRatio,omitempty"`

// ID is the k8s UID of connected storageclient
// +optional
ID types.UID `json:"clientId,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageconsumers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ spec:
client:
description: Information of storage client received from consumer
properties:
clientId:
description: ID is the k8s UID of connected storageclient
type: string
clusterId:
description: ClusterID is the id of the openshift cluster
type: string
Expand Down
2 changes: 1 addition & 1 deletion controllers/storagecluster/odfinfoconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func getConnectedClients(r *StorageClusterReconciler, storageCluster *ocsv1.Stor
newConnectedClient := ocsv1a1.ConnectedClient{
Name: name,
ClusterID: clusterID,
ClientID: string(storageConsumer.UID),
ClientID: string(storageConsumer.Status.Client.ID),
}
connectedClients = append(connectedClients, newConnectedClient)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ spec:
client:
description: Information of storage client received from consumer
properties:
clientId:
description: ID is the k8s UID of connected storageclient
type: string
clusterId:
description: ClusterID is the id of the openshift cluster
type: string
Expand Down
3 changes: 3 additions & 0 deletions deploy/ocs-operator/manifests/storageconsumer.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ spec:
client:
description: Information of storage client received from consumer
properties:
clientId:
description: ID is the k8s UID of connected storageclient
type: string
clusterId:
description: ClusterID is the id of the openshift cluster
type: string
Expand Down

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/api/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ type StorageClientStatus interface {
GetClusterID() string
GetClusterName() string
GetClientName() string
GetClientID() string
GetStorageQuotaUtilizationRatio() float64

SetPlatformVersion(string) StorageClientStatus
SetOperatorVersion(string) StorageClientStatus
SetClusterID(string) StorageClientStatus
SetClusterName(string) StorageClientStatus
SetClientName(string) StorageClientStatus
SetClientID(string) StorageClientStatus
SetStorageQuotaUtilizationRatio(float64) StorageClientStatus
}

Expand Down
158 changes: 84 additions & 74 deletions services/provider/api/provider.pb.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions services/provider/api/storageclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func (r *ReportStatusRequest) SetClusterName(clusterName string) ifaces.StorageC
return r
}

func (r *ReportStatusRequest) SetClientID(clientID string) ifaces.StorageClientStatus {
r.ClientID = clientID
return r
}

func (r *ReportStatusRequest) SetStorageQuotaUtilizationRatio(storageQuotaUtilizationRatio float64) ifaces.StorageClientStatus {
r.StorageQuotaUtilizationRatio = storageQuotaUtilizationRatio
return r
Expand Down
2 changes: 2 additions & 0 deletions services/provider/proto/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ message ReportStatusRequest{
string clientName = 6;
// storageQuotaUtilizationRatio is the ratio of utilized quota of connected client
double storageQuotaUtilizationRatio = 7;
// clientID is the k8s UID of storageClient
string clientID = 8;

}

Expand Down
1 change: 1 addition & 0 deletions services/provider/server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func (c *ocsConsumerManager) UpdateConsumerStatus(ctx context.Context, id string
consumerObj.Status.Client.OperatorVersion = status.GetOperatorVersion()
consumerObj.Status.Client.ClusterID = status.GetClusterID()
consumerObj.Status.Client.Name = status.GetClientName()
consumerObj.Status.Client.ID = types.UID(status.GetClientID())
consumerObj.Status.Client.ClusterName = status.GetClusterName()
consumerObj.Status.Client.StorageQuotaUtilizationRatio = status.GetStorageQuotaUtilizationRatio()

Expand Down

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

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

Loading

0 comments on commit c5d8931

Please sign in to comment.