Skip to content

Commit

Permalink
Sends V*ReplicationClass to client
Browse files Browse the repository at this point in the history
Sends two V*RCs (one for image flattening) for RDR

Signed-off-by: raaizik <132667934+raaizik@users.noreply.github.com>
  • Loading branch information
raaizik committed Sep 11, 2024
1 parent b82b171 commit bd6ccbb
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 4 deletions.
50 changes: 50 additions & 0 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,56 @@ func (s *OCSProviderServer) GetStorageClaimConfig(ctx context.Context, req *pb.S
Data: mustMarshal(map[string]string{
"csi.storage.k8s.io/group-snapshotter-secret-name": provisionerSecretName,
})},
&pb.ExternalResource{
Name: "ceph-rbd",
Kind: "VolumeReplicationClass",
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/replication-secret-name": provisionerSecretName,
"mirroringMode": "snapshot",
}),
Annotations: map[string]string{
"replication.storage.openshift.io/is-default-class": "true",
},
},
&pb.ExternalResource{
Name: "ceph-rbd-flatten",
Kind: "VolumeReplicationClass",
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/replication-secret-name": provisionerSecretName,
"mirroringMode": "snapshot",
}),
Labels: map[string]string{
"flattenMode": "force",
},
Annotations: map[string]string{
"replication.storage.openshift.io/flatten-mode": "force",
},
},
&pb.ExternalResource{
Name: "ceph-rbd",
Kind: "VolumeGroupReplicationClass",
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/group-replication-secret-name": provisionerSecretName,
"mirroringMode": "snapshot",
}),
Annotations: map[string]string{
"replication.storage.openshift.io/is-default-class": "true",
},
},
&pb.ExternalResource{
Name: "ceph-rbd-flatten",
Kind: "VolumeGroupReplicationClass",
Data: mustMarshal(map[string]string{
"replication.storage.openshift.io/group-replication-secret-name": provisionerSecretName,
"mirroringMode": "snapshot",
}),
Labels: map[string]string{
"flattenMode": "force",
},
Annotations: map[string]string{
"replication.storage.openshift.io/flatten-mode": "force",
},
},
&pb.ExternalResource{
Kind: "ClientProfile",
Name: "ceph-rbd",
Expand Down
80 changes: 76 additions & 4 deletions services/provider/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"reflect"
"strconv"
"testing"

Expand All @@ -29,9 +30,11 @@ import (
)

type externalResource struct {
Kind string `json:"kind"`
Data any `json:"data"`
Name string `json:"name"`
Kind string `json:"kind"`
Data any `json:"data"`
Name string `json:"name"`
Labels map[string]string `json:"labels"`
Annotations map[string]string `json:"annotations"`
}

var serverNamespace = "openshift-storage"
Expand Down Expand Up @@ -350,7 +353,10 @@ func TestGetExternalResources(t *testing.T) {
data, err := json.Marshal(mockResoruce.Data)
assert.NoError(t, err)
assert.Equal(t, string(extResource.Data), string(data))

}
assert.True(t, reflect.DeepEqual(extResource.Labels, mockResoruce.Labels))
assert.True(t, reflect.DeepEqual(extResource.Annotations, mockResoruce.Annotations))
assert.Equal(t, extResource.Kind, mockResoruce.Kind)
assert.Equal(t, extResource.Name, mockResoruce.Name)
}
Expand Down Expand Up @@ -388,7 +394,8 @@ func TestGetExternalResources(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, string(extResource.Data), string(data))
}

