Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add suffix for external ceph client secret name during gRPC response #2512

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,10 @@ func (s *OCSProviderServer) GetStorageClassClaimConfig(ctx context.Context, req
keyProp = "adminKey"
}
extR = append(extR, &pb.ExternalResource{
Name: clientSecretName,
// a common suffix '.csi' is being added to distinguish secrets that are created
nb-ohad marked this conversation as resolved.
Show resolved Hide resolved
// by ocs-client-operator vs rook-operator when both these operators are deployed in same namespace
// TODO: need to transform existing secrets during migration manually
Name: clientSecretName + ".csi",
Kind: "Secret",
Data: mustMarshal(map[string]string{
idProp: cephRes.Name,
Expand Down
23 changes: 21 additions & 2 deletions services/provider/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"strconv"
"strings"
"testing"

ocsv1alpha1 "github.com/red-hat-storage/ocs-operator/api/v4/v1alpha1"
Expand Down Expand Up @@ -841,6 +842,10 @@ func TestOCSProviderServerGetStorageClassClaimConfig(t *testing.T) {
name = fmt.Sprintf("%s-volumesnapshotclass", name)
} else if extResource.Kind == "StorageClass" {
name = fmt.Sprintf("%s-storageclass", name)
} else if extResource.Kind == "Secret" {
var found bool
name, found = strings.CutSuffix(name, ".csi")
assert.True(t, found)
}
mockResoruce, ok := mockBlockPoolClaimExtR[name]
assert.True(t, ok)
Expand All @@ -849,7 +854,12 @@ func TestOCSProviderServerGetStorageClassClaimConfig(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, string(extResource.Data), string(data))
assert.Equal(t, extResource.Kind, mockResoruce.Kind)
assert.Equal(t, extResource.Name, mockResoruce.Name)
if extResource.Kind == "Secret" {
name, _ := strings.CutSuffix(name, ".csi")
assert.Equal(t, name, mockResoruce.Name)
} else {
assert.Equal(t, extResource.Name, mockResoruce.Name)
}
}

// get the storage class request config for share filesystem
Expand All @@ -868,6 +878,10 @@ func TestOCSProviderServerGetStorageClassClaimConfig(t *testing.T) {
name = fmt.Sprintf("%s-volumesnapshotclass", name)
} else if extResource.Kind == "StorageClass" {
name = fmt.Sprintf("%s-storageclass", name)
} else if extResource.Kind == "Secret" {
var found bool
name, found = strings.CutSuffix(name, ".csi")
assert.True(t, found)
}
mockResoruce, ok := mockShareFilesystemClaimExtR[name]
assert.True(t, ok)
Expand All @@ -876,7 +890,12 @@ func TestOCSProviderServerGetStorageClassClaimConfig(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, string(extResource.Data), string(data))
assert.Equal(t, extResource.Kind, mockResoruce.Kind)
assert.Equal(t, extResource.Name, mockResoruce.Name)
if extResource.Kind == "Secret" {
name, _ := strings.CutSuffix(name, ".csi")
assert.Equal(t, name, mockResoruce.Name)
} else {
assert.Equal(t, extResource.Name, mockResoruce.Name)
}
}

// When ceph resources is empty
Expand Down
Loading