Skip to content

Commit 2e8be35

Browse files
e2e: handle ceph-csi-operator deployment changes
This commits adds e2e/operator.go containing utility methods specific to the operator. Signed-off-by: Praveen M <m.praveen@ibm.com>
1 parent 2764662 commit 2e8be35

File tree

5 files changed

+127
-21
lines changed

5 files changed

+127
-21
lines changed

e2e/cephfs.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ var (
4646
subvolumegroup = "e2e"
4747
fileSystemName = "myfs"
4848
fileSystemPoolName = "myfs-replicated"
49+
50+
operatorCephFSDeploymentName = "cephfs.csi.ceph.com-ctrlplugin"
51+
operatorCephFSDaemonsetName = "cephfs.csi.ceph.com-nodeplugin"
4952
)
5053

5154
func deployCephfsPlugin() {
@@ -175,6 +178,11 @@ var _ = Describe(cephfsType, func() {
175178
Skip("Skipping CephFS E2E")
176179
}
177180
c = f.ClientSet
181+
if operatorDeployment {
182+
cephFSDeploymentName = operatorCephFSDeploymentName
183+
cephFSDeamonSetName = operatorCephFSDaemonsetName
184+
}
185+
178186
if deployCephFS {
179187
if cephCSINamespace != defaultNs {
180188
err := createNamespace(c, cephCSINamespace)
@@ -209,11 +217,15 @@ var _ = Describe(cephfsType, func() {
209217
deployVault(f.ClientSet, deployTimeout)
210218

211219
// wait for cluster name update in deployment
212-
containers := []string{cephFSContainerName}
213-
err = waitForContainersArgsUpdate(c, cephCSINamespace, cephFSDeploymentName,
214-
"clustername", defaultClusterName, containers, deployTimeout)
220+
if operatorDeployment {
221+
err = setClusterName(defaultClusterName)
222+
} else {
223+
containers := []string{cephFSContainerName}
224+
err = waitForContainersArgsUpdate(c, cephCSINamespace, cephFSDeploymentName,
225+
"clustername", defaultClusterName, containers, deployTimeout)
226+
}
215227
if err != nil {
216-
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, cephFSDeploymentName, err)
228+
framework.Failf("timeout waiting for clustername arg update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
217229
}
218230

219231
err = createSubvolumegroup(f, fileSystemName, subvolumegroup)

e2e/nfs.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ var (
5050

5151
// FIXME: some tests change the subvolumegroup to "e2e".
5252
defaultSubvolumegroup = "csi"
53+
54+
operatorNFSDeploymentName = "nfs.csi.ceph.com-ctrlplugin"
55+
operatorNFSDaemonsetName = "nfs.csi.ceph.com-nodeplugin"
5356
)
5457

5558
func deployNFSPlugin(f *framework.Framework) {
@@ -242,6 +245,10 @@ var _ = Describe("nfs", func() {
242245
Skip("Skipping NFS E2E")
243246
}
244247
c = f.ClientSet
248+
if operatorDeployment {
249+
nfsDeploymentName = operatorNFSDeploymentName
250+
nfsDeamonSetName = operatorNFSDaemonsetName
251+
}
245252
if deployNFS {
246253
if cephCSINamespace != defaultNs {
247254
err := createNamespace(c, cephCSINamespace)

e2e/operator.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Copyright 2024 The Ceph-CSI Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"fmt"
21+
)
22+
23+
const (
24+
OperatorConfigName = "ceph-csi-operator-config"
25+
OperatorNamespace = "ceph-csi-operator-system"
26+
)
27+
28+
func setEnableMetadata(value bool) error{
29+
command := []string{
30+
"operatorconfigs.csi.ceph.io",
31+
OperatorConfigName,
32+
"--type=merge",
33+
"-p",
34+
fmt.Sprintf(`{"spec": {"driverSpecDefaults": {"enableMetadata": %t}}}`, value),
35+
}
36+
37+
// Patch the operator config
38+
err := retryKubectlArgs(OperatorNamespace, kubectlPatch, deployTimeout, command...)
39+
if err != nil {
40+
return err
41+
}
42+
43+
return nil
44+
}
45+
46+
func setClusterName(value string) error {
47+
command := []string{
48+
"operatorconfigs.csi.ceph.io",
49+
OperatorConfigName,
50+
"--type=merge",
51+
"-p",
52+
fmt.Sprintf(`{"spec": {"driverSpecDefaults": {"clusterName": %s}}}`, value),
53+
}
54+
55+
// Patch the operator config
56+
err := retryKubectlArgs(OperatorNamespace, kubectlPatch, deployTimeout, command...)
57+
if err != nil {
58+
return err
59+
}
60+
61+
return nil
62+
}

e2e/rbd.go

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ var (
108108
volSnapNameKey = "csi.storage.k8s.io/volumesnapshot/name"
109109
volSnapNamespaceKey = "csi.storage.k8s.io/volumesnapshot/namespace"
110110
volSnapContentNameKey = "csi.storage.k8s.io/volumesnapshotcontent/name"
111+
112+
operatorRBDDeploymentName = "rbd.csi.ceph.com-ctrlplugin"
113+
operatorRBDDaemonsetName = "rbd.csi.ceph.com-nodeplugin"
114+
rbdPodSelector = fmt.Sprintf("app in (ceph-csi-rbd, %s, %s, %s, %s)", rbdDeploymentName, rbdDaemonsetName, operatorRBDDeploymentName, operatorRBDDaemonsetName)
111115
)
112116

113117
func deployRBDPlugin() {
@@ -167,9 +171,9 @@ func createORDeleteRbdResources(action kubectlAction) {
167171
},
168172
// the node-plugin itself
169173
&yamlResourceNamespaced{
170-
filename: rbdDirPath + rbdNodePlugin,
171-
namespace: cephCSINamespace,
172-
domainLabel: nodeRegionLabel + "," + nodeZoneLabel,
174+
filename: rbdDirPath + rbdNodePlugin,
175+
namespace: cephCSINamespace,
176+
domainLabel: nodeRegionLabel + "," + nodeZoneLabel,
173177
},
174178
}
175179

@@ -287,6 +291,10 @@ var _ = Describe("RBD", func() {
287291
Skip("Skipping RBD E2E")
288292
}
289293
c = f.ClientSet
294+
if operatorDeployment {
295+
rbdDeploymentName = operatorRBDDeploymentName
296+
rbdDaemonsetName = operatorRBDDaemonsetName
297+
}
290298
if deployRBD {
291299
err := addLabelsToNodes(f, map[string]string{
292300
nodeRegionLabel: regionValue,
@@ -359,11 +367,15 @@ var _ = Describe("RBD", func() {
359367
}
360368

361369
// wait for cluster name update in deployment
362-
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
363-
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
364-
"clustername", defaultClusterName, containers, deployTimeout)
370+
if operatorDeployment {
371+
err = setClusterName(defaultClusterName)
372+
} else {
373+
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
374+
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
375+
"clustername", defaultClusterName, containers, deployTimeout)
376+
}
365377
if err != nil {
366-
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
378+
framework.Failf("timeout waiting for clustername arg update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
367379
}
368380
})
369381

@@ -2829,7 +2841,11 @@ var _ = Describe("RBD", func() {
28292841
validateRBDImageCount(f, 1, defaultRBDPool)
28302842
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
28312843
// delete rbd nodeplugin pods
2832-
err = deletePodWithLabel("app=csi-rbdplugin", cephCSINamespace, false)
2844+
selector, err := getDaemonSetLabelSelector(f, cephCSINamespace, rbdDaemonsetName)
2845+
if err != nil {
2846+
framework.Failf("failed to get the labels: %v", err)
2847+
}
2848+
err = deletePodWithLabel(selector, cephCSINamespace, false)
28332849
if err != nil {
28342850
framework.Failf("fail to delete pod: %v", err)
28352851
}
@@ -3909,8 +3925,7 @@ var _ = Describe("RBD", func() {
39093925
framework.Failf("failed to create rados namespace: %v", err)
39103926
}
39113927
// delete csi pods
3912-
err = deletePodWithLabel("app in (ceph-csi-rbd, csi-rbdplugin, csi-rbdplugin-provisioner)",
3913-
cephCSINamespace, false)
3928+
err = deletePodWithLabel(rbdPodSelector, cephCSINamespace, false)
39143929
if err != nil {
39153930
framework.Failf("failed to delete pods with labels: %v", err)
39163931
}
@@ -4729,10 +4744,14 @@ var _ = Describe("RBD", func() {
47294744

47304745
// wait for cluster name update in deployment
47314746
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
4732-
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4733-
"setmetadata", "false", containers, deployTimeout)
4747+
if operatorDeployment {
4748+
err = setEnableMetadata(false)
4749+
} else {
4750+
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4751+
"setmetadata", "false", containers, deployTimeout)
4752+
}
47344753
if err != nil {
4735-
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
4754+
framework.Failf("failed to update setmetadata arg in %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
47364755
}
47374756
pvcSmartClone, err := loadPVC(pvcSmartClonePath)
47384757
if err != nil {
@@ -4832,11 +4851,15 @@ var _ = Describe("RBD", func() {
48324851
validateRBDImageCount(f, 0, defaultRBDPool)
48334852
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
48344853
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
4835-
// wait for cluster name update in deployment
4836-
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4837-
"setmetadata", "true", containers, deployTimeout)
4854+
if operatorDeployment {
4855+
err = setEnableMetadata(true)
4856+
} else {
4857+
// wait for cluster name update in deployment
4858+
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4859+
"setmetadata", "true", containers, deployTimeout)
4860+
}
48384861
if err != nil {
4839-
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
4862+
framework.Failf("failed to update setmetadata arg in %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
48404863
}
48414864
})
48424865

e2e/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,8 @@ const (
16341634
kubectlCreate = kubectlAction("create")
16351635
// kubectlDelete tells retryKubectlInput() to run "delete".
16361636
kubectlDelete = kubectlAction("delete")
1637+
// kubectlPatch tells retryKubectlInput() to run "patch".
1638+
kubectlPatch = kubectlAction("patch")
16371639
)
16381640

16391641
// String returns the string format of the kubectlAction, this is automatically

0 commit comments

Comments
 (0)