Skip to content

Commit

Permalink
Merge pull request #2930 from rewantsoni/fix-server
Browse files Browse the repository at this point in the history
provider: provide namespace for storage-client-mapping config
Signed-off-by: rchikatw <[email protected]>
  • Loading branch information
openshift-merge-bot[bot] authored and rchikatw committed Dec 9, 2024
2 parents 61f6999 + ac49789 commit 384859e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
5 changes: 0 additions & 5 deletions services/provider/api/interfaces/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ type StorageClientStatus interface {
// no client is using it
GetPlatformVersion() string
GetOperatorVersion() string
GetClusterID() string
GetClusterName() string
GetClientName() string
GetClientID() string
GetStorageQuotaUtilizationRatio() float64

SetPlatformVersion(string) StorageClientStatus
SetOperatorVersion(string) StorageClientStatus
Expand Down
3 changes: 2 additions & 1 deletion services/provider/server/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"

ocsv1alpha1 "github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1"
pb "github.com/red-hat-storage/ocs-operator/services/provider/api/v4"
ifaces "github.com/red-hat-storage/ocs-operator/services/provider/api/v4/interfaces"
"github.com/red-hat-storage/ocs-operator/v4/controllers/util"

Expand Down Expand Up @@ -209,7 +210,7 @@ func (c *ocsConsumerManager) Get(ctx context.Context, id string) (*ocsv1alpha1.S
return consumerObj, nil
}

func (c *ocsConsumerManager) UpdateConsumerStatus(ctx context.Context, id string, status ifaces.StorageClientStatus) error {
func (c *ocsConsumerManager) UpdateConsumerStatus(ctx context.Context, id string, status *pb.ReportStatusRequest) error {
consumerObj, err := c.Get(ctx, id)
if err != nil {
return err
Expand Down
4 changes: 3 additions & 1 deletion services/provider/server/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
opv1a1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
api "github.com/red-hat-storage/ocs-operator/api/v4/v1"
ocsv1alpha1 "github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1"
pb "github.com/red-hat-storage/ocs-operator/services/provider/api/v4"
providerClient "github.com/red-hat-storage/ocs-operator/services/provider/api/v4/client"
rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -217,7 +218,8 @@ func TestUpdateConsumerStatus(t *testing.T) {
fields := providerClient.NewStorageClientStatus().
SetPlatformVersion("1.0.0").
SetOperatorVersion("1.0.0")
err = consumerManager.UpdateConsumerStatus(ctx, "uid1", fields)
status := fields.(*pb.ReportStatusRequest)
err = consumerManager.UpdateConsumerStatus(ctx, "uid1", status)
assert.NoError(t, err)

c1, err := consumerManager.Get(ctx, "uid1")
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 @@ -238,7 +238,7 @@ func (s *OCSProviderServer) GetStorageConfig(ctx context.Context, req *pb.Storag
isConsumerMirrorEnabled, err := s.isConsumerMirrorEnabled(ctx, consumerObj)
if err != nil {
klog.Error(err)
return nil, status.Errorf(codes.Internal, "Failed to get maintenance mode status.")
return nil, status.Errorf(codes.Internal, "Failed to get mirroring status for consumer.")
}

desiredClientConfigHash := getDesiredClientConfigHash(
Expand Down Expand Up @@ -1016,7 +1016,7 @@ func (s *OCSProviderServer) ReportStatus(ctx context.Context, req *pb.ReportStat
isConsumerMirrorEnabled, err := s.isConsumerMirrorEnabled(ctx, storageConsumer)
if err != nil {
klog.Error(err)
return nil, status.Errorf(codes.Internal, "Failed to get maintenance mode status.")
return nil, status.Errorf(codes.Internal, "Failed to get mirroring status for consumer.")
}

desiredClientConfigHash := getDesiredClientConfigHash(
Expand Down Expand Up @@ -1273,7 +1273,7 @@ func (s *OCSProviderServer) isSystemInMaintenanceMode(ctx context.Context) (bool
func (s *OCSProviderServer) isConsumerMirrorEnabled(ctx context.Context, consumer *ocsv1alpha1.StorageConsumer) (bool, error) {
clientMappingConfig := &corev1.ConfigMap{}
clientMappingConfig.Name = util.StorageClientMappingConfigName
clientMappingConfig.Name = s.namespace
clientMappingConfig.Namespace = s.namespace

if err := s.client.Get(ctx, client.ObjectKeyFromObject(clientMappingConfig), clientMappingConfig); err != nil {
return false, client.IgnoreNotFound(err)
Expand Down

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

0 comments on commit 384859e

Please sign in to comment.