Skip to content

Commit 306a93b

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 33d4824 commit 306a93b

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

@@ -272,6 +276,10 @@ var _ = Describe("RBD", func() {
272276
Skip("Skipping RBD E2E")
273277
}
274278
c = f.ClientSet
279+
if operatorDeployment {
280+
rbdDeploymentName = operatorRBDDeploymentName
281+
rbdDaemonsetName = operatorRBDDaemonsetName
282+
}
275283
if deployRBD {
276284
err := addLabelsToNodes(f, map[string]string{
277285
nodeRegionLabel: regionValue,
@@ -344,11 +352,15 @@ var _ = Describe("RBD", func() {
344352
}
345353

346354
// wait for cluster name update in deployment
347-
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
348-
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
349-
"clustername", defaultClusterName, containers, deployTimeout)
355+
if operatorDeployment {
356+
err = setClusterName(defaultClusterName)
357+
} else {
358+
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
359+
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
360+
"clustername", defaultClusterName, containers, deployTimeout)
361+
}
350362
if err != nil {
351-
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
363+
framework.Failf("timeout waiting for clustername arg update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
352364
}
353365
})
354366

@@ -2814,7 +2826,11 @@ var _ = Describe("RBD", func() {
28142826
validateRBDImageCount(f, 1, defaultRBDPool)
28152827
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
28162828
// delete rbd nodeplugin pods
2817-
err = deletePodWithLabel("app=csi-rbdplugin", cephCSINamespace, false)
2829+
selector, err := getDaemonSetLabelSelector(f, cephCSINamespace, rbdDaemonsetName)
2830+
if err != nil {
2831+
framework.Failf("failed to get the labels: %v", err)
2832+
}
2833+
err = deletePodWithLabel(selector, cephCSINamespace, false)
28182834
if err != nil {
28192835
framework.Failf("fail to delete pod: %v", err)
28202836
}
@@ -3781,8 +3797,7 @@ var _ = Describe("RBD", func() {
37813797
framework.Failf("failed to create rados namespace: %v", err)
37823798
}
37833799
// delete csi pods
3784-
err = deletePodWithLabel("app in (ceph-csi-rbd, csi-rbdplugin, csi-rbdplugin-provisioner)",
3785-
cephCSINamespace, false)
3800+
err = deletePodWithLabel(rbdPodSelector, cephCSINamespace, false)
37863801
if err != nil {
37873802
framework.Failf("failed to delete pods with labels: %v", err)
37883803
}
@@ -4600,10 +4615,14 @@ var _ = Describe("RBD", func() {
46004615

46014616
// wait for cluster name update in deployment
46024617
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
4603-
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4604-
"setmetadata", "false", containers, deployTimeout)
4618+
if operatorDeployment {
4619+
err = setEnableMetadata(false)
4620+
} else {
4621+
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4622+
"setmetadata", "false", containers, deployTimeout)
4623+
}
46054624
if err != nil {
4606-
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
4625+
framework.Failf("failed to update setmetadata arg in %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
46074626
}
46084627
pvcSmartClone, err := loadPVC(pvcSmartClonePath)
46094628
if err != nil {
@@ -4703,11 +4722,15 @@ var _ = Describe("RBD", func() {
47034722
validateRBDImageCount(f, 0, defaultRBDPool)
47044723
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
47054724
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
4706-
// wait for cluster name update in deployment
4707-
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4708-
"setmetadata", "true", containers, deployTimeout)
4725+
if operatorDeployment {
4726+
err = setEnableMetadata(true)
4727+
} else {
4728+
// wait for cluster name update in deployment
4729+
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
4730+
"setmetadata", "true", containers, deployTimeout)
4731+
}
47094732
if err != nil {
4710-
framework.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
4733+
framework.Failf("failed to update setmetadata arg in %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
47114734
}
47124735
})
47134736

e2e/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,8 @@ const (
16211621
kubectlCreate = kubectlAction("create")
16221622
// kubectlDelete tells retryKubectlInput() to run "delete".
16231623
kubectlDelete = kubectlAction("delete")
1624+
// kubectlPatch tells retryKubectlInput() to run "patch".
1625+
kubectlPatch = kubectlAction("patch")
16241626
)
16251627

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

0 commit comments

Comments
 (0)