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 13, 2024
1 parent 35ac7ee commit 24bec9c
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 149 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"`
// NamespacedName is the name and namespace of the StorageClient
NamespacedName string `json:"namespacedName"`
}

//+kubebuilder:object:root=true
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageconsumers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,21 @@ spec:
client:
description: Information of storage client received from consumer
properties:
clusterId:
description: ClusterID is the id of the openshift cluster
type: string
namespacedName:
description: NamespacedName is the name and namespace of the StorageClient
type: string
operatorVersion:
description: StorageClient Operator Version
type: string
platformVersion:
description: StorageClient Platform Version
type: string
required:
- clusterId
- namespacedName
- operatorVersion
- platformVersion
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,21 @@ spec:
client:
description: Information of storage client received from consumer
properties:
clusterId:
description: ClusterID is the id of the openshift cluster
type: string
namespacedName:
description: NamespacedName is the name and namespace of the StorageClient
type: string
operatorVersion:
description: StorageClient Operator Version
type: string
platformVersion:
description: StorageClient Platform Version
type: string
required:
- clusterId
- namespacedName
- operatorVersion
- platformVersion
type: object
Expand Down
8 changes: 8 additions & 0 deletions deploy/ocs-operator/manifests/storageconsumer.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,21 @@ spec:
client:
description: Information of storage client received from consumer
properties:
clusterId:
description: ClusterID is the id of the openshift cluster
type: string
namespacedName:
description: NamespacedName is the name and namespace of the StorageClient
type: string
operatorVersion:
description: StorageClient Operator Version
type: string
platformVersion:
description: StorageClient Platform Version
type: string
required:
- clusterId
- namespacedName
- operatorVersion
- platformVersion
type: object
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 @@ -16,8 +16,12 @@ type StorageClientOnboarding interface {
GetOnboardingTicket() string
GetConsumerName() string
GetClientOperatorVersion() string
GetClusterId() string
GetNamespacedName() string

SetOnboardingTicket(string) StorageClientOnboarding
SetConsumerName(string) StorageClientOnboarding
SetClientOperatorVersion(string) StorageClientOnboarding
SetClusterID(string) StorageClientOnboarding
SetNamespacedName(string) StorageClientOnboarding
}
314 changes: 168 additions & 146 deletions services/provider/pb/provider.pb.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions services/provider/pb/storageclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ func (o *OnboardConsumerRequest) SetClientOperatorVersion(version string) ifaces
o.ClientOperatorVersion = version
return o
}

func (o *OnboardConsumerRequest) SetClusterID(clusterID string) ifaces.StorageClientOnboarding {
o.ClusterId = clusterID
return o
}

func (o *OnboardConsumerRequest) SetNamespacedName(namespacedName string) ifaces.StorageClientOnboarding {
o.NamespacedName = namespacedName
return o
}
4 changes: 4 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;
// NamespacedName is the name and namespace of the StorageClient
string NamespacedName = 5;
}

// OnboardConsumerResponse holds the response for OnboardConsumer API request
Expand Down
2 changes: 2 additions & 0 deletions services/provider/server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func (c *ocsConsumerManager) Create(ctx context.Context, onboard ifaces.StorageC
Status: ocsv1alpha1.StorageConsumerStatus{
Client: ocsv1alpha1.ClientStatus{
OperatorVersion: onboard.GetClientOperatorVersion(),
ClusterID: onboard.GetClusterId(),
NamespacedName: onboard.GetNamespacedName(),
},
},
}
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 24bec9c

Please sign in to comment.