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

Sends VolumeGroupSnapshotClass to client #2661

Merged
merged 1 commit into from
Jul 15, 2024
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
75 changes: 42 additions & 33 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,19 +611,24 @@ 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,
})})
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{
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})},
&pb.ExternalResource{
Name: "ceph-rbd",
Kind: "VolumeGroupSnapshotClass",
Data: mustMarshal(map[string]string{
"csi.storage.k8s.io/group-snapshotter-secret-name": provisionerSecretName,
})})

case "CephFilesystemSubVolumeGroup":
subVolumeGroup := &rookCephv1.CephFilesystemSubVolumeGroup{}
Expand All @@ -644,26 +649,30 @@ 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{
"csi.storage.k8s.io/snapshotter-secret-name": provisionerSecretName,
})},
&pb.ExternalResource{
Name: "cephfs",
Kind: "VolumeGroupSnapshotClass",
Data: mustMarshal(map[string]string{
"csi.storage.k8s.io/group-snapshotter-secret-name": provisionerSecretName,
})})
}
}

Expand Down
21 changes: 19 additions & 2 deletions services/provider/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,16 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
Name: "ceph-rbd",
Kind: "VolumeSnapshotClass",
Data: map[string]string{
"clusterID": serverNamespace,
"csi.storage.k8s.io/snapshotter-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
},
},
"ceph-rbd-volumegroupsnapshotclass": {
Name: "ceph-rbd",
Kind: "VolumeGroupSnapshotClass",
Data: map[string]string{
"csi.storage.k8s.io/group-snapshotter-secret-name": "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
},
},
"ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c": {
Name: "ceph-client-provisioner-8d40b6be71600457b5dec219d2ce2d4c",
Kind: "Secret",
Expand Down Expand Up @@ -547,10 +553,17 @@ func TestOCSProviderServerGetStorageClaimConfig(t *testing.T) {
Name: "cephfs",
Kind: "VolumeSnapshotClass",
Data: map[string]string{
"clusterID": "8d26c7378c1b0ec9c2455d1c3601c4cd",
"csi.storage.k8s.io/snapshotter-secret-name": "ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c",
},
},

"cephfs-volumegroupsnapshotclass": {
Name: "cephfs",
Kind: "VolumeGroupSnapshotClass",
Data: map[string]string{
"csi.storage.k8s.io/group-snapshotter-secret-name": "ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c",
},
},
"ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c": {
Name: "ceph-client-provisioner-0e8555e6556f70d23a61675af44e880c",
Kind: "Secret",
Expand Down Expand Up @@ -853,6 +866,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 +895,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
Loading