assert.True(t, reflect.DeepEqual(extResource.Labels, mockResoruce.Labels))
assert.True(t, reflect.DeepEqual(extResource.Annotations, mockResoruce.Annotations))
assert.Equal(t, extResource.Kind, mockResoruce.Kind)
assert.Equal(t, extResource.Name, mockResoruce.Name)
}
Expand Down Expand Up @@ -681,6 +688,57 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
"csi.storage.k8s.io/group-snapshotter-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
},
},
"ceph-rbd-volumereplicationclass": {
Name: "ceph-rbd",
Kind: "VolumeReplicationClass",
Data: map[string]string{
"replication.storage.openshift.io/replication-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
"mirroringMode": "snapshot",
},

Annotations: map[string]string{
"replication.storage.openshift.io/is-default-class": "true",
},
},
"ceph-rbd-flatten-volumereplicationclass": {
Name: "ceph-rbd-flatten",
Kind: "VolumeReplicationClass",
Data: map[string]string{
"replication.storage.openshift.io/replication-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
"mirroringMode": "snapshot",
},
Labels: map[string]string{
"flattenMode": "force",
},
Annotations: map[string]string{
"replication.storage.openshift.io/flatten-mode": "force",
},
},
"ceph-rbd-volumegroupreplicationclass": {
Name: "ceph-rbd",
Kind: "VolumeGroupReplicationClass",
Data: map[string]string{
"replication.storage.openshift.io/group-replication-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
"mirroringMode": "snapshot",
},
Annotations: map[string]string{
"replication.storage.openshift.io/is-default-class": "true",
},
},
"ceph-rbd-flatten-volumegroupreplicationclass": {
Name: "ceph-rbd-flatten",
Kind: "VolumeGroupReplicationClass",
Data: map[string]string{
"replication.storage.openshift.io/group-replication-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
"mirroringMode": "snapshot",
},
Labels: map[string]string{
"flattenMode": "force",
},
Annotations: map[string]string{
"replication.storage.openshift.io/flatten-mode": "force",
},
},
"ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c": {
Name: "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
Kind: "Secret",
Expand Down Expand Up @@ -1065,6 +1123,10 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
name = fmt.Sprintf("%s-storageclass", name)
} else if extResource.Kind == "VolumeGroupSnapshotClass" {
name = fmt.Sprintf("%s-volumegroupsnapshotclass", name)
} else if extResource.Kind == "VolumeReplicationClass" {
name = fmt.Sprintf("%s-volumereplicationclass", name)
} else if extResource.Kind == "VolumeGroupReplicationClass" {
name = fmt.Sprintf("%s-volumegroupreplicationclass", name)
} else if extResource.Kind == "ClientProfile" {
name = fmt.Sprintf("%s-clientprofile", name)
}
Expand All @@ -1074,6 +1136,10 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
data, err := json.Marshal(mockResoruce.Data)
assert.NoError(t, err)
assert.Equal(t, string(extResource.Data), string(data))
assert.NoError(t, err)
assert.True(t, reflect.DeepEqual(extResource.Labels, mockResoruce.Labels))
assert.NoError(t, err)
assert.True(t, reflect.DeepEqual(extResource.Annotations, mockResoruce.Annotations))
assert.Equal(t, extResource.Kind, mockResoruce.Kind)
assert.Equal(t, extResource.Name, mockResoruce.Name)
}
Expand All @@ -1096,6 +1162,10 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
name = fmt.Sprintf("%s-storageclass", name)
} else if extResource.Kind == "VolumeGroupSnapshotClass" {
name = fmt.Sprintf("%s-volumegroupsnapshotclass", name)
} else if extResource.Kind == "VolumeReplicationClass" {
name = fmt.Sprintf("%s-volumereplicationclass", name)
} else if extResource.Kind == "VolumeGroupReplicationClass" {
name = fmt.Sprintf("%s-volumegroupreplicationclass", name)
} else if extResource.Kind == "ClientProfile" {
name = fmt.Sprintf("%s-clientprofile", name)
}
Expand All @@ -1104,6 +1174,8 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
data, err := json.Marshal(mockResoruce.Data)
assert.NoError(t, err)
assert.Equal(t, string(extResource.Data), string(data))
assert.True(t, reflect.DeepEqual(extResource.Labels, mockResoruce.Labels))
assert.True(t, reflect.DeepEqual(extResource.Annotations, mockResoruce.Annotations))
assert.Equal(t, extResource.Kind, mockResoruce.Kind)
assert.Equal(t, extResource.Name, mockResoruce.Name)
}
Expand Down

0 comments on commit bd6ccbb

Please sign in to comment.