2021-12-21 14:23:26 +00:00
|
|
|
/*
|
|
|
|
Copyright 2021 The Ceph-CSI Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
2020-12-09 16:10:43 +00:00
|
|
|
"context"
|
2021-05-31 11:31:02 +00:00
|
|
|
"errors"
|
2019-06-18 07:07:11 +00:00
|
|
|
"fmt"
|
2020-02-24 13:19:42 +00:00
|
|
|
"strings"
|
2021-05-31 11:31:02 +00:00
|
|
|
"time"
|
2019-06-14 09:42:48 +00:00
|
|
|
|
2021-07-14 10:13:11 +00:00
|
|
|
"github.com/ceph/ceph-csi/internal/util"
|
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
. "github.com/onsi/ginkgo" // nolint
|
2020-04-16 14:47:43 +00:00
|
|
|
v1 "k8s.io/api/core/v1"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
2022-02-22 11:13:45 +00:00
|
|
|
"k8s.io/apimachinery/pkg/types"
|
2021-05-31 11:31:02 +00:00
|
|
|
"k8s.io/apimachinery/pkg/util/wait"
|
2019-07-25 06:49:44 +00:00
|
|
|
clientset "k8s.io/client-go/kubernetes"
|
2019-05-31 09:34:04 +00:00
|
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
2019-06-24 07:58:39 +00:00
|
|
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
2022-09-02 05:03:48 +00:00
|
|
|
"k8s.io/pod-security-admission/api"
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
rbdProvisioner = "csi-rbdplugin-provisioner.yaml"
|
|
|
|
rbdProvisionerRBAC = "csi-provisioner-rbac.yaml"
|
|
|
|
rbdNodePlugin = "csi-rbdplugin.yaml"
|
|
|
|
rbdNodePluginRBAC = "csi-nodeplugin-rbac.yaml"
|
2019-07-25 06:49:44 +00:00
|
|
|
configMap = "csi-config-map.yaml"
|
2021-09-02 05:06:21 +00:00
|
|
|
cephConfconfigMap = "ceph-conf.yaml"
|
2021-03-30 05:33:01 +00:00
|
|
|
csiDriverObject = "csidriver.yaml"
|
2019-12-19 15:35:58 +00:00
|
|
|
rbdDirPath = "../deploy/rbd/kubernetes/"
|
2021-09-02 05:06:21 +00:00
|
|
|
examplePath = "../examples/"
|
|
|
|
rbdExamplePath = examplePath + "/rbd/"
|
2021-10-28 12:34:07 +00:00
|
|
|
e2eTemplatesPath = "../e2e/templates/"
|
2019-06-10 08:00:40 +00:00
|
|
|
rbdDeploymentName = "csi-rbdplugin-provisioner"
|
|
|
|
rbdDaemonsetName = "csi-rbdplugin"
|
2020-05-05 03:53:24 +00:00
|
|
|
defaultRBDPool = "replicapool"
|
2021-10-27 05:12:09 +00:00
|
|
|
erasureCodedPool = "ec-pool"
|
2021-10-27 08:22:50 +00:00
|
|
|
noDataPool = ""
|
2021-07-08 14:59:34 +00:00
|
|
|
// Topology related variables.
|
2020-04-06 20:19:13 +00:00
|
|
|
nodeRegionLabel = "test.failure-domain/region"
|
|
|
|
regionValue = "testregion"
|
|
|
|
nodeZoneLabel = "test.failure-domain/zone"
|
|
|
|
zoneValue = "testzone"
|
|
|
|
nodeCSIRegionLabel = "topology.rbd.csi.ceph.com/region"
|
|
|
|
nodeCSIZoneLabel = "topology.rbd.csi.ceph.com/zone"
|
|
|
|
rbdTopologyPool = "newrbdpool"
|
|
|
|
rbdTopologyDataPool = "replicapool" // NOTE: should be different than rbdTopologyPool for test to be effective
|
2021-03-22 06:57:02 +00:00
|
|
|
|
2021-07-08 14:59:34 +00:00
|
|
|
// yaml files required for deployment.
|
2021-03-22 06:57:02 +00:00
|
|
|
pvcPath = rbdExamplePath + "pvc.yaml"
|
|
|
|
appPath = rbdExamplePath + "pod.yaml"
|
|
|
|
rawPvcPath = rbdExamplePath + "raw-block-pvc.yaml"
|
|
|
|
rawAppPath = rbdExamplePath + "raw-block-pod.yaml"
|
2022-01-06 15:19:07 +00:00
|
|
|
rawAppRWOPPath = rbdExamplePath + "raw-block-pod-rwop.yaml"
|
|
|
|
rawPVCRWOPPath = rbdExamplePath + "raw-block-pvc-rwop.yaml"
|
2021-03-22 06:57:02 +00:00
|
|
|
pvcClonePath = rbdExamplePath + "pvc-restore.yaml"
|
|
|
|
pvcSmartClonePath = rbdExamplePath + "pvc-clone.yaml"
|
|
|
|
pvcBlockSmartClonePath = rbdExamplePath + "pvc-block-clone.yaml"
|
2022-01-06 15:19:07 +00:00
|
|
|
pvcRWOPPath = rbdExamplePath + "pvc-rwop.yaml"
|
|
|
|
appRWOPPath = rbdExamplePath + "pod-rwop.yaml"
|
2021-03-22 06:57:02 +00:00
|
|
|
appClonePath = rbdExamplePath + "pod-restore.yaml"
|
|
|
|
appSmartClonePath = rbdExamplePath + "pod-clone.yaml"
|
|
|
|
appBlockSmartClonePath = rbdExamplePath + "block-pod-clone.yaml"
|
2021-12-16 05:27:46 +00:00
|
|
|
pvcBlockRestorePath = rbdExamplePath + "pvc-block-restore.yaml"
|
|
|
|
appBlockRestorePath = rbdExamplePath + "pod-block-restore.yaml"
|
2021-10-29 09:07:04 +00:00
|
|
|
appEphemeralPath = rbdExamplePath + "pod-ephemeral.yaml"
|
2021-03-22 06:57:02 +00:00
|
|
|
snapshotPath = rbdExamplePath + "snapshot.yaml"
|
2021-10-28 12:34:07 +00:00
|
|
|
deployFSAppPath = e2eTemplatesPath + "rbd-fs-deployment.yaml"
|
|
|
|
deployBlockAppPath = e2eTemplatesPath + "rbd-block-deployment.yaml"
|
2022-06-29 05:31:07 +00:00
|
|
|
defaultCloneCount = 3 // TODO: set to 10 once issues#2327 is fixed
|
2021-08-23 13:10:22 +00:00
|
|
|
|
2021-11-16 15:51:43 +00:00
|
|
|
nbdMapOptions = "nbd:debug-rbd=20"
|
2021-09-30 07:11:57 +00:00
|
|
|
e2eDefaultCephLogStrategy = "preserve"
|
2022-02-22 11:13:45 +00:00
|
|
|
|
|
|
|
// PV and PVC metadata keys used by external provisioner as part of
|
|
|
|
// create requests as parameters, when `extra-create-metadata` is true.
|
|
|
|
pvcNameKey = "csi.storage.k8s.io/pvc/name"
|
|
|
|
pvcNamespaceKey = "csi.storage.k8s.io/pvc/namespace"
|
|
|
|
pvNameKey = "csi.storage.k8s.io/pv/name"
|
2022-03-02 09:40:32 +00:00
|
|
|
|
|
|
|
// snapshot metadata keys.
|
|
|
|
volSnapNameKey = "csi.storage.k8s.io/volumesnapshot/name"
|
|
|
|
volSnapNamespaceKey = "csi.storage.k8s.io/volumesnapshot/namespace"
|
|
|
|
volSnapContentNameKey = "csi.storage.k8s.io/volumesnapshotcontent/name"
|
2019-05-31 09:34:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func deployRBDPlugin() {
|
2019-12-11 08:48:36 +00:00
|
|
|
// delete objects deployed by rook
|
2020-02-26 08:11:05 +00:00
|
|
|
data, err := replaceNamespaceInTemplate(rbdDirPath + rbdProvisionerRBAC)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdProvisionerRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2021-07-28 03:51:18 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, kubectlDelete, data, deployTimeout, "--ignore-not-found=true")
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete provisioner rbac %s: %v", rbdDirPath+rbdProvisionerRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
data, err = replaceNamespaceInTemplate(rbdDirPath + rbdNodePluginRBAC)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to read content from %s: %v", rbdDirPath+rbdNodePluginRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
2021-07-28 03:51:18 +00:00
|
|
|
err = retryKubectlInput(cephCSINamespace, kubectlDelete, data, deployTimeout, "--ignore-not-found=true")
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete nodeplugin rbac %s: %v", rbdDirPath+rbdNodePluginRBAC, err)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
2021-07-28 03:51:18 +00:00
|
|
|
createORDeleteRbdResources(kubectlCreate)
|
2019-05-31 09:34:04 +00:00
|
|
|
}
|
|
|
|
|
2019-08-07 14:53:39 +00:00
|
|
|
func deleteRBDPlugin() {
|
2021-07-28 03:51:18 +00:00
|
|
|
createORDeleteRbdResources(kubectlDelete)
|
2020-02-26 08:11:05 +00:00
|
|
|
}
|
|
|
|
|
2021-07-28 03:51:18 +00:00
|
|
|
func createORDeleteRbdResources(action kubectlAction) {
|
2022-04-15 14:27:35 +00:00
|
|
|
resources := []ResourceDeployer{
|
2022-05-11 10:06:40 +00:00
|
|
|
// shared resources
|
2022-04-15 14:27:35 +00:00
|
|
|
&yamlResource{
|
|
|
|
filename: rbdDirPath + csiDriverObject,
|
|
|
|
allowMissing: true,
|
|
|
|
},
|
|
|
|
&yamlResource{
|
|
|
|
filename: examplePath + cephConfconfigMap,
|
|
|
|
allowMissing: true,
|
|
|
|
},
|
2022-05-11 10:06:40 +00:00
|
|
|
// dependencies for provisioner
|
2022-04-15 14:27:35 +00:00
|
|
|
&yamlResourceNamespaced{
|
|
|
|
filename: rbdDirPath + rbdProvisionerRBAC,
|
|
|
|
namespace: cephCSINamespace,
|
|
|
|
},
|
2022-05-11 10:06:40 +00:00
|
|
|
// the provisioner itself
|
2022-04-15 14:27:35 +00:00
|
|
|
&yamlResourceNamespaced{
|
2022-05-11 10:06:40 +00:00
|
|
|
filename: rbdDirPath + rbdProvisioner,
|
|
|
|
namespace: cephCSINamespace,
|
|
|
|
oneReplica: true,
|
|
|
|
enableTopology: true,
|
2022-04-15 14:27:35 +00:00
|
|
|
},
|
2022-05-11 10:06:40 +00:00
|
|
|
// dependencies for the node-plugin
|
2022-04-15 14:27:35 +00:00
|
|
|
&yamlResourceNamespaced{
|
|
|
|
filename: rbdDirPath + rbdNodePluginRBAC,
|
|
|
|
namespace: cephCSINamespace,
|
|
|
|
},
|
2022-05-11 10:06:40 +00:00
|
|
|
// the node-plugin itself
|
|
|
|
&yamlResourceNamespaced{
|
|
|
|
filename: rbdDirPath + rbdNodePlugin,
|
|
|
|
namespace: cephCSINamespace,
|
|
|
|
domainLabel: nodeRegionLabel + "," + nodeZoneLabel,
|
|
|
|
},
|
2022-04-15 14:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, r := range resources {
|
|
|
|
err := r.Do(action)
|
2021-09-02 05:06:21 +00:00
|
|
|
if err != nil {
|
2022-04-15 14:27:35 +00:00
|
|
|
e2elog.Failf("failed to %s resource: %v", action, err)
|
2021-09-02 05:06:21 +00:00
|
|
|
}
|
2021-03-30 05:33:01 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
|
2021-03-19 09:09:28 +00:00
|
|
|
func validateRBDImageCount(f *framework.Framework, count int, pool string) {
|
|
|
|
imageList, err := listRBDImages(f, pool)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to list rbd images: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
if len(imageList) != count {
|
2021-06-25 12:38:30 +00:00
|
|
|
e2elog.Failf(
|
2021-07-19 05:42:02 +00:00
|
|
|
"backend images not matching kubernetes resource count,image count %d kubernetes resource count %d"+
|
|
|
|
"\nbackend image Info:\n %v",
|
2021-06-25 12:38:30 +00:00
|
|
|
len(imageList),
|
2021-07-19 05:42:02 +00:00
|
|
|
count,
|
|
|
|
imageList)
|
2020-01-21 08:22:43 +00:00
|
|
|
}
|
2019-08-07 14:53:39 +00:00
|
|
|
}
|
|
|
|
|
2022-05-04 15:54:15 +00:00
|
|
|
func formatImageMetaGetCmd(pool, image, key string) string {
|
|
|
|
return fmt.Sprintf("rbd image-meta get %s --image=%s %s", rbdOptions(pool), image, key)
|
|
|
|
}
|
|
|
|
|
|
|
|
// checkGetKeyError check for error conditions returned by get image-meta key,
|
|
|
|
// returns true if key exists.
|
|
|
|
func checkGetKeyError(err error, stdErr string) bool {
|
|
|
|
if err == nil || !strings.Contains(err.Error(), "command terminated with exit code 2") ||
|
|
|
|
!strings.Contains(stdErr, "failed to get metadata") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-04-11 12:18:06 +00:00
|
|
|
// checkClusternameInMetadata check for cluster name metadata on RBD image.
|
|
|
|
// nolint:nilerr // intentionally returning nil on error in the retry loop.
|
|
|
|
func checkClusternameInMetadata(f *framework.Framework, ns, pool, image string) {
|
|
|
|
t := time.Duration(deployTimeout) * time.Minute
|
|
|
|
var (
|
|
|
|
coName string
|
|
|
|
stdErr string
|
|
|
|
execErr error
|
|
|
|
)
|
|
|
|
err := wait.PollImmediate(poll, t, func() (bool, error) {
|
|
|
|
coName, stdErr, execErr = execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s", rbdOptions(pool), image, clusterNameKey),
|
|
|
|
ns)
|
|
|
|
if execErr != nil || stdErr != "" {
|
|
|
|
e2elog.Logf("failed to get cluster name %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(pool), image, clusterNameKey, execErr, stdErr)
|
|
|
|
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return true, nil
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("could not get cluster name %s/%s %s: %v", rbdOptions(pool), image, clusterNameKey, err)
|
|
|
|
}
|
|
|
|
coName = strings.TrimSuffix(coName, "\n")
|
|
|
|
if coName != defaultClusterName {
|
|
|
|
e2elog.Failf("expected coName %q got %q", defaultClusterName, coName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
var _ = Describe("RBD", func() {
|
2022-04-25 11:49:04 +00:00
|
|
|
f := framework.NewDefaultFramework(rbdType)
|
2022-09-02 05:03:48 +00:00
|
|
|
f.NamespacePodSecurityEnforceLevel = api.LevelPrivileged
|
2019-12-18 08:41:20 +00:00
|
|
|
var c clientset.Interface
|
2021-08-23 13:10:22 +00:00
|
|
|
var kernelRelease string
|
2019-06-10 06:48:41 +00:00
|
|
|
// deploy RBD CSI
|
2019-05-31 09:34:04 +00:00
|
|
|
BeforeEach(func() {
|
2020-07-25 16:40:28 +00:00
|
|
|
if !testRBD || upgradeTesting {
|
2020-07-08 11:46:31 +00:00
|
|
|
Skip("Skipping RBD E2E")
|
|
|
|
}
|
2019-12-18 08:41:20 +00:00
|
|
|
c = f.ClientSet
|
2020-02-25 08:00:23 +00:00
|
|
|
if deployRBD {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := createNodeLabel(f, nodeRegionLabel, regionValue)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = createNodeLabel(f, nodeZoneLabel, zoneValue)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-02-25 11:45:54 +00:00
|
|
|
if cephCSINamespace != defaultNs {
|
2020-09-03 09:34:29 +00:00
|
|
|
err = createNamespace(c, cephCSINamespace)
|
2020-02-26 08:11:05 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create namespace: %v", err)
|
2020-02-25 11:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-25 08:00:23 +00:00
|
|
|
deployRBDPlugin()
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err := createConfigMap(rbdDirPath, f.ClientSet, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create configmap: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-06-24 10:20:25 +00:00
|
|
|
// Since helm deploys storageclass, skip storageclass creation if
|
|
|
|
// ceph-csi is deployed via helm.
|
|
|
|
if !helmTest {
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-06-24 10:20:25 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-02-22 11:13:40 +00:00
|
|
|
// create rbd provisioner secret
|
|
|
|
key, err := createCephUser(f, keyringRBDProvisionerUsername, rbdProvisionerCaps("", ""))
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create user %s: %v", keyringRBDProvisionerUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
err = createRBDSecret(f, rbdProvisionerSecretName, keyringRBDProvisionerUsername, key)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create provisioner secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
// create rbd plugin secret
|
|
|
|
key, err = createCephUser(f, keyringRBDNodePluginUsername, rbdNodePluginCaps("", ""))
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create user %s: %v", keyringRBDNodePluginUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
err = createRBDSecret(f, rbdNodePluginSecretName, keyringRBDNodePluginUsername, key)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create node secret: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-01-29 11:44:45 +00:00
|
|
|
deployVault(f.ClientSet, deployTimeout)
|
2021-08-23 13:10:22 +00:00
|
|
|
|
|
|
|
// wait for provisioner deployment
|
2021-10-29 08:36:30 +00:00
|
|
|
err = waitForDeploymentComplete(f.ClientSet, rbdDeploymentName, cephCSINamespace, deployTimeout)
|
2021-08-23 13:10:22 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("timeout waiting for deployment %s: %v", rbdDeploymentName, err)
|
2021-08-23 13:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// wait for nodeplugin deamonset pods
|
|
|
|
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset %s: %v", rbdDaemonsetName, err)
|
2021-08-23 13:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
kernelRelease, err = getKernelVersionFromDaemonset(f, cephCSINamespace, rbdDaemonsetName, "csi-rbdplugin")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to get the kernel version: %v", err)
|
2021-08-23 13:10:22 +00:00
|
|
|
}
|
2021-11-12 13:03:20 +00:00
|
|
|
// default io-timeout=0, needs kernel >= 5.4
|
|
|
|
if !util.CheckKernelSupport(kernelRelease, nbdZeroIOtimeoutSupport) {
|
2021-11-16 15:51:43 +00:00
|
|
|
nbdMapOptions = "nbd:debug-rbd=20,io-timeout=330"
|
2021-11-12 13:03:20 +00:00
|
|
|
}
|
2022-04-11 12:18:06 +00:00
|
|
|
|
|
|
|
// wait for cluster name update in deployment
|
|
|
|
containers := []string{"csi-rbdplugin", "csi-rbdplugin-controller"}
|
|
|
|
err = waitForContainersArgsUpdate(c, cephCSINamespace, rbdDeploymentName,
|
|
|
|
"clustername", defaultClusterName, containers, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("timeout waiting for deployment update %s/%s: %v", cephCSINamespace, rbdDeploymentName, err)
|
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
2020-07-25 16:40:28 +00:00
|
|
|
if !testRBD || upgradeTesting {
|
2020-07-08 11:46:31 +00:00
|
|
|
Skip("Skipping RBD E2E")
|
|
|
|
}
|
2019-12-18 08:41:20 +00:00
|
|
|
if CurrentGinkgoTestDescription().Failed {
|
2020-04-01 07:20:43 +00:00
|
|
|
// log pods created by helm chart
|
|
|
|
logsCSIPods("app=ceph-csi-rbd", c)
|
2021-06-10 11:00:26 +00:00
|
|
|
// log provisioner
|
2019-12-18 08:41:20 +00:00
|
|
|
logsCSIPods("app=csi-rbdplugin-provisioner", c)
|
|
|
|
// log node plugin
|
|
|
|
logsCSIPods("app=csi-rbdplugin", c)
|
2020-12-03 11:00:22 +00:00
|
|
|
|
|
|
|
// log all details from the namespace where Ceph-CSI is deployed
|
|
|
|
framework.DumpAllNamespaceInfo(c, cephCSINamespace)
|
2019-12-18 08:41:20 +00:00
|
|
|
}
|
2020-02-25 11:45:54 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteConfigMap(rbdDirPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete configmap: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), rbdProvisionerSecretName, metav1.DeleteOptions{})
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete provisioner secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), rbdNodePluginSecretName, metav1.DeleteOptions{})
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete node secret: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2019-08-13 09:40:08 +00:00
|
|
|
// deleteResource(rbdExamplePath + "snapshotclass.yaml")
|
2020-01-29 11:44:45 +00:00
|
|
|
deleteVault()
|
2020-02-25 11:45:54 +00:00
|
|
|
if deployRBD {
|
|
|
|
deleteRBDPlugin()
|
|
|
|
if cephCSINamespace != defaultNs {
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteNamespace(c, cephCSINamespace)
|
2020-02-25 11:45:54 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete namespace: %v", err)
|
2020-02-25 11:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteNodeLabel(c, nodeRegionLabel)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = deleteNodeLabel(c, nodeZoneLabel)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
// Remove the CSI labels that get added
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteNodeLabel(c, nodeCSIRegionLabel)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = deleteNodeLabel(c, nodeCSIZoneLabel)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
Context("Test RBD CSI", func() {
|
2022-04-19 09:25:54 +00:00
|
|
|
if !testRBD || upgradeTesting {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-05-31 09:34:04 +00:00
|
|
|
It("Test RBD CSI", func() {
|
2021-06-24 10:20:25 +00:00
|
|
|
// test only if ceph-csi is deployed via helm
|
|
|
|
if helmTest {
|
|
|
|
By("verify PVC and app binding on helm installation", func() {
|
|
|
|
err := validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding: %v", err)
|
2021-06-24 10:20:25 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-06-24 10:20:25 +00:00
|
|
|
// Deleting the storageclass and secret created by helm
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-06-24 10:20:25 +00:00
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "secret.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete secret: %v", err)
|
2021-06-24 10:20:25 +00:00
|
|
|
}
|
|
|
|
// Re-create the RBD storageclass
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-06-24 10:20:25 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2022-02-22 11:13:45 +00:00
|
|
|
|
|
|
|
By("create a PVC and check PVC/PV metadata on RBD image", func() {
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-02-22 11:13:45 +00:00
|
|
|
|
|
|
|
imageList, err := listRBDImages(f, defaultRBDPool)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list rbd images: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcName, stdErr, err := execCommandInToolBoxPod(f,
|
2022-05-04 15:54:15 +00:00
|
|
|
formatImageMetaGetCmd(defaultRBDPool, imageList[0], pvcNameKey),
|
2022-02-22 11:13:45 +00:00
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get PVC name %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNameKey, err, stdErr)
|
|
|
|
}
|
|
|
|
pvcName = strings.TrimSuffix(pvcName, "\n")
|
|
|
|
if pvcName != pvc.Name {
|
|
|
|
e2elog.Failf("expected pvcName %q got %q", pvc.Name, pvcName)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcNamespace, stdErr, err := execCommandInToolBoxPod(f,
|
2022-05-04 15:54:15 +00:00
|
|
|
formatImageMetaGetCmd(defaultRBDPool, imageList[0], pvcNamespaceKey),
|
2022-02-22 11:13:45 +00:00
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get PVC namespace %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNamespaceKey, err, stdErr)
|
|
|
|
}
|
|
|
|
pvcNamespace = strings.TrimSuffix(pvcNamespace, "\n")
|
|
|
|
if pvcNamespace != pvc.Namespace {
|
|
|
|
e2elog.Failf("expected pvcNamespace %q got %q", pvc.Namespace, pvcNamespace)
|
|
|
|
}
|
2022-05-06 06:59:50 +00:00
|
|
|
pvcObj, err := getPersistentVolumeClaim(c, pvc.Namespace, pvc.Name)
|
2022-02-22 11:13:45 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("error getting pvc %q in namespace %q: %v", pvc.Name, pvc.Namespace, err)
|
|
|
|
}
|
|
|
|
if pvcObj.Spec.VolumeName == "" {
|
|
|
|
e2elog.Logf("pv name is empty %q in namespace %q: %v", pvc.Name, pvc.Namespace, err)
|
|
|
|
}
|
|
|
|
pvName, stdErr, err := execCommandInToolBoxPod(f,
|
2022-05-04 15:54:15 +00:00
|
|
|
formatImageMetaGetCmd(defaultRBDPool, imageList[0], pvNameKey),
|
2022-02-22 11:13:45 +00:00
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get PV name %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvNameKey, err, stdErr)
|
|
|
|
}
|
|
|
|
pvName = strings.TrimSuffix(pvName, "\n")
|
|
|
|
if pvName != pvcObj.Spec.VolumeName {
|
|
|
|
e2elog.Failf("expected pvName %q got %q", pvcObj.Spec.VolumeName, pvName)
|
|
|
|
}
|
|
|
|
|
2022-04-11 12:18:06 +00:00
|
|
|
checkClusternameInMetadata(f, rookNamespace, defaultRBDPool, imageList[0])
|
|
|
|
|
2022-02-22 11:13:45 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc: %v", err)
|
|
|
|
}
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2022-02-22 11:13:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("reattach the old PV to a new PVC and check if PVC metadata is updated on RBD image", func() {
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-02-22 11:13:45 +00:00
|
|
|
|
|
|
|
imageList, err := listRBDImages(f, defaultRBDPool)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list rbd images: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcName, stdErr, err := execCommandInToolBoxPod(f,
|
2022-03-02 09:40:32 +00:00
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
2022-02-22 11:13:45 +00:00
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNameKey),
|
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get PVC name %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNameKey, err, stdErr)
|
|
|
|
}
|
|
|
|
pvcName = strings.TrimSuffix(pvcName, "\n")
|
|
|
|
if pvcName != pvc.Name {
|
|
|
|
e2elog.Failf("expected pvcName %q got %q", pvc.Name, pvcName)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcObj, err := c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(
|
|
|
|
context.TODO(),
|
|
|
|
pvc.Name,
|
|
|
|
metav1.GetOptions{})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("error getting pvc %q in namespace %q: %v", pvc.Name, pvc.Namespace, err)
|
|
|
|
}
|
|
|
|
if pvcObj.Spec.VolumeName == "" {
|
|
|
|
e2elog.Logf("pv name is empty %q in namespace %q: %v", pvc.Name, pvc.Namespace, err)
|
|
|
|
}
|
|
|
|
|
2022-04-11 14:24:19 +00:00
|
|
|
// patch PV to Retain it after deleting the PVC.
|
|
|
|
patchBytes := []byte(`{"spec":{"persistentVolumeReclaimPolicy": "Retain"}}`)
|
2022-02-22 11:13:45 +00:00
|
|
|
_, err = c.CoreV1().PersistentVolumes().Patch(
|
|
|
|
context.TODO(),
|
|
|
|
pvcObj.Spec.VolumeName,
|
|
|
|
types.StrategicMergePatchType,
|
|
|
|
patchBytes,
|
|
|
|
metav1.PatchOptions{})
|
|
|
|
if err != nil {
|
2022-04-11 14:24:19 +00:00
|
|
|
e2elog.Logf("error Patching PV %q for persistentVolumeReclaimPolicy: %v",
|
2022-02-22 11:13:45 +00:00
|
|
|
pvcObj.Spec.VolumeName, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Delete(
|
|
|
|
context.TODO(),
|
|
|
|
pvc.Name,
|
|
|
|
metav1.DeleteOptions{})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("failed to delete pvc: %w", err)
|
|
|
|
}
|
|
|
|
|
2022-04-11 14:24:19 +00:00
|
|
|
// Remove the claimRef to bind this PV to a new PVC.
|
|
|
|
patchBytes = []byte(`{"spec":{"claimRef": null}}`)
|
|
|
|
_, err = c.CoreV1().PersistentVolumes().Patch(
|
|
|
|
context.TODO(),
|
|
|
|
pvcObj.Spec.VolumeName,
|
|
|
|
types.StrategicMergePatchType,
|
|
|
|
patchBytes,
|
|
|
|
metav1.PatchOptions{})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("error Patching PV %q for claimRef: %v",
|
|
|
|
pvcObj.Spec.VolumeName, err)
|
|
|
|
}
|
|
|
|
|
2022-02-22 11:13:45 +00:00
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-02-22 11:13:45 +00:00
|
|
|
|
2022-03-02 09:40:32 +00:00
|
|
|
pvcObj.Name = "rbd-pvc-new"
|
|
|
|
// unset the resource version as should not be set on objects to be created
|
|
|
|
pvcObj.ResourceVersion = ""
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcObj, deployTimeout)
|
2022-02-22 11:13:45 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create new PVC: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-02-22 11:13:45 +00:00
|
|
|
|
|
|
|
pvcName, stdErr, err = execCommandInToolBoxPod(f,
|
2022-03-02 09:40:32 +00:00
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
2022-02-22 11:13:45 +00:00
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNameKey),
|
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get PVC name %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNameKey, err, stdErr)
|
|
|
|
}
|
|
|
|
pvcName = strings.TrimSuffix(pvcName, "\n")
|
2022-03-02 09:40:32 +00:00
|
|
|
if pvcName != pvcObj.Name {
|
|
|
|
e2elog.Failf("expected pvcName %q got %q", pvcObj.Name, pvcName)
|
2022-02-22 11:13:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
patchBytes = []byte(`{"spec":{"persistentVolumeReclaimPolicy": "Delete"}}`)
|
|
|
|
_, err = c.CoreV1().PersistentVolumes().Patch(
|
|
|
|
context.TODO(),
|
|
|
|
pvcObj.Spec.VolumeName,
|
|
|
|
types.StrategicMergePatchType,
|
|
|
|
patchBytes,
|
|
|
|
metav1.PatchOptions{})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("error Patching PV %q for persistentVolumeReclaimPolicy: %v", pvcObj.Spec.VolumeName, err)
|
|
|
|
}
|
2022-03-02 09:40:32 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvcObj, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc: %v", err)
|
|
|
|
}
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2022-03-02 09:40:32 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("create a snapshot and check metadata on RBD snapshot image", func() {
|
|
|
|
err := createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
pvc, app, err := createPVCAndAppBinding(pvcPath, appPath, f, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create pvc and application binding: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-03-02 09:40:32 +00:00
|
|
|
// delete pod as we should not create snapshot for in-use pvc
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create snapshot: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent PVC + snapshot
|
|
|
|
totalImages := 2
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2022-03-02 09:40:32 +00:00
|
|
|
|
|
|
|
imageList, err := listRBDImages(f, defaultRBDPool)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list rbd images: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
volSnapName, stdErr, err := execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], volSnapNameKey),
|
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get volume snapshot name %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], volSnapNameKey, err, stdErr)
|
|
|
|
}
|
|
|
|
volSnapName = strings.TrimSuffix(volSnapName, "\n")
|
|
|
|
if volSnapName != snap.Name {
|
|
|
|
e2elog.Failf("expected volSnapName %q got %q", snap.Name, volSnapName)
|
|
|
|
}
|
|
|
|
|
|
|
|
volSnapNamespace, stdErr, err := execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], volSnapNamespaceKey),
|
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get volume snapshot namespace %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], volSnapNamespaceKey, err, stdErr)
|
|
|
|
}
|
|
|
|
volSnapNamespace = strings.TrimSuffix(volSnapNamespace, "\n")
|
|
|
|
if volSnapNamespace != snap.Namespace {
|
|
|
|
e2elog.Failf("expected volSnapNamespace %q got %q", snap.Namespace, volSnapNamespace)
|
|
|
|
}
|
|
|
|
|
|
|
|
content, err := getVolumeSnapshotContent(snap.Namespace, snap.Name)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to get snapshotcontent for %s in namespace %s: %v",
|
|
|
|
snap.Name, snap.Namespace, err)
|
|
|
|
}
|
|
|
|
volSnapContentName, stdErr, err := execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], volSnapContentNameKey),
|
|
|
|
rookNamespace)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to get snapshotcontent name %s/%s %s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], volSnapContentNameKey, err, stdErr)
|
|
|
|
}
|
|
|
|
volSnapContentName = strings.TrimSuffix(volSnapContentName, "\n")
|
|
|
|
if volSnapContentName != content.Name {
|
|
|
|
e2elog.Failf("expected volSnapContentName %q got %q", content.Name, volSnapContentName)
|
|
|
|
}
|
|
|
|
|
2022-05-04 15:54:15 +00:00
|
|
|
// make sure we had unset the PVC metadata on the rbd image created
|
|
|
|
// for the snapshot
|
|
|
|
pvcName, stdErr, err := execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNameKey),
|
|
|
|
rookNamespace)
|
|
|
|
if checkGetKeyError(err, stdErr) {
|
|
|
|
e2elog.Failf("PVC name found on %s/%s %s=%s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNameKey, pvcName, err, stdErr)
|
|
|
|
}
|
|
|
|
pvcNamespace, stdErr, err := execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNamespaceKey),
|
|
|
|
rookNamespace)
|
|
|
|
if checkGetKeyError(err, stdErr) {
|
|
|
|
e2elog.Failf("PVC namespace found on %s/%s %s=%s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvcNamespaceKey, pvcNamespace, err, stdErr)
|
|
|
|
}
|
|
|
|
pvName, stdErr, err := execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvNameKey),
|
|
|
|
rookNamespace)
|
|
|
|
if checkGetKeyError(err, stdErr) {
|
|
|
|
e2elog.Failf("PV name found on %s/%s %s=%s: err=%v stdErr=%q",
|
|
|
|
rbdOptions(defaultRBDPool), imageList[0], pvNameKey, pvName, err, stdErr)
|
|
|
|
}
|
2022-04-11 12:18:06 +00:00
|
|
|
checkClusternameInMetadata(f, rookNamespace, defaultRBDPool, imageList[0])
|
2022-05-04 15:54:15 +00:00
|
|
|
|
2022-03-02 09:40:32 +00:00
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete snapshot: %v", err)
|
|
|
|
}
|
2022-02-22 11:13:45 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc: %v", err)
|
|
|
|
}
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2022-02-22 11:13:45 +00:00
|
|
|
})
|
|
|
|
|
2021-10-29 09:07:04 +00:00
|
|
|
By("verify generic ephemeral volume support", func() {
|
2022-05-26 05:56:35 +00:00
|
|
|
// create application
|
|
|
|
app, err := loadApp(appEphemeralPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
|
|
|
// validate images in trash
|
|
|
|
err = waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", defaultRBDPool, err)
|
2021-10-29 09:07:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-11-19 04:50:27 +00:00
|
|
|
By("validate RBD migration PVC", func() {
|
|
|
|
err := setupMigrationCMSecretAndSC(f, "")
|
2021-10-01 04:15:45 +00:00
|
|
|
if err != nil {
|
2021-11-19 04:50:27 +00:00
|
|
|
e2elog.Failf("failed to setup migration prerequisites: %v", err)
|
2021-10-01 04:15:45 +00:00
|
|
|
}
|
2021-11-19 04:50:27 +00:00
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-10-15 06:44:10 +00:00
|
|
|
|
2021-11-19 04:50:27 +00:00
|
|
|
// Block PVC resize
|
|
|
|
err = resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
|
2021-10-01 04:15:45 +00:00
|
|
|
if err != nil {
|
2021-11-19 04:50:27 +00:00
|
|
|
e2elog.Failf("failed to resize block PVC: %v", err)
|
2021-10-01 04:15:45 +00:00
|
|
|
}
|
2021-11-19 04:50:27 +00:00
|
|
|
|
|
|
|
// FileSystem PVC resize
|
|
|
|
err = resizePVCAndValidateSize(pvcPath, appPath, f)
|
2021-10-01 04:15:45 +00:00
|
|
|
if err != nil {
|
2021-11-19 04:50:27 +00:00
|
|
|
e2elog.Failf("failed to resize filesystem PVC: %v", err)
|
2021-10-01 04:15:45 +00:00
|
|
|
}
|
2021-11-19 04:50:27 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
2021-10-01 04:15:45 +00:00
|
|
|
if err != nil {
|
2021-11-19 04:50:27 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-10-01 04:15:45 +00:00
|
|
|
}
|
2021-11-19 04:50:27 +00:00
|
|
|
err = tearDownMigrationSetup(f)
|
2021-10-01 04:15:45 +00:00
|
|
|
if err != nil {
|
2021-11-19 04:50:27 +00:00
|
|
|
e2elog.Failf("failed to tear down migration setup: %v", err)
|
2021-10-01 04:15:45 +00:00
|
|
|
}
|
2021-11-19 04:50:27 +00:00
|
|
|
})
|
2021-10-15 06:44:10 +00:00
|
|
|
|
2021-11-19 04:50:27 +00:00
|
|
|
By("validate RBD migration+static FileSystem", func() {
|
|
|
|
err := setupMigrationCMSecretAndSC(f, "migrationsc")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to setup migration prerequisites: %v", err)
|
|
|
|
}
|
|
|
|
// validate filesystem pvc mount
|
|
|
|
err = validateRBDStaticMigrationPVC(f, appPath, "migrationsc", false)
|
2021-10-15 06:44:10 +00:00
|
|
|
if err != nil {
|
2021-11-19 04:50:27 +00:00
|
|
|
e2elog.Failf("failed to validate rbd migrated static file mode pvc: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-11-19 04:50:27 +00:00
|
|
|
err = tearDownMigrationSetup(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to tear down migration setup: %v", err)
|
2021-10-15 06:44:10 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-10-15 06:44:10 +00:00
|
|
|
}
|
2021-10-01 04:15:45 +00:00
|
|
|
})
|
2021-06-24 10:20:25 +00:00
|
|
|
|
2020-11-26 10:44:22 +00:00
|
|
|
By("create a PVC and validate owner", func() {
|
|
|
|
err := validateImageOwner(pvcPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate owner of pvc: %v", err)
|
2020-11-26 10:44:22 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-11-26 10:44:22 +00:00
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app", func() {
|
|
|
|
err := validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
2019-06-11 12:40:31 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app with normal user", func() {
|
|
|
|
err := validateNormalUserPVCAccess(pvcPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate normal user pvc and application binding: %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2019-06-11 12:40:31 +00:00
|
|
|
})
|
2019-09-19 17:11:32 +00:00
|
|
|
|
2022-01-06 15:19:07 +00:00
|
|
|
By("create a Block mode RWOP PVC and bind it to more than one app", func() {
|
2022-07-25 04:40:20 +00:00
|
|
|
pvc, err := loadPVC(rawPVCRWOPPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
2022-01-06 15:19:07 +00:00
|
|
|
|
2022-07-25 04:40:20 +00:00
|
|
|
app, err := loadApp(rawAppRWOPPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
baseAppName := app.Name
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
if rwopMayFail(err) {
|
|
|
|
e2elog.Logf("RWOP is not supported: %v", err)
|
2022-04-11 15:54:53 +00:00
|
|
|
|
2022-07-25 04:40:20 +00:00
|
|
|
return
|
2022-01-06 15:19:07 +00:00
|
|
|
}
|
2022-07-25 04:40:20 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-01-06 15:19:07 +00:00
|
|
|
|
2022-07-25 04:40:20 +00:00
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
2022-01-06 15:19:07 +00:00
|
|
|
}
|
2022-07-25 04:40:20 +00:00
|
|
|
err = validateRWOPPodCreation(f, pvc, app, baseAppName)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate RWOP pod creation: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2022-01-06 15:19:07 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("create a RWOP PVC and bind it to more than one app", func() {
|
2022-07-25 04:40:20 +00:00
|
|
|
pvc, err := loadPVC(pvcRWOPPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
2022-01-06 15:19:07 +00:00
|
|
|
|
2022-07-25 04:40:20 +00:00
|
|
|
app, err := loadApp(appRWOPPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
baseAppName := app.Name
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
if rwopMayFail(err) {
|
|
|
|
e2elog.Logf("RWOP is not supported: %v", err)
|
2022-04-11 15:54:53 +00:00
|
|
|
|
2022-07-25 04:40:20 +00:00
|
|
|
return
|
2022-01-06 15:19:07 +00:00
|
|
|
}
|
2022-07-25 04:40:20 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-01-06 15:19:07 +00:00
|
|
|
|
2022-07-25 04:40:20 +00:00
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
2022-01-06 15:19:07 +00:00
|
|
|
}
|
2022-07-25 04:40:20 +00:00
|
|
|
err = validateRWOPPodCreation(f, pvc, app, baseAppName)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate RWOP pod creation: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2022-01-06 15:19:07 +00:00
|
|
|
})
|
|
|
|
|
2021-10-27 05:12:09 +00:00
|
|
|
By("create an erasure coded PVC and bind it to an app", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"dataPool": erasureCodedPool,
|
|
|
|
"pool": defaultRBDPool,
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
pvc, app, err := createPVCAndAppBinding(pvcPath, appPath, f, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create pvc and application binding: %v", err)
|
|
|
|
}
|
|
|
|
err = checkPVCDataPoolForImageInPool(f, pvc, defaultRBDPool, "ec-pool")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to check data pool for image: %v", err)
|
|
|
|
}
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc and application : %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-10-27 08:22:50 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("create an erasure coded PVC and validate snapshot restore", func() {
|
|
|
|
validatePVCSnapshot(
|
|
|
|
defaultCloneCount,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
snapshotPath,
|
|
|
|
pvcClonePath,
|
|
|
|
appClonePath,
|
|
|
|
noKMS, noKMS,
|
|
|
|
defaultSCName,
|
|
|
|
erasureCodedPool,
|
|
|
|
f)
|
2021-10-27 05:12:09 +00:00
|
|
|
})
|
|
|
|
|
2021-10-27 08:25:23 +00:00
|
|
|
By("create an erasure coded PVC and validate PVC-PVC clone", func() {
|
|
|
|
validatePVCClone(
|
|
|
|
defaultCloneCount,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
pvcSmartClonePath,
|
|
|
|
appSmartClonePath,
|
2022-04-26 06:38:49 +00:00
|
|
|
defaultSCName,
|
2021-10-27 08:25:23 +00:00
|
|
|
erasureCodedPool,
|
|
|
|
noKMS,
|
|
|
|
noPVCValidation,
|
|
|
|
f)
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app with ext4 as the FS ", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{"csi.storage.k8s.io/fstype": "ext4"},
|
|
|
|
deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-01-21 11:29:25 +00:00
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2021-01-21 11:29:25 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-01-21 11:29:25 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-01-21 11:29:25 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-01-21 11:29:25 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-01-21 11:29:25 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("create a PVC and bind it to an app using rbd-nbd mounter", func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-01-21 11:29:25 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-01-21 11:29:25 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
2021-08-16 10:19:25 +00:00
|
|
|
map[string]string{
|
2021-09-30 07:11:57 +00:00
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
2021-08-16 10:19:25 +00:00
|
|
|
},
|
2021-06-25 12:38:30 +00:00
|
|
|
deletePolicy)
|
2021-01-21 11:29:25 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-01-21 11:29:25 +00:00
|
|
|
}
|
2020-09-03 09:34:29 +00:00
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2019-09-19 17:11:32 +00:00
|
|
|
})
|
|
|
|
|
2021-07-14 10:13:11 +00:00
|
|
|
By("Resize rbd-nbd PVC and check application directory size", func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-07-14 10:13:11 +00:00
|
|
|
if util.CheckKernelSupport(kernelRelease, nbdResizeSupport) {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
// Storage class with rbd-nbd mounter
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
2021-08-16 10:19:25 +00:00
|
|
|
map[string]string{
|
2021-09-30 07:11:57 +00:00
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
2021-08-16 10:19:25 +00:00
|
|
|
},
|
2021-07-14 10:13:11 +00:00
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
// Block PVC resize
|
|
|
|
err = resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to resize block PVC: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-14 10:13:11 +00:00
|
|
|
|
|
|
|
// FileSystem PVC resize
|
|
|
|
err = resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to resize filesystem PVC: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-14 10:13:11 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-12-07 08:05:31 +00:00
|
|
|
By("create PVC with layering,fast-diff image-features and bind it to an app",
|
|
|
|
func() {
|
|
|
|
if util.CheckKernelSupport(kernelRelease, fastDiffSupport) {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"imageFeatures": "layering,exclusive-lock,object-map,fast-diff",
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-12-07 08:05:31 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-02-17 06:01:34 +00:00
|
|
|
By("create PVC with layering,deep-flatten image-features and bind it to an app",
|
|
|
|
func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"imageFeatures": "layering,deep-flatten",
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
// set up PVC
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-02-17 06:01:34 +00:00
|
|
|
|
|
|
|
if util.CheckKernelSupport(kernelRelease, deepFlattenSupport) {
|
|
|
|
app, aErr := loadApp(appPath)
|
|
|
|
if aErr != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", aErr)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
|
|
|
}
|
|
|
|
// delete pod as we should not create snapshot for in-use pvc
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// clean up after ourselves
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2022-02-17 06:24:47 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2022-02-17 06:24:47 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("create PVC with layering,deep-flatten image-features and bind it to an app",
|
|
|
|
func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"imageFeatures": "",
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
// set up PVC
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2022-02-17 06:24:47 +00:00
|
|
|
|
|
|
|
// checking the minimal kernel version for fast-diff as its
|
|
|
|
// higher kernel version than other default image features.
|
|
|
|
if util.CheckKernelSupport(kernelRelease, fastDiffSupport) {
|
|
|
|
app, aErr := loadApp(appPath)
|
|
|
|
if aErr != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", aErr)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
|
|
|
}
|
|
|
|
// delete pod as we should not create snapshot for in-use pvc
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// clean up after ourselves
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2022-02-17 06:01:34 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2022-02-17 06:01:34 +00:00
|
|
|
})
|
|
|
|
|
2021-12-07 08:05:31 +00:00
|
|
|
By("create PVC with journaling,fast-diff image-features and bind it to an app using rbd-nbd mounter",
|
|
|
|
func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-07 08:05:31 +00:00
|
|
|
if util.CheckKernelSupport(kernelRelease, fastDiffSupport) {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
// Storage class with rbd-nbd mounter
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"imageFeatures": "layering,journaling,exclusive-lock,object-map,fast-diff",
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate CephFS pvc and application binding: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-12-07 08:05:31 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-10-28 12:34:07 +00:00
|
|
|
// NOTE: RWX is restricted for FileSystem VolumeMode at ceph-csi,
|
|
|
|
// see pull#261 for more details.
|
|
|
|
By("Create RWX+Block Mode PVC and bind to multiple pods via deployment using rbd-nbd mounter", func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-10-28 12:34:07 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
// Storage class with rbd-nbd mounter
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
pvc, err := loadPVC(rawPvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
pvc.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadWriteMany}
|
|
|
|
|
|
|
|
app, err := loadAppDeployment(deployBlockAppPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application deployment: %v", err)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
|
2022-02-15 14:27:40 +00:00
|
|
|
err = createPVCAndDeploymentApp(f, pvc, app, deployTimeout)
|
2021-10-28 12:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = waitForDeploymentComplete(f.ClientSet, app.Name, app.Namespace, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("timeout waiting for deployment to be in running state: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
devPath := app.Spec.Template.Spec.Containers[0].VolumeDevices[0].DevicePath
|
|
|
|
cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath)
|
|
|
|
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", app.Name),
|
|
|
|
}
|
|
|
|
podList, err := f.PodClientNS(app.Namespace).List(context.TODO(), opt)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("get pod list failed: %v", err)
|
|
|
|
}
|
|
|
|
if len(podList.Items) != int(*app.Spec.Replicas) {
|
|
|
|
e2elog.Failf("podlist contains %d items, expected %d items", len(podList.Items), *app.Spec.Replicas)
|
|
|
|
}
|
|
|
|
for _, pod := range podList.Items {
|
|
|
|
_, _, err = execCommandInPodWithName(f, cmd, pod.Name, pod.Spec.Containers[0].Name, app.Namespace)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("command %q failed: %v", cmd, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 14:27:40 +00:00
|
|
|
err = deletePVCAndDeploymentApp(f, pvc, app)
|
2021-10-28 12:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-10-28 12:34:07 +00:00
|
|
|
// validate images in trash
|
|
|
|
err = waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", rbdOptions(defaultRBDPool), err)
|
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("Create ROX+FS Mode PVC and bind to multiple pods via deployment using rbd-nbd mounter", func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-10-28 12:34:07 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
// Storage class with rbd-nbd mounter
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2021-10-28 12:34:07 +00:00
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// create clone PVC as ROX
|
|
|
|
pvcClone, err := loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvcClone.Spec.DataSource.Name = pvc.Name
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany}
|
|
|
|
appClone, err := loadAppDeployment(deployFSAppPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application deployment: %v", err)
|
|
|
|
}
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
appClone.Spec.Template.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
|
|
|
appClone.Spec.Template.Spec.Volumes[0].PersistentVolumeClaim.ReadOnly = true
|
2022-02-15 14:27:40 +00:00
|
|
|
err = createPVCAndDeploymentApp(f, pvcClone, appClone, deployTimeout)
|
2021-10-28 12:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = waitForDeploymentComplete(f.ClientSet, appClone.Name, appClone.Namespace, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("timeout waiting for deployment to be in running state: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 3, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType)
|
2021-10-28 12:34:07 +00:00
|
|
|
|
|
|
|
filePath := appClone.Spec.Template.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
|
|
|
|
cmd := fmt.Sprintf("echo 'Hello World' > %s", filePath)
|
|
|
|
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", appClone.Name),
|
|
|
|
}
|
|
|
|
podList, err := f.PodClientNS(appClone.Namespace).List(context.TODO(), opt)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("get pod list failed: %v", err)
|
|
|
|
}
|
|
|
|
if len(podList.Items) != int(*appClone.Spec.Replicas) {
|
|
|
|
e2elog.Failf("podlist contains %d items, expected %d items", len(podList.Items), *appClone.Spec.Replicas)
|
|
|
|
}
|
|
|
|
for _, pod := range podList.Items {
|
|
|
|
var stdErr string
|
|
|
|
_, stdErr, err = execCommandInPodWithName(f, cmd, pod.Name, pod.Spec.Containers[0].Name, appClone.Namespace)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("command %q failed: %v", cmd, err)
|
|
|
|
}
|
|
|
|
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
|
|
|
|
if !strings.Contains(stdErr, readOnlyErr) {
|
|
|
|
e2elog.Failf(stdErr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-15 14:27:40 +00:00
|
|
|
err = deletePVCAndDeploymentApp(f, pvcClone, appClone)
|
2021-10-28 12:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-10-28 12:34:07 +00:00
|
|
|
// validate images in trash
|
|
|
|
err = waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", rbdOptions(defaultRBDPool), err)
|
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("Create ROX+Block Mode PVC and bind to multiple pods via deployment using rbd-nbd mounter", func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-10-28 12:34:07 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
// Storage class with rbd-nbd mounter
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(rawPvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
app, err := loadApp(rawAppPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2021-10-28 12:34:07 +00:00
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// create clone PVC as ROX
|
|
|
|
pvcClone, err := loadPVC(pvcBlockSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
pvcClone.Spec.DataSource.Name = pvc.Name
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany}
|
|
|
|
volumeMode := v1.PersistentVolumeBlock
|
|
|
|
pvcClone.Spec.VolumeMode = &volumeMode
|
|
|
|
appClone, err := loadAppDeployment(deployBlockAppPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load application deployment: %v", err)
|
|
|
|
}
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
appClone.Spec.Template.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
|
|
|
appClone.Spec.Template.Spec.Volumes[0].PersistentVolumeClaim.ReadOnly = true
|
2022-02-15 14:27:40 +00:00
|
|
|
err = createPVCAndDeploymentApp(f, pvcClone, appClone, deployTimeout)
|
2021-10-28 12:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = waitForDeploymentComplete(f.ClientSet, appClone.Name, appClone.Namespace, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("timeout waiting for deployment to be in running state: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 3, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType)
|
2021-10-28 12:34:07 +00:00
|
|
|
|
|
|
|
devPath := appClone.Spec.Template.Spec.Containers[0].VolumeDevices[0].DevicePath
|
|
|
|
cmd := fmt.Sprintf("dd if=/dev/zero of=%s bs=1M count=10", devPath)
|
|
|
|
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", appClone.Name),
|
|
|
|
}
|
|
|
|
podList, err := f.PodClientNS(appClone.Namespace).List(context.TODO(), opt)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("get pod list failed: %v", err)
|
|
|
|
}
|
|
|
|
if len(podList.Items) != int(*appClone.Spec.Replicas) {
|
|
|
|
e2elog.Failf("podlist contains %d items, expected %d items", len(podList.Items), *appClone.Spec.Replicas)
|
|
|
|
}
|
|
|
|
for _, pod := range podList.Items {
|
|
|
|
var stdErr string
|
|
|
|
_, stdErr, err = execCommandInPodWithName(f, cmd, pod.Name, pod.Spec.Containers[0].Name, appClone.Namespace)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Logf("command %q failed: %v", cmd, err)
|
|
|
|
}
|
|
|
|
readOnlyErr := fmt.Sprintf("'%s': Operation not permitted", devPath)
|
|
|
|
if !strings.Contains(stdErr, readOnlyErr) {
|
|
|
|
e2elog.Failf(stdErr)
|
|
|
|
}
|
|
|
|
}
|
2022-02-15 14:27:40 +00:00
|
|
|
err = deletePVCAndDeploymentApp(f, pvcClone, appClone)
|
2021-10-28 12:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-10-28 12:34:07 +00:00
|
|
|
// validate images in trash
|
|
|
|
err = waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", rbdOptions(defaultRBDPool), err)
|
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-05-31 11:31:02 +00:00
|
|
|
By("perform IO on rbd-nbd volume after nodeplugin restart", func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-02-09 13:17:09 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
// Storage class with rbd-nbd mounter
|
2021-06-25 12:38:30 +00:00
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
2021-08-16 10:19:25 +00:00
|
|
|
map[string]string{
|
2021-09-30 07:11:57 +00:00
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
2021-08-16 10:19:25 +00:00
|
|
|
},
|
2021-06-25 12:38:30 +00:00
|
|
|
deletePolicy)
|
2021-02-09 13:17:09 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
label := map[string]string{
|
|
|
|
"app": app.Name,
|
|
|
|
}
|
|
|
|
app.Labels = label
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
|
2021-07-29 11:44:50 +00:00
|
|
|
appOpt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", app.Name),
|
|
|
|
}
|
|
|
|
// TODO: Remove this once we ensure that rbd-nbd can sync data
|
|
|
|
// from Filesystem layer to backend rbd image as part of its
|
|
|
|
// detach or SIGTERM signal handler
|
|
|
|
_, stdErr, err := execCommandInPod(
|
|
|
|
f,
|
|
|
|
fmt.Sprintf("sync %s", app.Spec.Containers[0].VolumeMounts[0].MountPath),
|
|
|
|
app.Namespace,
|
|
|
|
&appOpt)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to sync, err: %v, stdErr: %v ", err, stdErr)
|
|
|
|
}
|
|
|
|
|
2021-02-09 13:17:09 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2021-02-09 13:17:09 +00:00
|
|
|
|
|
|
|
selector, err := getDaemonSetLabelSelector(f, cephCSINamespace, rbdDaemonsetName)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to get the labels: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
// delete rbd nodeplugin pods
|
|
|
|
err = deletePodWithLabel(selector, cephCSINamespace, false)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("fail to delete pod: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// wait for nodeplugin pods to come up
|
|
|
|
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset pods: %v", err)
|
2021-02-09 13:17:09 +00:00
|
|
|
}
|
|
|
|
|
2021-02-25 07:23:22 +00:00
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: selector,
|
|
|
|
}
|
|
|
|
uname, stdErr, err := execCommandInContainer(f, "uname -a", cephCSINamespace, "csi-rbdplugin", &opt)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to run uname cmd : %v, stdErr: %v ", err, stdErr)
|
|
|
|
}
|
|
|
|
e2elog.Logf("uname -a: %v", uname)
|
2021-06-25 12:38:30 +00:00
|
|
|
rpmv, stdErr, err := execCommandInContainer(
|
|
|
|
f,
|
|
|
|
"rpm -qa | grep rbd-nbd",
|
|
|
|
cephCSINamespace,
|
|
|
|
"csi-rbdplugin",
|
|
|
|
&opt)
|
2021-02-25 07:23:22 +00:00
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to run rpm -qa cmd : %v, stdErr: %v ", err, stdErr)
|
|
|
|
}
|
|
|
|
e2elog.Logf("rbd-nbd package version: %v", rpmv)
|
|
|
|
|
2021-05-31 11:31:02 +00:00
|
|
|
timeout := time.Duration(deployTimeout) * time.Minute
|
|
|
|
var reason string
|
|
|
|
err = wait.PollImmediate(poll, timeout, func() (bool, error) {
|
|
|
|
var runningAttachCmd string
|
|
|
|
runningAttachCmd, stdErr, err = execCommandInContainer(
|
|
|
|
f,
|
2022-02-03 07:17:47 +00:00
|
|
|
"pstree --arguments | grep [r]bd-nbd",
|
2021-05-31 11:31:02 +00:00
|
|
|
cephCSINamespace,
|
|
|
|
"csi-rbdplugin",
|
|
|
|
&opt)
|
2022-02-03 07:17:47 +00:00
|
|
|
// if the rbd-nbd process is not running the 'grep' command
|
2021-05-31 11:31:02 +00:00
|
|
|
// will return with exit code 1
|
|
|
|
if err != nil {
|
|
|
|
if strings.Contains(err.Error(), "command terminated with exit code 1") {
|
|
|
|
reason = fmt.Sprintf("rbd-nbd process is not running yet: %v", err)
|
|
|
|
} else if stdErr != "" {
|
|
|
|
reason = fmt.Sprintf("failed to run ps cmd : %v, stdErr: %v", err, stdErr)
|
|
|
|
}
|
|
|
|
e2elog.Logf("%s", reason)
|
2021-07-22 05:45:17 +00:00
|
|
|
|
2021-05-31 11:31:02 +00:00
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
e2elog.Logf("attach command running after restart, runningAttachCmd: %v", runningAttachCmd)
|
2021-07-22 05:45:17 +00:00
|
|
|
|
2021-05-31 11:31:02 +00:00
|
|
|
return true, nil
|
|
|
|
})
|
2021-02-25 07:23:22 +00:00
|
|
|
|
2021-05-31 11:31:02 +00:00
|
|
|
if errors.Is(err, wait.ErrWaitTimeout) {
|
|
|
|
e2elog.Failf("timed out waiting for the rbd-nbd process: %s", reason)
|
2021-02-25 07:23:22 +00:00
|
|
|
}
|
|
|
|
if err != nil {
|
2021-05-31 11:31:02 +00:00
|
|
|
e2elog.Failf("failed to poll: %v", err)
|
2021-02-25 07:23:22 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 11:45:06 +00:00
|
|
|
// Writes on kernel < 5.4 are failing due to a bug in NBD driver,
|
|
|
|
// NBD zero cmd timeout handling is fixed with kernel >= 5.4
|
|
|
|
// see https://github.com/ceph/ceph-csi/issues/2204#issuecomment-930941047
|
|
|
|
if util.CheckKernelSupport(kernelRelease, nbdZeroIOtimeoutSupport) {
|
|
|
|
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
|
|
|
|
_, stdErr, err = execCommandInPod(
|
|
|
|
f,
|
|
|
|
fmt.Sprintf("echo 'Hello World' > %s", filePath),
|
|
|
|
app.Namespace,
|
|
|
|
&appOpt)
|
|
|
|
if err != nil || stdErr != "" {
|
|
|
|
e2elog.Failf("failed to write IO, err: %v, stdErr: %v ", err, stdErr)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
e2elog.Logf("kernel %q does not meet recommendation, skipping IO test", kernelRelease)
|
2021-02-25 07:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2021-02-25 07:23:22 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-02-25 07:23:22 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-02-25 07:23:22 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-02-25 07:23:22 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-02-25 07:23:22 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-07-14 10:13:11 +00:00
|
|
|
By("create a PVC and bind it to an app using rbd-nbd mounter with encryption", func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-07-14 10:13:11 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
// Storage class with rbd-nbd mounter
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
2021-08-16 10:19:25 +00:00
|
|
|
map[string]string{
|
2021-09-30 07:11:57 +00:00
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
|
|
|
"encrypted": "true",
|
2021-08-16 10:19:25 +00:00
|
|
|
},
|
2021-07-14 10:13:11 +00:00
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, noKMS, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-14 10:13:11 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-14 10:13:11 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a PVC and bind it to an app with encrypted RBD volume", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{"encrypted": "true"},
|
|
|
|
deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-07-09 11:49:23 +00:00
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, noKMS, f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-07-07 10:21:21 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-07 10:21:21 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("Resize Encrypted Block PVC and check Device size", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-07 10:21:21 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{"encrypted": "true"},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-07 10:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FileSystem PVC resize
|
|
|
|
err = resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to resize filesystem PVC: %v", err)
|
2021-07-07 10:21:21 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-07 10:21:21 +00:00
|
|
|
|
|
|
|
// Block PVC resize
|
|
|
|
err = resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to resize block PVC: %v", err)
|
2021-07-07 10:21:21 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-07 10:21:21 +00:00
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-07 10:21:21 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-01-29 11:44:45 +00:00
|
|
|
})
|
|
|
|
|
2020-12-09 16:10:43 +00:00
|
|
|
By("create a PVC and bind it to an app with encrypted RBD volume with VaultKMS", func() {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-01-29 11:44:45 +00:00
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-07-09 11:49:23 +00:00
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, vaultKMS, f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2019-12-13 11:41:32 +00:00
|
|
|
})
|
|
|
|
|
2020-12-09 16:10:43 +00:00
|
|
|
By("create a PVC and bind it to an app with encrypted RBD volume with VaultTokensKMS", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-12-09 16:10:43 +00:00
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-tokens-test",
|
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
2020-12-09 16:10:43 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-12-09 16:10:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// name(space) of the Tenant
|
|
|
|
tenant := f.UniqueName
|
|
|
|
|
|
|
|
// create the Secret with Vault Token in the Tenants namespace
|
|
|
|
token, err := getSecret(vaultExamplePath + "tenant-token.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load tenant token from secret: %v", err)
|
|
|
|
}
|
|
|
|
_, err = c.CoreV1().Secrets(tenant).Create(context.TODO(), &token, metav1.CreateOptions{})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create Secret with tenant token: %v", err)
|
|
|
|
}
|
|
|
|
|
2021-07-09 11:49:23 +00:00
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, vaultTokensKMS, f)
|
2020-12-09 16:10:43 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
2020-12-09 16:10:43 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-12-09 16:10:43 +00:00
|
|
|
|
|
|
|
// delete the Secret of the Tenant
|
|
|
|
err = c.CoreV1().Secrets(tenant).Delete(context.TODO(), token.Name, metav1.DeleteOptions{})
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete Secret with tenant token: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-12-09 16:10:43 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-12-09 16:10:43 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-12-09 16:10:43 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-07-08 08:33:17 +00:00
|
|
|
By("create a PVC and bind it to an app with encrypted RBD volume with VaultTenantSA KMS", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-tenant-sa-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = createTenantServiceAccount(f.ClientSet, f.UniqueName)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create ServiceAccount: %v", err)
|
|
|
|
}
|
|
|
|
defer deleteTenantServiceAccount(f.UniqueName)
|
|
|
|
|
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, vaultTenantSAKMS, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-08 08:33:17 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-03-04 09:23:53 +00:00
|
|
|
By("create a PVC and bind it to an app with encrypted RBD volume with SecretsMetadataKMS", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-03-04 09:23:53 +00:00
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "secrets-metadata-test",
|
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
2021-03-04 09:23:53 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-03-04 09:23:53 +00:00
|
|
|
}
|
2021-07-09 11:49:23 +00:00
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, noKMS, f)
|
2021-03-04 09:23:53 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
2021-03-04 09:23:53 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-03-04 09:23:53 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-03-04 09:23:53 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-03-04 09:23:53 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-03-04 09:23:53 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-07-05 08:28:33 +00:00
|
|
|
By("test RBD volume encryption with user secrets based SecretsMetadataKMS", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "user-ns-secrets-metadata-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// user provided namespace where secret will be created
|
|
|
|
namespace := cephCSINamespace
|
|
|
|
|
|
|
|
// create user Secret
|
2021-08-05 11:58:48 +00:00
|
|
|
err = retryKubectlFile(namespace, kubectlCreate, vaultExamplePath+vaultUserSecret, deployTimeout)
|
2021-07-05 08:28:33 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create user Secret: %v", err)
|
|
|
|
}
|
|
|
|
|
2021-07-09 11:49:23 +00:00
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, noKMS, f)
|
2021-07-05 08:28:33 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-05 08:28:33 +00:00
|
|
|
|
|
|
|
// delete user secret
|
2021-08-02 11:04:12 +00:00
|
|
|
err = retryKubectlFile(namespace,
|
|
|
|
kubectlDelete,
|
2021-08-05 11:58:48 +00:00
|
|
|
vaultExamplePath+vaultUserSecret,
|
2021-08-02 11:04:12 +00:00
|
|
|
deployTimeout,
|
|
|
|
"--ignore-not-found=true")
|
2021-07-05 08:28:33 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete user Secret: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By(
|
|
|
|
"test RBD volume encryption with user secrets based SecretsMetadataKMS with tenant namespace",
|
|
|
|
func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "user-secrets-metadata-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PVC creation namespace where secret will be created
|
|
|
|
namespace := f.UniqueName
|
|
|
|
|
|
|
|
// create user Secret
|
2021-08-05 11:58:48 +00:00
|
|
|
err = retryKubectlFile(namespace, kubectlCreate, vaultExamplePath+vaultUserSecret, deployTimeout)
|
2021-07-05 08:28:33 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create user Secret: %v", err)
|
|
|
|
}
|
|
|
|
|
2021-07-09 11:49:23 +00:00
|
|
|
err = validateEncryptedPVCAndAppBinding(pvcPath, appPath, noKMS, f)
|
2021-07-05 08:28:33 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate encrypted pvc: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-05 08:28:33 +00:00
|
|
|
|
|
|
|
// delete user secret
|
2021-08-02 11:04:12 +00:00
|
|
|
err = retryKubectlFile(
|
|
|
|
namespace,
|
|
|
|
kubectlDelete,
|
2021-08-05 11:58:48 +00:00
|
|
|
vaultExamplePath+vaultUserSecret,
|
2021-08-02 11:04:12 +00:00
|
|
|
deployTimeout,
|
|
|
|
"--ignore-not-found=true")
|
2021-07-05 08:28:33 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete user Secret: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-06-25 12:38:30 +00:00
|
|
|
By(
|
|
|
|
"create a PVC and Bind it to an app with journaling/exclusive-lock image-features and rbd-nbd mounter",
|
|
|
|
func() {
|
2022-10-13 08:22:55 +00:00
|
|
|
if !testNBD {
|
|
|
|
e2elog.Logf("skipping NBD test")
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-06-25 12:38:30 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-06-25 12:38:30 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
2021-08-16 10:19:25 +00:00
|
|
|
map[string]string{
|
2021-09-30 07:11:57 +00:00
|
|
|
"imageFeatures": "layering,journaling,exclusive-lock",
|
|
|
|
"mounter": "rbd-nbd",
|
|
|
|
"mapOptions": nbdMapOptions,
|
|
|
|
"cephLogStrategy": e2eDefaultCephLogStrategy,
|
2021-08-16 10:19:25 +00:00
|
|
|
},
|
2021-06-25 12:38:30 +00:00
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-06-25 12:38:30 +00:00
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2021-06-25 12:38:30 +00:00
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-06-25 12:38:30 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-06-25 12:38:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
)
|
2021-03-11 06:28:48 +00:00
|
|
|
|
2020-05-15 08:34:59 +00:00
|
|
|
By("create a PVC clone and bind it to an app", func() {
|
2021-11-03 09:55:08 +00:00
|
|
|
validatePVCSnapshot(
|
|
|
|
defaultCloneCount,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
snapshotPath,
|
|
|
|
pvcClonePath,
|
|
|
|
appClonePath,
|
|
|
|
noKMS, noKMS,
|
|
|
|
defaultSCName,
|
2021-10-27 08:22:50 +00:00
|
|
|
noDataPool,
|
2021-11-03 09:55:08 +00:00
|
|
|
f)
|
2020-04-16 07:09:59 +00:00
|
|
|
})
|
2019-06-14 09:26:17 +00:00
|
|
|
|
2020-07-08 12:59:38 +00:00
|
|
|
By("create a PVC-PVC clone and bind it to an app", func() {
|
2021-11-03 09:58:19 +00:00
|
|
|
validatePVCClone(
|
|
|
|
defaultCloneCount,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
pvcSmartClonePath,
|
|
|
|
appSmartClonePath,
|
2022-04-26 06:38:49 +00:00
|
|
|
defaultSCName,
|
2021-10-27 08:25:23 +00:00
|
|
|
noDataPool,
|
2021-11-03 09:58:19 +00:00
|
|
|
noKMS,
|
|
|
|
noPVCValidation,
|
|
|
|
f)
|
2021-06-07 08:13:14 +00:00
|
|
|
})
|
|
|
|
|
2021-04-26 13:15:18 +00:00
|
|
|
By("create an encrypted PVC snapshot and restore it for an app with VaultKMS", func() {
|
2021-04-08 15:46:11 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-04-08 15:46:11 +00:00
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
2021-04-26 13:15:18 +00:00
|
|
|
"encryptionKMSID": "vault-test",
|
2021-04-08 15:46:11 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
2021-04-08 15:46:11 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-04-08 15:46:11 +00:00
|
|
|
}
|
|
|
|
|
2021-09-29 06:46:55 +00:00
|
|
|
validatePVCSnapshot(1,
|
|
|
|
pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath,
|
|
|
|
vaultKMS, vaultKMS,
|
2021-10-27 08:22:50 +00:00
|
|
|
defaultSCName, noDataPool,
|
2021-09-29 06:46:55 +00:00
|
|
|
f)
|
2021-04-08 15:46:11 +00:00
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-04-08 15:46:11 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-04-08 15:46:11 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-04-08 15:46:11 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-09-30 04:41:29 +00:00
|
|
|
By("Validate PVC restore from vaultKMS to vaultTenantSAKMS", func() {
|
|
|
|
restoreSCName := "restore-sc"
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
scOpts = map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-tenant-sa-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, restoreSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = createTenantServiceAccount(f.ClientSet, f.UniqueName)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create ServiceAccount: %v", err)
|
|
|
|
}
|
|
|
|
defer deleteTenantServiceAccount(f.UniqueName)
|
|
|
|
|
|
|
|
validatePVCSnapshot(1,
|
|
|
|
pvcPath, appPath, snapshotPath, pvcClonePath, appClonePath,
|
|
|
|
vaultKMS, vaultTenantSAKMS,
|
2021-10-27 08:22:50 +00:00
|
|
|
restoreSCName, noDataPool, f)
|
2021-09-30 04:41:29 +00:00
|
|
|
|
|
|
|
err = retryKubectlArgs(cephCSINamespace, kubectlDelete, deployTimeout, "storageclass", restoreSCName)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass %q: %v", restoreSCName, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-09-30 04:41:29 +00:00
|
|
|
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-10-01 08:47:31 +00:00
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-04-26 06:38:49 +00:00
|
|
|
By("Validate PVC-PVC clone with different SC from vaultKMS to vaultTenantSAKMS", func() {
|
|
|
|
restoreSCName := "restore-sc"
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
scOpts = map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-tenant-sa-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, restoreSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = createTenantServiceAccount(f.ClientSet, f.UniqueName)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create ServiceAccount: %v", err)
|
|
|
|
}
|
|
|
|
defer deleteTenantServiceAccount(f.UniqueName)
|
|
|
|
|
|
|
|
validatePVCClone(1,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
pvcSmartClonePath,
|
|
|
|
appSmartClonePath,
|
|
|
|
restoreSCName,
|
|
|
|
noDataPool,
|
|
|
|
secretsMetadataKMS,
|
|
|
|
isEncryptedPVC,
|
|
|
|
f)
|
|
|
|
|
|
|
|
err = retryKubectlArgs(cephCSINamespace, kubectlDelete, deployTimeout, "storageclass", restoreSCName)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass %q: %v", restoreSCName, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-03-12 15:42:31 +00:00
|
|
|
By("create an encrypted PVC-PVC clone and bind it to an app", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-03-12 15:42:31 +00:00
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "secrets-metadata-test",
|
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
2021-03-12 15:42:31 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-03-12 15:42:31 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 08:25:23 +00:00
|
|
|
validatePVCClone(1,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
pvcSmartClonePath,
|
|
|
|
appSmartClonePath,
|
2022-04-26 06:38:49 +00:00
|
|
|
defaultSCName,
|
2021-10-27 08:25:23 +00:00
|
|
|
noDataPool,
|
|
|
|
secretsMetadataKMS,
|
|
|
|
isEncryptedPVC,
|
|
|
|
f)
|
2021-05-20 08:46:39 +00:00
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-05-20 08:46:39 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-05-20 08:46:39 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("create an encrypted PVC-PVC clone and bind it to an app with VaultKMS", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-05-20 08:46:39 +00:00
|
|
|
}
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-05-20 08:46:39 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 08:25:23 +00:00
|
|
|
validatePVCClone(1,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
pvcSmartClonePath,
|
|
|
|
appSmartClonePath,
|
2022-04-26 06:38:49 +00:00
|
|
|
defaultSCName,
|
2021-10-27 08:25:23 +00:00
|
|
|
noDataPool,
|
|
|
|
vaultKMS,
|
|
|
|
isEncryptedPVC,
|
|
|
|
f)
|
2021-03-12 15:42:31 +00:00
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-03-12 15:42:31 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-03-12 15:42:31 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-07-08 12:59:38 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("create a block type PVC and bind it to an app", func() {
|
|
|
|
err := validatePVCAndAppBinding(rawPvcPath, rawAppPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2019-12-18 08:36:47 +00:00
|
|
|
})
|
2020-10-15 13:54:57 +00:00
|
|
|
By("create a Block mode PVC-PVC clone and bind it to an app", func() {
|
2021-11-03 09:58:19 +00:00
|
|
|
_, err := f.ClientSet.Discovery().ServerVersion()
|
2020-10-15 13:54:57 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to get server version: %v", err)
|
2020-10-15 13:54:57 +00:00
|
|
|
}
|
2021-11-03 09:58:19 +00:00
|
|
|
validatePVCClone(
|
|
|
|
defaultCloneCount,
|
|
|
|
rawPvcPath,
|
|
|
|
rawAppPath,
|
|
|
|
pvcBlockSmartClonePath,
|
|
|
|
appBlockSmartClonePath,
|
2022-04-26 06:38:49 +00:00
|
|
|
defaultSCName,
|
2021-10-27 08:25:23 +00:00
|
|
|
noDataPool,
|
2021-11-03 09:58:19 +00:00
|
|
|
noKMS,
|
|
|
|
noPVCValidation,
|
|
|
|
f)
|
2020-10-15 13:54:57 +00:00
|
|
|
})
|
2019-06-18 07:07:11 +00:00
|
|
|
By("create/delete multiple PVCs and Apps", func() {
|
|
|
|
totalCount := 2
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
2020-09-03 09:34:29 +00:00
|
|
|
// create PVC and app
|
2019-06-18 07:07:11 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
2020-03-27 18:21:18 +00:00
|
|
|
err := createPVCAndApp(name, f, pvc, app, deployTimeout)
|
2019-06-18 07:07:11 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, totalCount, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, totalCount, rbdType, defaultRBDPool, volumesType)
|
2020-09-03 09:34:29 +00:00
|
|
|
// delete PVC and app
|
2019-06-18 07:07:11 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
err := deletePVCAndApp(name, f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2019-06-18 07:07:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2019-06-14 09:26:17 +00:00
|
|
|
})
|
2019-07-03 10:02:36 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
By("check data persist after recreating pod", func() {
|
2019-07-03 10:02:36 +00:00
|
|
|
err := checkDataPersist(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check data persist: %v", err)
|
2019-07-03 10:02:36 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2019-07-03 10:02:36 +00:00
|
|
|
})
|
2019-09-19 12:19:57 +00:00
|
|
|
|
2019-12-18 10:35:48 +00:00
|
|
|
By("Resize Filesystem PVC and check application directory size", func() {
|
2021-11-03 09:59:04 +00:00
|
|
|
err := resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to resize filesystem PVC %v", err)
|
|
|
|
}
|
2019-11-27 12:15:49 +00:00
|
|
|
|
2021-11-03 09:59:04 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2019-12-13 10:29:33 +00:00
|
|
|
}
|
2021-11-03 09:59:04 +00:00
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{"csi.storage.k8s.io/fstype": "xfs"},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
|
|
|
err = resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to resize filesystem PVC: %v", err)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2019-11-27 12:15:49 +00:00
|
|
|
})
|
|
|
|
|
2019-12-18 10:35:48 +00:00
|
|
|
By("Resize Block PVC and check Device size", func() {
|
2021-11-03 09:58:19 +00:00
|
|
|
err := resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to resize block PVC: %v", err)
|
2019-12-18 10:35:48 +00:00
|
|
|
}
|
2021-11-03 09:58:19 +00:00
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2019-12-18 10:35:48 +00:00
|
|
|
})
|
|
|
|
|
2019-09-19 12:19:57 +00:00
|
|
|
By("Test unmount after nodeplugin restart", func() {
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
2020-03-27 18:21:18 +00:00
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
2019-09-19 12:19:57 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2019-09-19 12:19:57 +00:00
|
|
|
// delete rbd nodeplugin pods
|
2020-04-01 07:20:43 +00:00
|
|
|
err = deletePodWithLabel("app=csi-rbdplugin", cephCSINamespace, false)
|
2019-09-19 12:19:57 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("fail to delete pod: %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
// wait for nodeplugin pods to come up
|
2020-02-25 11:45:54 +00:00
|
|
|
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
2019-09-19 12:19:57 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset pods: %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2019-09-19 12:19:57 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2019-09-19 12:19:57 +00:00
|
|
|
})
|
2020-01-31 08:49:11 +00:00
|
|
|
|
2020-02-24 13:19:42 +00:00
|
|
|
By("create PVC in storageClass with volumeNamePrefix", func() {
|
|
|
|
volumeNamePrefix := "foo-bar-"
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{"volumeNamePrefix": volumeNamePrefix},
|
|
|
|
deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-02-24 13:19:42 +00:00
|
|
|
// set up PVC
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2020-02-24 13:19:42 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
2020-02-24 13:19:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2020-02-24 13:19:42 +00:00
|
|
|
// list RBD images and check if one of them has the same prefix
|
|
|
|
foundIt := false
|
2021-03-19 09:09:28 +00:00
|
|
|
images, err := listRBDImages(f, defaultRBDPool)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to list rbd images: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
for _, imgName := range images {
|
2020-02-24 13:19:42 +00:00
|
|
|
fmt.Printf("Checking prefix on %s\n", imgName)
|
|
|
|
if strings.HasPrefix(imgName, volumeNamePrefix) {
|
|
|
|
foundIt = true
|
2021-07-22 05:45:17 +00:00
|
|
|
|
2020-02-24 13:19:42 +00:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clean up after ourselves
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
2020-02-24 13:19:42 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-02-24 13:19:42 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-02-24 13:19:42 +00:00
|
|
|
if !foundIt {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("could not find image with prefix %s", volumeNamePrefix)
|
2020-02-24 13:19:42 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-01-20 07:11:21 +00:00
|
|
|
By("validate RBD static FileSystem PVC", func() {
|
2021-06-15 10:08:51 +00:00
|
|
|
err := validateRBDStaticPV(f, appPath, false, false)
|
2020-01-20 07:11:21 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate rbd static pv: %v", err)
|
2020-01-20 07:11:21 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-01-20 07:11:21 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("validate RBD static Block PVC", func() {
|
2021-06-15 10:08:51 +00:00
|
|
|
err := validateRBDStaticPV(f, rawAppPath, true, false)
|
2020-01-20 07:11:21 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate rbd block pv: %v", err)
|
2020-01-20 07:11:21 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-01-20 07:11:21 +00:00
|
|
|
})
|
|
|
|
|
2021-06-15 10:08:51 +00:00
|
|
|
By("validate failure of RBD static PVC without imageFeatures parameter", func() {
|
|
|
|
err := validateRBDStaticPV(f, rawAppPath, true, true)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("Validation of static PVC without imageFeatures parameter failed with err %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-06-15 10:08:51 +00:00
|
|
|
})
|
|
|
|
|
2020-03-02 08:31:44 +00:00
|
|
|
By("validate mount options in app pod", func() {
|
|
|
|
mountFlags := []string{"discard"}
|
|
|
|
err := checkMountOptions(pvcPath, appPath, f, mountFlags)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check mount options: %v", err)
|
2020-03-02 08:31:44 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-03-02 08:31:44 +00:00
|
|
|
})
|
|
|
|
|
2020-03-27 18:21:18 +00:00
|
|
|
By("creating an app with a PVC, using a topology constrained StorageClass", func() {
|
|
|
|
By("checking node has required CSI topology labels set", func() {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := checkNodeHasLabel(f.ClientSet, nodeCSIRegionLabel, regionValue)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = checkNodeHasLabel(f.ClientSet, nodeCSIZoneLabel, zoneValue)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check node label: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
By("creating a StorageClass with delayed binding mode and CSI topology parameter")
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
topologyConstraint := "[{\"poolName\":\"" + rbdTopologyPool + "\",\"domainSegments\":" +
|
|
|
|
"[{\"domainLabel\":\"region\",\"value\":\"" + regionValue + "\"}," +
|
|
|
|
"{\"domainLabel\":\"zone\",\"value\":\"" + zoneValue + "\"}]}]"
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName,
|
2020-03-27 18:21:18 +00:00
|
|
|
map[string]string{"volumeBindingMode": "WaitForFirstConsumer"},
|
2020-10-28 06:08:11 +00:00
|
|
|
map[string]string{"topologyConstrainedPools": topologyConstraint}, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
|
|
|
|
By("creating an app using a PV from the delayed binding mode StorageClass")
|
2020-09-03 09:34:29 +00:00
|
|
|
pvc, app, err := createPVCAndAppBinding(pvcPath, appPath, f, 0)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2022-04-25 11:49:04 +00:00
|
|
|
|
2020-03-27 18:21:18 +00:00
|
|
|
By("ensuring created PV has required node selector values populated")
|
2020-09-03 09:34:29 +00:00
|
|
|
err = checkPVSelectorValuesForPVC(f, pvc)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check pv selector values: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
By("ensuring created PV has its image in the topology specific pool")
|
2020-09-03 09:34:29 +00:00
|
|
|
err = checkPVCImageInPool(f, pvc, rbdTopologyPool)
|
2020-03-27 18:21:18 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check image in pool: %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created PV has its image journal in the topology specific pool")
|
|
|
|
err = checkPVCImageJournalInPool(f, pvc, rbdTopologyPool)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check image journal: %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created PV has its CSI journal in the CSI journal specific pool")
|
|
|
|
err = checkPVCCSIJournalInPool(f, pvc, "replicapool")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check csi journal in pool: %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
|
|
|
|
2022-05-05 02:46:40 +00:00
|
|
|
err = deleteJournalInfoInPool(f, pvc, "replicapool")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete omap data: %v", err)
|
|
|
|
}
|
2020-03-27 18:21:18 +00:00
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2020-03-27 18:21:18 +00:00
|
|
|
}
|
2022-04-25 11:49:04 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-04-06 20:19:13 +00:00
|
|
|
|
|
|
|
By("checking if data pool parameter is honored", func() {
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
topologyConstraint := "[{\"poolName\":\"" + rbdTopologyPool + "\",\"dataPool\":\"" + rbdTopologyDataPool +
|
|
|
|
"\",\"domainSegments\":" +
|
|
|
|
"[{\"domainLabel\":\"region\",\"value\":\"" + regionValue + "\"}," +
|
|
|
|
"{\"domainLabel\":\"zone\",\"value\":\"" + zoneValue + "\"}]}]"
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName,
|
2020-04-06 20:19:13 +00:00
|
|
|
map[string]string{"volumeBindingMode": "WaitForFirstConsumer"},
|
2020-10-28 06:08:11 +00:00
|
|
|
map[string]string{"topologyConstrainedPools": topologyConstraint}, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
By("creating an app using a PV from the delayed binding mode StorageClass with a data pool")
|
2020-09-03 09:34:29 +00:00
|
|
|
pvc, app, err = createPVCAndAppBinding(pvcPath, appPath, f, 0)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
|
|
|
|
By("ensuring created PV has its image in the topology specific pool")
|
|
|
|
err = checkPVCImageInPool(f, pvc, rbdTopologyPool)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check pvc image in pool: %v", err)
|
2020-04-06 20:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
By("ensuring created image has the right data pool parameter set")
|
|
|
|
err = checkPVCDataPoolForImageInPool(f, pvc, rbdTopologyPool, rbdTopologyDataPool)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to check data pool for image: %v", err)
|
2020-04-06 20:19:13 +00:00
|
|
|
}
|
|
|
|
|
2022-05-05 02:46:40 +00:00
|
|
|
err = deleteJournalInfoInPool(f, pvc, "replicapool")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete omap data: %v", err)
|
|
|
|
}
|
2020-04-06 20:19:13 +00:00
|
|
|
// cleanup and undo changes made by the test
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2020-04-06 20:19:13 +00:00
|
|
|
}
|
2022-04-25 11:49:04 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-04-06 20:19:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// cleanup and undo changes made by the test
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2022-04-25 11:49:04 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-03-27 18:21:18 +00:00
|
|
|
})
|
|
|
|
|
2020-05-18 13:07:58 +00:00
|
|
|
// Mount pvc to pod with invalid mount option,expected that
|
|
|
|
// mounting will fail
|
|
|
|
By("Mount pvc to pod with invalid mount option", func() {
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
map[string]string{rbdMountOptions: "debug,invalidOption"},
|
|
|
|
nil,
|
|
|
|
deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-05-18 13:07:58 +00:00
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2020-09-03 09:34:29 +00:00
|
|
|
|
2020-07-03 10:03:11 +00:00
|
|
|
// create an app and wait for 1 min for it to go to running state
|
|
|
|
err = createApp(f.ClientSet, app, 1)
|
2020-05-18 13:07:58 +00:00
|
|
|
if err == nil {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf("application should not go to running state due to invalid mount option")
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2020-05-18 13:07:58 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-08-17 08:37:19 +00:00
|
|
|
}
|
2020-05-18 13:07:58 +00:00
|
|
|
})
|
|
|
|
|
2021-03-22 07:35:15 +00:00
|
|
|
By("create rbd clones in different pool", func() {
|
|
|
|
clonePool := "clone-test"
|
|
|
|
// create pool for clones
|
|
|
|
err := createPool(f, clonePool)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create pool %s: %v", clonePool, err)
|
2021-03-22 07:35:15 +00:00
|
|
|
}
|
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create snapshotclass: %v", err)
|
2021-03-22 07:35:15 +00:00
|
|
|
}
|
|
|
|
cloneSC := "clone-storageclass"
|
|
|
|
param := map[string]string{
|
|
|
|
"pool": clonePool,
|
|
|
|
}
|
|
|
|
// create new storageclass with new pool
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, cloneSC, nil, param, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-03-22 07:35:15 +00:00
|
|
|
}
|
|
|
|
err = validateCloneInDifferentPool(f, defaultRBDPool, cloneSC, clonePool)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate clones in different pool: %v", err)
|
2021-03-22 07:35:15 +00:00
|
|
|
}
|
|
|
|
|
2021-07-28 03:51:18 +00:00
|
|
|
err = retryKubectlArgs(
|
|
|
|
cephCSINamespace,
|
|
|
|
kubectlDelete,
|
|
|
|
deployTimeout,
|
|
|
|
"sc",
|
|
|
|
cloneSC,
|
|
|
|
"--ignore-not-found=true")
|
2021-03-22 07:35:15 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass %s: %v", cloneSC, err)
|
2021-03-22 07:35:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteResource(rbdExamplePath + "snapshotclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete snapshotclass: %v", err)
|
2021-03-22 07:35:15 +00:00
|
|
|
}
|
2021-06-15 05:08:38 +00:00
|
|
|
// validate images in trash
|
|
|
|
err = waitToRemoveImagesFromTrash(f, clonePool, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", clonePool, err)
|
2021-06-15 05:08:38 +00:00
|
|
|
}
|
|
|
|
err = waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", defaultRBDPool, err)
|
2021-06-15 05:08:38 +00:00
|
|
|
}
|
2021-03-22 07:35:15 +00:00
|
|
|
|
|
|
|
err = deletePool(clonePool, false, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete pool %s: %v", clonePool, err)
|
2021-03-22 07:35:15 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-04-16 14:47:43 +00:00
|
|
|
By("create ROX PVC clone and mount it to multiple pods", func() {
|
2021-11-03 09:55:08 +00:00
|
|
|
err := createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
2021-04-08 15:46:11 +00:00
|
|
|
if err != nil {
|
2021-11-03 09:55:08 +00:00
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
2021-04-08 15:46:11 +00:00
|
|
|
}
|
2021-11-03 09:55:08 +00:00
|
|
|
}()
|
2021-04-08 15:46:11 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
2020-04-16 14:47:43 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2021-11-03 09:55:08 +00:00
|
|
|
// delete pod as we should not create snapshot for in-use pvc
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
2020-04-16 14:47:43 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
2020-04-16 14:47:43 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create snapshot: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent PVC + snapshot
|
|
|
|
totalImages := 2
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2021-11-03 09:55:08 +00:00
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
2020-04-16 14:47:43 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
// create clone PVC as ROX
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany}
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent pvc+ snapshot + clone
|
|
|
|
totalImages = 3
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2020-09-03 09:34:29 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
appClone, err := loadApp(appClonePath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
2020-04-16 14:47:43 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
totalCount := 2
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
appClone.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
2020-04-16 14:47:43 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
// create PVC and app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
label := map[string]string{
|
|
|
|
"app": name,
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2021-11-03 09:55:08 +00:00
|
|
|
appClone.Labels = label
|
|
|
|
appClone.Name = name
|
|
|
|
err = createApp(f.ClientSet, appClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
2020-04-16 14:47:43 +00:00
|
|
|
|
2021-11-03 09:55:08 +00:00
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", name),
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2021-11-03 09:55:08 +00:00
|
|
|
|
|
|
|
filePath := appClone.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
|
|
|
|
_, stdErr := execCommandInPodAndAllowFail(
|
|
|
|
f,
|
|
|
|
fmt.Sprintf("echo 'Hello World' > %s", filePath),
|
|
|
|
appClone.Namespace,
|
|
|
|
&opt)
|
|
|
|
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
|
|
|
|
if !strings.Contains(stdErr, readOnlyErr) {
|
|
|
|
e2elog.Failf(stdErr)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// delete app
|
|
|
|
for i := 0; i < totalCount; i++ {
|
|
|
|
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
|
|
|
appClone.Name = name
|
|
|
|
err = deletePod(appClone.Name, appClone.Namespace, f.ClientSet, deployTimeout)
|
2020-04-16 14:47:43 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
2020-04-16 14:47:43 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-03 09:55:08 +00:00
|
|
|
// delete PVC clone
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
// delete snapshot
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete snapshot: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-04-16 14:47:43 +00:00
|
|
|
})
|
|
|
|
|
2021-05-03 11:22:30 +00:00
|
|
|
By("validate PVC mounting if snapshot and parent PVC are deleted", func() {
|
|
|
|
err := createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2021-05-03 11:22:30 +00:00
|
|
|
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create snapshot: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent PVC + snapshot
|
|
|
|
totalImages := 2
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2021-05-03 11:22:30 +00:00
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// delete parent PVC
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2021-05-03 11:22:30 +00:00
|
|
|
|
|
|
|
// create clone PVC
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images = snapshot + clone
|
|
|
|
totalImages = 2
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2021-05-03 11:22:30 +00:00
|
|
|
|
|
|
|
// delete snapshot
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete snapshot: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images = clone
|
|
|
|
totalImages = 1
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
|
2021-05-03 11:22:30 +00:00
|
|
|
|
|
|
|
appClone, err := loadApp(appClonePath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
appClone.Namespace = f.UniqueName
|
|
|
|
appClone.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
|
|
|
|
|
|
|
// create application
|
|
|
|
err = createApp(f.ClientSet, appClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePod(appClone.Name, appClone.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
// delete PVC clone
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
2021-05-03 11:22:30 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
|
2021-05-03 11:22:30 +00:00
|
|
|
})
|
|
|
|
|
2021-07-15 06:13:00 +00:00
|
|
|
By(
|
|
|
|
"validate PVC mounting if snapshot and parent PVC are deleted chained with depth 2",
|
|
|
|
func() {
|
|
|
|
snapChainDepth := 2
|
|
|
|
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2021-07-15 06:13:00 +00:00
|
|
|
for i := 0; i < snapChainDepth; i++ {
|
|
|
|
var pvcClone *v1.PersistentVolumeClaim
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Name = fmt.Sprintf("%s-%d", snap.Name, i)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create snapshot: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent PVC + snapshot
|
|
|
|
totalImages := 2
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2021-07-15 06:13:00 +00:00
|
|
|
pvcClone, err = loadPVC(pvcClonePath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// delete parent PVC
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2021-07-15 06:13:00 +00:00
|
|
|
|
|
|
|
// create clone PVC
|
|
|
|
pvcClone.Name = fmt.Sprintf("%s-%d", pvcClone.Name, i)
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.DataSource.Name = snap.Name
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images = snapshot + clone
|
|
|
|
totalImages = 2
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2021-07-15 06:13:00 +00:00
|
|
|
|
|
|
|
// delete snapshot
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete snapshot: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// validate created backend rbd images = clone
|
|
|
|
totalImages = 1
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
|
2021-07-15 06:13:00 +00:00
|
|
|
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
|
|
|
// create application
|
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc = pvcClone
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
// delete PVC clone
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
2021-07-15 06:13:00 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
|
2021-07-15 06:13:00 +00:00
|
|
|
})
|
|
|
|
|
2021-07-15 09:09:08 +00:00
|
|
|
By("validate PVC Clone chained with depth 2", func() {
|
|
|
|
cloneChainDepth := 2
|
|
|
|
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2021-07-15 09:09:08 +00:00
|
|
|
|
|
|
|
for i := 0; i < cloneChainDepth; i++ {
|
|
|
|
var pvcClone *v1.PersistentVolumeClaim
|
|
|
|
pvcClone, err = loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// create clone PVC
|
|
|
|
pvcClone.Name = fmt.Sprintf("%s-%d", pvcClone.Name, i)
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.DataSource.Name = pvc.Name
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// delete parent PVC
|
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
|
|
|
// create application
|
|
|
|
err = createApp(f.ClientSet, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create application: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc = pvcClone
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete application: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
// delete PVC clone
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
2021-07-15 09:09:08 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-07-15 09:09:08 +00:00
|
|
|
})
|
|
|
|
|
2020-06-02 19:19:57 +00:00
|
|
|
By("ensuring all operations will work within a rados namespace", func() {
|
|
|
|
updateConfigMap := func(radosNS string) {
|
|
|
|
radosNamespace = radosNS
|
2020-09-03 09:34:29 +00:00
|
|
|
err := deleteConfigMap(rbdDirPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete configmap:: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = createConfigMap(rbdDirPath, f.ClientSet, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create configmap: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
|
|
|
err = createRadosNamespace(f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create rados namespace: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2020-06-02 19:19:57 +00:00
|
|
|
// delete csi pods
|
2020-09-03 09:34:29 +00:00
|
|
|
err = deletePodWithLabel("app in (ceph-csi-rbd, csi-rbdplugin, csi-rbdplugin-provisioner)",
|
2020-06-02 19:19:57 +00:00
|
|
|
cephCSINamespace, false)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete pods with labels: %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
// wait for csi pods to come up
|
|
|
|
err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("timeout waiting for daemonset pods: %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
2021-10-29 08:36:30 +00:00
|
|
|
err = waitForDeploymentComplete(f.ClientSet, rbdDeploymentName, cephCSINamespace, deployTimeout)
|
2020-06-02 19:19:57 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("timeout waiting for deployment to be in running state: %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
updateConfigMap("e2e-ns")
|
2021-02-22 11:13:40 +00:00
|
|
|
// create rbd provisioner secret
|
2021-06-25 12:38:30 +00:00
|
|
|
key, err := createCephUser(
|
|
|
|
f,
|
|
|
|
keyringRBDNamespaceProvisionerUsername,
|
|
|
|
rbdProvisionerCaps(defaultRBDPool, radosNamespace),
|
|
|
|
)
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create user %s: %v", keyringRBDNamespaceProvisionerUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
err = createRBDSecret(f, rbdNamespaceProvisionerSecretName, keyringRBDNamespaceProvisionerUsername, key)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create provisioner secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
// create rbd plugin secret
|
2021-06-25 12:38:30 +00:00
|
|
|
key, err = createCephUser(
|
|
|
|
f,
|
|
|
|
keyringRBDNamespaceNodePluginUsername,
|
|
|
|
rbdNodePluginCaps(defaultRBDPool, radosNamespace))
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create user %s: %v", keyringRBDNamespaceNodePluginUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
err = createRBDSecret(f, rbdNamespaceNodePluginSecretName, keyringRBDNamespaceNodePluginUsername, key)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create node secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2020-06-02 19:19:57 +00:00
|
|
|
|
2021-02-22 11:13:40 +00:00
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
param := make(map[string]string)
|
|
|
|
// override existing secrets
|
|
|
|
param["csi.storage.k8s.io/provisioner-secret-namespace"] = cephCSINamespace
|
|
|
|
param["csi.storage.k8s.io/provisioner-secret-name"] = rbdProvisionerSecretName
|
|
|
|
param["csi.storage.k8s.io/controller-expand-secret-namespace"] = cephCSINamespace
|
|
|
|
param["csi.storage.k8s.io/controller-expand-secret-name"] = rbdProvisionerSecretName
|
|
|
|
param["csi.storage.k8s.io/node-stage-secret-namespace"] = cephCSINamespace
|
|
|
|
param["csi.storage.k8s.io/node-stage-secret-name"] = rbdNodePluginSecretName
|
|
|
|
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, param, deletePolicy)
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = validateImageOwner(pvcPath, f)
|
2020-11-26 10:44:22 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate owner of pvc: %v", err)
|
2020-11-26 10:44:22 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-11-26 10:44:22 +00:00
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// Create a PVC and bind it to an app within the namesapce
|
2020-11-26 10:44:22 +00:00
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
2020-09-03 09:34:29 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2020-09-03 09:34:29 +00:00
|
|
|
}
|
2021-01-02 19:15:56 +00:00
|
|
|
|
2020-06-02 19:19:57 +00:00
|
|
|
// Resize Block PVC and check Device size within the namespace
|
2021-11-03 09:58:19 +00:00
|
|
|
err = resizePVCAndValidateSize(rawPvcPath, rawAppPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to resize block PVC: %v", err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
|
2021-01-02 19:15:56 +00:00
|
|
|
// Resize Filesystem PVC and check application directory size
|
2021-11-03 09:59:04 +00:00
|
|
|
err = resizePVCAndValidateSize(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to resize filesystem PVC %v", err)
|
2021-01-02 19:15:56 +00:00
|
|
|
}
|
|
|
|
|
2020-06-02 19:19:57 +00:00
|
|
|
// Create a PVC clone and bind it to an app within the namespace
|
2021-11-03 09:55:08 +00:00
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-11-03 09:55:08 +00:00
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
2021-04-08 15:46:11 +00:00
|
|
|
if err != nil {
|
2021-11-03 09:59:04 +00:00
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
2021-04-08 15:46:11 +00:00
|
|
|
}
|
2021-11-03 09:59:04 +00:00
|
|
|
}()
|
2021-04-08 15:46:11 +00:00
|
|
|
|
2021-11-03 09:59:04 +00:00
|
|
|
pvc, pvcErr := loadPVC(pvcPath)
|
|
|
|
if pvcErr != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", pvcErr)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
2020-06-02 19:19:57 +00:00
|
|
|
|
2021-11-03 09:59:04 +00:00
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2020-09-03 09:34:29 +00:00
|
|
|
|
2021-11-03 09:59:04 +00:00
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create snapshot: %v", err)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
|
|
|
validateRBDImageCount(f, 2, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
2020-06-02 19:19:57 +00:00
|
|
|
|
2021-11-03 09:59:04 +00:00
|
|
|
err = validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete snapshot: %v", err)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
|
|
|
// as snapshot is deleted the image count should be one
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
|
2020-09-22 05:44:21 +00:00
|
|
|
|
2021-11-03 09:59:04 +00:00
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
2021-11-03 09:59:04 +00:00
|
|
|
}
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, snapsType)
|
2021-07-27 06:45:09 +00:00
|
|
|
|
2021-11-03 09:59:04 +00:00
|
|
|
err = waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", rbdOptions(defaultRBDPool), err)
|
2020-06-02 19:19:57 +00:00
|
|
|
}
|
|
|
|
|
2021-02-22 11:13:40 +00:00
|
|
|
// delete RBD provisioner secret
|
|
|
|
err = deleteCephUser(f, keyringRBDNamespaceProvisionerUsername)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete user %s: %v", keyringRBDNamespaceProvisionerUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), rbdNamespaceProvisionerSecretName, metav1.DeleteOptions{})
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete provisioner secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
// delete RBD plugin secret
|
|
|
|
err = deleteCephUser(f, keyringRBDNamespaceNodePluginUsername)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete user %s: %v", keyringRBDNamespaceNodePluginUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2021-06-25 12:38:30 +00:00
|
|
|
err = c.CoreV1().
|
|
|
|
Secrets(cephCSINamespace).
|
|
|
|
Delete(context.TODO(), rbdNamespaceNodePluginSecretName, metav1.DeleteOptions{})
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete node secret: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2021-02-22 11:13:40 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2020-06-02 19:19:57 +00:00
|
|
|
updateConfigMap("")
|
|
|
|
})
|
|
|
|
|
2020-05-19 07:46:39 +00:00
|
|
|
By("Mount pvc as readonly in pod", func() {
|
2020-09-03 09:34:29 +00:00
|
|
|
// create PVC and bind it to an app
|
2020-05-19 07:46:39 +00:00
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
app, err := loadApp(appPath)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to load application: %v", err)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.Namespace = f.UniqueName
|
|
|
|
label := map[string]string{
|
|
|
|
"app": app.Name,
|
|
|
|
}
|
|
|
|
app.Labels = label
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
|
|
|
|
app.Spec.Volumes[0].PersistentVolumeClaim.ReadOnly = true
|
|
|
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
2020-05-19 07:46:39 +00:00
|
|
|
|
|
|
|
opt := metav1.ListOptions{
|
|
|
|
LabelSelector: fmt.Sprintf("app=%s", app.Name),
|
|
|
|
}
|
|
|
|
|
|
|
|
filePath := app.Spec.Containers[0].VolumeMounts[0].MountPath + "/test"
|
2021-06-25 12:38:30 +00:00
|
|
|
_, stdErr := execCommandInPodAndAllowFail(
|
|
|
|
f,
|
|
|
|
fmt.Sprintf("echo 'Hello World' > %s", filePath),
|
|
|
|
app.Namespace,
|
|
|
|
&opt)
|
2020-05-19 07:46:39 +00:00
|
|
|
readOnlyErr := fmt.Sprintf("cannot create %s: Read-only file system", filePath)
|
|
|
|
if !strings.Contains(stdErr, readOnlyErr) {
|
2020-09-03 09:34:29 +00:00
|
|
|
e2elog.Failf(stdErr)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 09:34:29 +00:00
|
|
|
// delete PVC and app
|
2020-05-19 07:46:39 +00:00
|
|
|
err = deletePVCAndApp("", f, pvc, app)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC and application: %v", err)
|
2020-05-19 07:46:39 +00:00
|
|
|
}
|
2020-08-17 08:37:19 +00:00
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2020-05-19 07:46:39 +00:00
|
|
|
})
|
|
|
|
|
2020-09-08 05:23:28 +00:00
|
|
|
By("create a PVC and Bind it to an app for mapped rbd image with options", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-08 05:23:28 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, map[string]string{
|
2022-06-29 07:37:50 +00:00
|
|
|
"imageFeatures": "exclusive-lock",
|
|
|
|
"mapOptions": "lock_on_read,queue_depth=1024",
|
|
|
|
"unmapOptions": "force",
|
2021-07-13 13:09:31 +00:00
|
|
|
}, deletePolicy)
|
2020-09-08 05:23:28 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-08 05:23:28 +00:00
|
|
|
}
|
|
|
|
err = validatePVCAndAppBinding(pvcPath, appPath, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate pvc and application binding: %v", err)
|
2020-09-08 05:23:28 +00:00
|
|
|
}
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
2020-09-08 05:23:28 +00:00
|
|
|
}
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-09-08 05:23:28 +00:00
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
2020-09-08 05:23:28 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-10-28 07:43:52 +00:00
|
|
|
By("validate the functionality of controller", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
2021-07-16 13:16:36 +00:00
|
|
|
e2elog.Failf("failed to delete storageclass : %v", err)
|
|
|
|
}
|
|
|
|
scParams := map[string]string{
|
|
|
|
"volumeNamePrefix": "test-",
|
2020-10-28 07:43:52 +00:00
|
|
|
}
|
2021-07-16 13:16:36 +00:00
|
|
|
err = validateController(f,
|
|
|
|
pvcPath, appPath, rbdExamplePath+"storageclass.yaml",
|
|
|
|
nil,
|
|
|
|
scParams)
|
2020-10-28 07:43:52 +00:00
|
|
|
if err != nil {
|
2021-07-16 13:16:36 +00:00
|
|
|
e2elog.Failf("failed to validate controller : %v", err)
|
2020-10-28 07:43:52 +00:00
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
2021-03-19 09:09:28 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-03-22 05:48:22 +00:00
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
2020-10-28 07:43:52 +00:00
|
|
|
if err != nil {
|
2021-07-16 13:16:36 +00:00
|
|
|
e2elog.Failf("failed to create storageclass : %v", err)
|
2020-10-28 07:43:52 +00:00
|
|
|
}
|
|
|
|
})
|
2021-08-02 11:12:05 +00:00
|
|
|
|
2021-10-12 06:32:56 +00:00
|
|
|
By("validate image deletion when it is moved to trash", func() {
|
|
|
|
// make sure pool is empty
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-10-12 06:32:56 +00:00
|
|
|
|
|
|
|
err := createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load pvc: %v", err)
|
|
|
|
}
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create pvc: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcSmartClone, err := loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load pvcSmartClone: %v", err)
|
|
|
|
}
|
|
|
|
pvcSmartClone.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcSmartClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create pvc: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create snapshot: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
smartCloneImageData, err := getImageInfoFromPVC(pvcSmartClone.Namespace, pvcSmartClone.Name, f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to get ImageInfo from pvc: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
imageList, err := listRBDImages(f, defaultRBDPool)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to list rbd images: %v", err)
|
|
|
|
}
|
|
|
|
for _, imageName := range imageList {
|
|
|
|
if imageName == smartCloneImageData.imageName {
|
|
|
|
// do not move smartclone image to trash to test
|
|
|
|
// temporary image clone cleanup.
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
_, _, err = execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd snap purge %s %s", rbdOptions(defaultRBDPool), imageName), rookNamespace)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf(
|
|
|
|
"failed to snap purge %s %s: %v",
|
|
|
|
imageName,
|
|
|
|
rbdOptions(defaultRBDPool),
|
|
|
|
err)
|
|
|
|
}
|
|
|
|
_, _, err = execCommandInToolBoxPod(f,
|
|
|
|
fmt.Sprintf("rbd trash move %s %s", rbdOptions(defaultRBDPool), imageName), rookNamespace)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf(
|
|
|
|
"failed to move rbd image %s %s to trash: %v",
|
|
|
|
imageName,
|
|
|
|
rbdOptions(defaultRBDPool),
|
|
|
|
err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete snapshot: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvcSmartClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete pvc: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-10-12 06:32:56 +00:00
|
|
|
|
|
|
|
err = waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate rbd images in trash %s: %v", rbdOptions(defaultRBDPool), err)
|
|
|
|
}
|
|
|
|
})
|
2021-06-15 05:08:38 +00:00
|
|
|
|
|
|
|
By("validate stale images in trash", func() {
|
|
|
|
err := waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", defaultRBDPool, err)
|
2021-06-15 05:08:38 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-12-16 05:27:46 +00:00
|
|
|
By("restore snapshot to a bigger size PVC", func() {
|
|
|
|
By("restore snapshot to bigger size pvc", func() {
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
// validate filesystem mode PVC
|
|
|
|
err = validateBiggerPVCFromSnapshot(f,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
snapshotPath,
|
|
|
|
pvcClonePath,
|
|
|
|
appClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate restore bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
// validate block mode PVC
|
|
|
|
err = validateBiggerPVCFromSnapshot(f,
|
|
|
|
rawPvcPath,
|
|
|
|
rawAppPath,
|
|
|
|
snapshotPath,
|
|
|
|
pvcBlockRestorePath,
|
|
|
|
appBlockRestorePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate restore bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("restore snapshot to bigger size encrypted PVC with VaultKMS", func() {
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
|
|
|
err := createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
// validate filesystem mode PVC
|
|
|
|
err = validateBiggerPVCFromSnapshot(f,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
snapshotPath,
|
|
|
|
pvcClonePath,
|
|
|
|
appClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate restore bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
// validate block mode PVC
|
|
|
|
err = validateBiggerPVCFromSnapshot(f,
|
|
|
|
rawPvcPath,
|
|
|
|
rawAppPath,
|
|
|
|
snapshotPath,
|
|
|
|
pvcBlockRestorePath,
|
|
|
|
appBlockRestorePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate restore bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("validate image deletion", func() {
|
2021-12-16 06:34:45 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-12-16 06:34:45 +00:00
|
|
|
err := waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", defaultRBDPool, err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
By("clone PVC to a bigger size PVC", func() {
|
|
|
|
By("clone PVC to bigger size encrypted PVC with VaultKMS", func() {
|
|
|
|
scOpts := map[string]string{
|
|
|
|
"encrypted": "true",
|
|
|
|
"encryptionKMSID": "vault-test",
|
|
|
|
}
|
|
|
|
err := createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// validate filesystem mode PVC
|
|
|
|
err = validateBiggerCloneFromPVC(f,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
pvcSmartClonePath,
|
|
|
|
appSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
// validate block mode PVC
|
|
|
|
err = validateBiggerCloneFromPVC(f,
|
|
|
|
rawPvcPath,
|
|
|
|
rawAppPath,
|
|
|
|
pvcBlockSmartClonePath,
|
|
|
|
appBlockSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("clone PVC to bigger size pvc", func() {
|
|
|
|
err := createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
// validate filesystem mode PVC
|
|
|
|
err = validateBiggerCloneFromPVC(f,
|
|
|
|
pvcPath,
|
|
|
|
appPath,
|
|
|
|
pvcSmartClonePath,
|
|
|
|
appSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
// validate block mode PVC
|
|
|
|
err = validateBiggerCloneFromPVC(f,
|
|
|
|
rawPvcPath,
|
|
|
|
rawAppPath,
|
|
|
|
pvcBlockSmartClonePath,
|
|
|
|
appBlockSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate bigger size clone: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
By("validate image deletion", func() {
|
2021-12-16 05:27:46 +00:00
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
2022-04-25 11:49:04 +00:00
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
2021-12-16 05:27:46 +00:00
|
|
|
err := waitToRemoveImagesFromTrash(f, defaultRBDPool, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate rbd images in pool %s trash: %v", defaultRBDPool, err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-05-24 03:38:42 +00:00
|
|
|
By("validate rbd image stripe", func() {
|
|
|
|
stripeUnit := 4096
|
|
|
|
stripeCount := 8
|
|
|
|
objectSize := 131072
|
|
|
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = createRBDStorageClass(
|
|
|
|
f.ClientSet,
|
|
|
|
f,
|
|
|
|
defaultSCName,
|
|
|
|
nil,
|
|
|
|
map[string]string{
|
|
|
|
"stripeUnit": fmt.Sprintf("%d", stripeUnit),
|
|
|
|
"stripeCount": fmt.Sprintf("%d", stripeCount),
|
|
|
|
"objectSize": fmt.Sprintf("%d", objectSize),
|
|
|
|
},
|
|
|
|
deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete storageclass: %v", err)
|
|
|
|
}
|
|
|
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
err = createRBDSnapshotClass(f)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create storageclass: %v", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
err = deleteRBDSnapshotClass()
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// create PVC and bind it to an app
|
|
|
|
pvc, err := loadPVC(pvcPath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvc.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC and application: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 1, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
err = validateStripe(f, pvc, stripeUnit, stripeCount, objectSize)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate stripe: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
snap := getSnapshot(snapshotPath)
|
|
|
|
snap.Namespace = f.UniqueName
|
|
|
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
|
|
|
|
|
|
|
err = createSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create snapshot: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent PVC + snapshot
|
|
|
|
totalImages := 2
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
|
|
|
pvcClone, err := loadPVC(pvcClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load PVC: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// create clone PVC as ROX
|
|
|
|
pvcClone.Namespace = f.UniqueName
|
|
|
|
pvcClone.Spec.AccessModes = []v1.PersistentVolumeAccessMode{v1.ReadOnlyMany}
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent pvc + snapshot + clone
|
|
|
|
totalImages = 3
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType)
|
|
|
|
validateOmapCount(f, 1, rbdType, defaultRBDPool, snapsType)
|
|
|
|
err = validateStripe(f, pvcClone, stripeUnit, stripeCount, objectSize)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate stripe for clone: %v", err)
|
|
|
|
}
|
|
|
|
// delete snapshot
|
|
|
|
err = deleteSnapshot(&snap, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete snapshot: %v", err)
|
|
|
|
}
|
|
|
|
// delete clone pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvcClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
pvcSmartClone, err := loadPVC(pvcSmartClonePath)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to load pvcSmartClone: %v", err)
|
|
|
|
}
|
|
|
|
pvcSmartClone.Namespace = f.UniqueName
|
|
|
|
|
|
|
|
err = createPVCAndvalidatePV(f.ClientSet, pvcSmartClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to create pvc: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
// parent pvc + temp clone + clone
|
|
|
|
totalImages = 3
|
|
|
|
validateRBDImageCount(f, totalImages, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 2, rbdType, defaultRBDPool, volumesType)
|
|
|
|
err = validateStripe(f, pvcSmartClone, stripeUnit, stripeCount, objectSize)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to validate stripe for clone: %v", err)
|
|
|
|
}
|
|
|
|
// delete parent pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete clone pvc
|
|
|
|
err = deletePVCAndValidatePV(f.ClientSet, pvcSmartClone, deployTimeout)
|
|
|
|
if err != nil {
|
|
|
|
e2elog.Failf("failed to delete PVC: %v", err)
|
|
|
|
}
|
|
|
|
// validate created backend rbd images
|
|
|
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
|
|
|
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
|
|
|
|
})
|
|
|
|
|
2020-01-31 08:49:11 +00:00
|
|
|
// Make sure this should be last testcase in this file, because
|
|
|
|
// it deletes pool
|
2020-09-03 09:34:29 +00:00
|
|
|
By("Create a PVC and delete PVC when backend pool deleted", func() {
|
2020-01-31 08:49:11 +00:00
|
|
|
err := pvcDeleteWhenPoolNotFound(pvcPath, false, f)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete PVC when pool not found: %v", err)
|
2020-01-31 08:49:11 +00:00
|
|
|
}
|
|
|
|
})
|
2021-02-22 11:13:40 +00:00
|
|
|
// delete RBD provisioner secret
|
|
|
|
err := deleteCephUser(f, keyringRBDProvisionerUsername)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete user %s: %v", keyringRBDProvisionerUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
|
|
|
// delete RBD plugin secret
|
|
|
|
err = deleteCephUser(f, keyringRBDNodePluginUsername)
|
|
|
|
if err != nil {
|
2021-11-22 06:03:50 +00:00
|
|
|
e2elog.Failf("failed to delete user %s: %v", keyringRBDNodePluginUsername, err)
|
2021-02-22 11:13:40 +00:00
|
|
|
}
|
2019-05-31 09:34:04 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|