Skip to content

Commit

Permalink
Sends VolumeGroupSnapshotClass to client
Browse files Browse the repository at this point in the history
Signed-off-by: raaizik <[email protected]>
  • Loading branch information
raaizik committed Jun 23, 2024
1 parent b18b234 commit 33f4080
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 34 deletions.
83 changes: 49 additions & 34 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,19 +611,27 @@ func (s *OCSProviderServer) GetStorageClaimConfig(ctx context.Context, req *pb.S
rbdStorageClassData["encryptionKMSID"] = storageRequest.Spec.EncryptionMethod
}

extR = append(extR, &pb.ExternalResource{
Name: "ceph-rbd",
Kind: "StorageClass",
Data: mustMarshal(rbdStorageClassData),
})

extR = append(extR, &pb.ExternalResource{
Name: "ceph-rbd",
Kind: "VolumeSnapshotClass",
Data: mustMarshal(map[string]string{
"clusterID": rbdStorageClassData["clusterID"],
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})})
cephRBDClusterID := rbdStorageClassData["clusterID"]
extR = append(extR,
&pb.ExternalResource{
Name: "ceph-rbd",
Kind: "StorageClass",
Data: mustMarshal(rbdStorageClassData),
},
&pb.ExternalResource{
Name: "ceph-rbd",
Kind: "VolumeSnapshotClass",
Data: mustMarshal(map[string]string{
"clusterID": cephRBDClusterID,
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})},
&pb.ExternalResource{
Name: "ceph-rbd",
Kind: "VolumeGroupSnapshotClass",
Data: mustMarshal(map[string]string{
"clusterID": cephRBDClusterID,
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})})

case "CephFilesystemSubVolumeGroup":
subVolumeGroup := &rookCephv1.CephFilesystemSubVolumeGroup{}
Expand All @@ -634,8 +642,9 @@ func (s *OCSProviderServer) GetStorageClaimConfig(ctx context.Context, req *pb.S

provisionerSecretName := storageClaimCephCsiSecretName("provisioner", storageRequestHash)
nodeSecretName := storageClaimCephCsiSecretName("node", storageRequestHash)
cephFSClusterID := getSubVolumeGroupClusterID(subVolumeGroup)
cephfsStorageClassData := map[string]string{
"clusterID": getSubVolumeGroupClusterID(subVolumeGroup),
"clusterID": cephFSClusterID,
"subvolumegroupname": subVolumeGroup.Name,
"fsName": subVolumeGroup.Spec.FilesystemName,
"pool": subVolumeGroup.GetLabels()[v1alpha1.CephFileSystemDataPoolLabel],
Expand All @@ -644,26 +653,32 @@ func (s *OCSProviderServer) GetStorageClaimConfig(ctx context.Context, req *pb.S
"csi.storage.k8s.io/controller-expand-secret-name": provisionerSecretName,
}

extR = append(extR, &pb.ExternalResource{
Name: "cephfs",
Kind: "StorageClass",
Data: mustMarshal(cephfsStorageClassData),
})

extR = append(extR, &pb.ExternalResource{
Name: cephRes.Name,
Kind: cephRes.Kind,
Data: mustMarshal(map[string]string{
"filesystemName": subVolumeGroup.Spec.FilesystemName,
})})

extR = append(extR, &pb.ExternalResource{
Name: "cephfs",
Kind: "VolumeSnapshotClass",
Data: mustMarshal(map[string]string{
"clusterID": getSubVolumeGroupClusterID(subVolumeGroup),
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})})
extR = append(extR,
&pb.ExternalResource{
Name: "cephfs",
Kind: "StorageClass",
Data: mustMarshal(cephfsStorageClassData),
},
&pb.ExternalResource{
Name: cephRes.Name,
Kind: cephRes.Kind,
Data: mustMarshal(map[string]string{
"filesystemName": subVolumeGroup.Spec.FilesystemName,
})},
&pb.ExternalResource{
Name: "cephfs",
Kind: "VolumeSnapshotClass",
Data: mustMarshal(map[string]string{
"clusterID": cephFSClusterID,
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})},
&pb.ExternalResource{
Name: "cephfs",
Kind: "VolumeGroupSnapshotClass",
Data: mustMarshal(map[string]string{
"clusterID": cephFSClusterID,
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})})
}
}

Expand Down
21 changes: 21 additions & 0 deletions services/provider/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,14 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
"csi.storage.k8s.io/snapshotter-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
},
},
"ceph-rbd-volumegroupsnapshotclass": {
Name: "ceph-rbd",
Kind: "VolumeGroupSnapshotClass",
Data: map[string]string{
"clusterID": serverNamespace,
"csi.storage.k8s.io/snapshotter-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
},
},
"ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c": {
Name: "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
Kind: "Secret",
Expand Down Expand Up @@ -551,6 +559,15 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
"csi.storage.k8s.io/snapshotter-secret-name": "ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c",
},
},

"cephfs-volumegroupsnapshotclass": {
Name: "cephfs",
Kind: "VolumeGroupSnapshotClass",
Data: map[string]string{
"clusterID": "8d26c7378c1b0ec9c2455d1c3601c4cd",
"csi.storage.k8s.io/snapshotter-secret-name": "ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c",
},
},
"ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c": {
Name: "ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c",
Kind: "Secret",
Expand Down Expand Up @@ -853,6 +870,8 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
name = fmt.Sprintf("%s-volumesnapshotclass", name)
} else if extResource.Kind == "StorageClass" {
name = fmt.Sprintf("%s-storageclass", name)
} else if extResource.Kind == "VolumeGroupSnapshotClass" {
name = fmt.Sprintf("%s-volumegroupsnapshotclass", name)
}
mockResoruce, ok := mockBlockPoolClaimExtR[name]
assert.True(t, ok)
Expand Down Expand Up @@ -880,6 +899,8 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
name = fmt.Sprintf("%s-volumesnapshotclass", name)
} else if extResource.Kind == "StorageClass" {
name = fmt.Sprintf("%s-storageclass", name)
} else if extResource.Kind == "VolumeGroupSnapshotClass" {
name = fmt.Sprintf("%s-volumegroupsnapshotclass", name)
}
mockResoruce, ok := mockShareFilesystemClaimExtR[name]
assert.True(t, ok)
Expand Down

0 comments on commit 33f4080

Please sign in to comment.