mirror of
https://github.com/kastenhq/kubestr.git
synced 2024-12-14 11:57:56 +00:00
Left over volume snapshot class (#45)
* Added image option to fio command * order change of delete * fix when deleting snapshots
This commit is contained in:
parent
72cca45db3
commit
461543547c
7 changed files with 193 additions and 56 deletions
|
@ -51,7 +51,7 @@ Name | CSI Driver Name | Compatible with CSI Version(s) | Description | Persiste
|
|||
[HPE](https://github.com/hpe-storage/csi-driver) | `csi.hpe.com` | v1.0, v1.1, v1.2 | A [multi-platform](https://scod.hpedev.io/csi_driver) Container Storage Interface (CSI) driver. Supports [HPE Nimble Storage](https://hpe.com/storage/nimble), [HPE Primera](https://hpe.com/storage/primera) and [HPE 3PAR](https://hpe.com/storage/3par) | Persistent and Ephemeral | Read/Write Multiple Pods | Yes | Raw Block, Snapshot, Expansion, Cloning
|
||||
[Huawei Storage CSI](https://github.com/Huawei/eSDK_K8S_Plugin) | `csi.huawei.com` | v1.0 | A Container Storage Interface (CSI) Driver for FusionStorage, OceanStor 100D, OceanStor Dorado V3, OceanStor Dorado V6, OceanStor V3, OceanStor V5 | Persistent | Read/Write Multiple Pod | Yes | Snapshot, Expansion, Cloning
|
||||
[HyperV CSI](https://github.com/Zetanova/hyperv-csi-driver) | `eu.zetanova.csi.hyperv` | v1.0, v1.1 | A Container Storage Interface (CSI) driver to manage hyperv hosts | Persistent | Read/Write Multiple Pods | Yes |
|
||||
[IBM Block Storage](https://github.com/ibm/ibm-block-csi-driver) | `block.csi.ibm.com` | v1.0, v1.1, v1.2 | A Container Storage Interface (CSI) [Driver](https://www.ibm.com/support/knowledgecenter/SSRQ8T) for IBM Spectrum Virtualize, IBM Storwize, IBM FlashSystem 9100, A9000 and A9000R, IBM DS8880 and DS8900. | Persistent | Read/Write Single Pod | Yes | Raw Block, Snapshot
|
||||
[IBM Block Storage](https://github.com/ibm/ibm-block-csi-driver) | `block.csi.ibm.com` | v1.0, v1.1, v1.2 | A Container Storage Interface (CSI) [Driver](https://www.ibm.com/support/knowledgecenter/SSRQ8T) for IBM Spectrum Virtualize Family, IBM FlashSystem A9000 and A9000R, IBM DS8880 and DS8900. | Persistent | Read/Write Single Pod | Yes | Raw Block, Snapshot, Expansion, Cloning
|
||||
[IBM Spectrum Scale](https://github.com/IBM/ibm-spectrum-scale-csi) | `spectrumscale.csi.ibm.com` | v1.0, v1.1 | A Container Storage Interface (CSI) [Driver](https://www.ibm.com/support/knowledgecenter/STXKQY_CSI_SHR) for the IBM Spectrum Scale File System | Persistent | Read/Write Multiple Pod | Yes |
|
||||
[IBM Cloud Block Storage VPC CSI Driver](https://cloud.ibm.com/docs/containers?topic=containers-vpc-block) | `vpc.block.csi.ibm.io` | v1.0 | A Container Storage Interface (CSI) [Driver](https://cloud.ibm.com/docs/containers?topic=containers-vpc-block) for IBM Cloud Kubernetes Service and Red Hat OpenShift on IBM Cloud | Persistent | Read/Write Single Pod | Yes | Raw Block |
|
||||
[Infinidat](https://github.com/Infinidat/infinibox-csi-driver) | `infinibox-csi-driver` | v1.0, v1.1 | A Container Storage Interface (CSI) Driver for Infinidat [InfiniBox](https://infinidat.com/en/products-technology/infinibox) | Persistent | Read/Write Multiple Pods | Yes | Raw Block, Snapshot, Expansion, Cloning
|
||||
|
@ -81,7 +81,7 @@ Name | CSI Driver Name | Compatible with CSI Version(s) | Description | Persiste
|
|||
[Quobyte](https://github.com/quobyte/quobyte-csi) | `quobyte-csi` | v0.2 | A Container Storage Interface (CSI) Driver for Quobyte | Persistent | Read/Write Multiple Pods | Yes |
|
||||
[ROBIN](https://get.robin.io/) | `robin` | v0.3, v1.0 | A Container Storage Interface (CSI) Driver for [ROBIN](https://docs.robin.io) | Persistent | Read/Write Multiple Pods | Yes | Raw Block, Snapshot, Cloning
|
||||
[SandStone](https://github.com/sandstone-storage/sandstone-csi-driver) | `csi-sandstone-plugin` | v1.0 | A Container Storage Interface (CSI) Driver for SandStone USP | Persistent | Read/Write Multiple Pods | Yes | Raw Block, Snapshot, Expansion, Cloning
|
||||
[Sangfor-EDS](https://github.com/evan37717/sangfor-eds-csi) | `eds.csi.sangfor.com` | v1.0 | A Container Storage Interface (CSI) Driver for Sangfor Distributed File Storage(EDS) | Persistent | Read/Write Multiple Pods | Yes |
|
||||
[Sangfor-EDS-File-Storage](https://github.com/evan37717/sangfor-eds-csi) | `eds.csi.file.sangfor.com` | v1.0 | A Container Storage Interface (CSI) Driver for Sangfor Distributed File Storage(EDS) | Persistent | Read/Write Multiple Pods | Yes |
|
||||
[Sangfor-EDS-Block-Storage](https://github.com/eds-wzc/sangfor-eds-csi) | `eds.csi.block.sangfor.com` | v1.0 | A Container Storage Interface (CSI) Driver for Sangfor Block Storage(EDS) | Persistent | Read/Write Single Pod | Yes |
|
||||
[SeaweedFS](https://github.com/seaweedfs/seaweedfs-csi-driver) | `seaweedfs-csi-driver` | v1.0 | A Container Storage Interface (CSI Driver for [SeaweedFS](https://github.com/chrislusf/seaweedfs)) | Persistent | Read/Write Multiple Pods | Yes |
|
||||
[Secrets Store CSI Driver](https://github.com/kubernetes-sigs/secrets-store-csi-driver) | `secrets-store.csi.k8s.io` | v0.0.10 | A Container Storage Interface (CSI) Driver for mounting secrets, keys, and certs stored in enterprise-grade external secrets stores as volumes. | Ephemeral | N/A | N/A |
|
||||
|
|
|
@ -7,6 +7,7 @@ package mocks
|
|||
import (
|
||||
context "context"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
|
@ -62,15 +63,15 @@ func (mr *MockCleanerMockRecorder) DeletePod(arg0, arg1, arg2 interface{}) *gomo
|
|||
}
|
||||
|
||||
// DeleteSnapshot mocks base method
|
||||
func (m *MockCleaner) DeleteSnapshot(arg0 context.Context, arg1, arg2 string) error {
|
||||
func (m *MockCleaner) DeleteSnapshot(arg0 context.Context, arg1, arg2 string, arg3 *v1.GroupVersionForDiscovery) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteSnapshot", arg0, arg1, arg2)
|
||||
ret := m.ctrl.Call(m, "DeleteSnapshot", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteSnapshot indicates an expected call of DeleteSnapshot
|
||||
func (mr *MockCleanerMockRecorder) DeleteSnapshot(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
func (mr *MockCleanerMockRecorder) DeleteSnapshot(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSnapshot", reflect.TypeOf((*MockCleaner)(nil).DeleteSnapshot), arg0, arg1, arg2)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSnapshot", reflect.TypeOf((*MockCleaner)(nil).DeleteSnapshot), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
snapshot "github.com/kanisterio/kanister/pkg/kube/snapshot"
|
||||
v1alpha1 "github.com/kanisterio/kanister/pkg/kube/snapshot/apis/v1alpha1"
|
||||
types "github.com/kastenhq/kubestr/pkg/csi/types"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
|
@ -37,17 +38,17 @@ func (m *MockSnapshotCreator) EXPECT() *MockSnapshotCreatorMockRecorder {
|
|||
}
|
||||
|
||||
// CreateFromSourceCheck mocks base method
|
||||
func (m *MockSnapshotCreator) CreateFromSourceCheck(arg0 context.Context, arg1 snapshot.Snapshotter, arg2 *types.CreateFromSourceCheckArgs) error {
|
||||
func (m *MockSnapshotCreator) CreateFromSourceCheck(arg0 context.Context, arg1 snapshot.Snapshotter, arg2 *types.CreateFromSourceCheckArgs, arg3 *v1.GroupVersionForDiscovery) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateFromSourceCheck", arg0, arg1, arg2)
|
||||
ret := m.ctrl.Call(m, "CreateFromSourceCheck", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// CreateFromSourceCheck indicates an expected call of CreateFromSourceCheck
|
||||
func (mr *MockSnapshotCreatorMockRecorder) CreateFromSourceCheck(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
func (mr *MockSnapshotCreatorMockRecorder) CreateFromSourceCheck(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateFromSourceCheck", reflect.TypeOf((*MockSnapshotCreator)(nil).CreateFromSourceCheck), arg0, arg1, arg2)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateFromSourceCheck", reflect.TypeOf((*MockSnapshotCreator)(nil).CreateFromSourceCheck), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// CreateSnapshot mocks base method
|
||||
|
|
|
@ -25,6 +25,8 @@ const (
|
|||
SnapGroupName = "snapshot.storage.k8s.io"
|
||||
// VolumeSnapshotClassResourcePlural describes volume snapshot classses
|
||||
VolumeSnapshotClassResourcePlural = "volumesnapshotclasses"
|
||||
// VolumeSnapshotResourcePlural is "volumesnapshots"
|
||||
VolumeSnapshotResourcePlural = "volumesnapshots"
|
||||
// VolSnapClassAlphaDriverKey describes alpha driver key
|
||||
VolSnapClassAlphaDriverKey = "snapshotter"
|
||||
// VolSnapClassBetaDriverKey describes beta driver key
|
||||
|
@ -135,12 +137,13 @@ type SnapshotRestoreStepper interface {
|
|||
}
|
||||
|
||||
type snapshotRestoreSteps struct {
|
||||
validateOps ArgumentValidator
|
||||
versionFetchOps ApiVersionFetcher
|
||||
createAppOps ApplicationCreator
|
||||
dataValidatorOps DataValidator
|
||||
snapshotCreateOps SnapshotCreator
|
||||
cleanerOps Cleaner
|
||||
validateOps ArgumentValidator
|
||||
versionFetchOps ApiVersionFetcher
|
||||
createAppOps ApplicationCreator
|
||||
dataValidatorOps DataValidator
|
||||
snapshotCreateOps SnapshotCreator
|
||||
cleanerOps Cleaner
|
||||
SnapshotGroupVersion *metav1.GroupVersionForDiscovery
|
||||
}
|
||||
|
||||
func (s *snapshotRestoreSteps) ValidateArgs(ctx context.Context, args *types.CSISnapshotRestoreArgs) error {
|
||||
|
@ -159,6 +162,7 @@ func (s *snapshotRestoreSteps) ValidateArgs(ctx context.Context, args *types.CSI
|
|||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to fetch groupVersion")
|
||||
}
|
||||
s.SnapshotGroupVersion = groupVersion
|
||||
|
||||
uVSC, err := s.validateOps.ValidateVolumeSnapshotClass(ctx, args.VolumeSnapshotClass, groupVersion)
|
||||
if err != nil {
|
||||
|
@ -232,7 +236,7 @@ func (s *snapshotRestoreSteps) SnapshotApplication(ctx context.Context, args *ty
|
|||
SnapshotName: snapshot.Name,
|
||||
Namespace: args.Namespace,
|
||||
}
|
||||
if err = s.snapshotCreateOps.CreateFromSourceCheck(ctx, snapshotter, cfsArgs); err != nil {
|
||||
if err = s.snapshotCreateOps.CreateFromSourceCheck(ctx, snapshotter, cfsArgs, s.SnapshotGroupVersion); err != nil {
|
||||
return snapshot, errors.Wrap(err, "Failed to create duplicate snapshot from source. To skip check use '--skipcfs=true' option.")
|
||||
}
|
||||
}
|
||||
|
@ -281,19 +285,34 @@ func (s *snapshotRestoreSteps) Cleanup(ctx context.Context, results *types.CSISn
|
|||
return
|
||||
}
|
||||
if results.OriginalPVC != nil {
|
||||
_ = s.cleanerOps.DeletePVC(ctx, results.OriginalPVC.Name, results.OriginalPVC.Namespace)
|
||||
err := s.cleanerOps.DeletePVC(ctx, results.OriginalPVC.Name, results.OriginalPVC.Namespace)
|
||||
if err != nil {
|
||||
fmt.Printf("Error deleteing PVC (%s) - (%v)\n", results.OriginalPVC.Name, err)
|
||||
}
|
||||
}
|
||||
if results.OriginalPod != nil {
|
||||
_ = s.cleanerOps.DeletePod(ctx, results.OriginalPod.Name, results.OriginalPod.Namespace)
|
||||
err := s.cleanerOps.DeletePod(ctx, results.OriginalPod.Name, results.OriginalPod.Namespace)
|
||||
if err != nil {
|
||||
fmt.Printf("Error deleteing Pod (%s) - (%v)\n", results.OriginalPod.Name, err)
|
||||
}
|
||||
}
|
||||
if results.ClonedPVC != nil {
|
||||
_ = s.cleanerOps.DeletePVC(ctx, results.ClonedPVC.Name, results.ClonedPVC.Namespace)
|
||||
err := s.cleanerOps.DeletePVC(ctx, results.ClonedPVC.Name, results.ClonedPVC.Namespace)
|
||||
if err != nil {
|
||||
fmt.Printf("Error deleteing PVC (%s) - (%v)\n", results.ClonedPVC.Name, err)
|
||||
}
|
||||
}
|
||||
if results.ClonedPod != nil {
|
||||
_ = s.cleanerOps.DeletePod(ctx, results.ClonedPod.Name, results.ClonedPod.Namespace)
|
||||
err := s.cleanerOps.DeletePod(ctx, results.ClonedPod.Name, results.ClonedPod.Namespace)
|
||||
if err != nil {
|
||||
fmt.Printf("Error deleteing Pod (%s) - (%v)\n", results.ClonedPod.Name, err)
|
||||
}
|
||||
}
|
||||
if results.Snapshot != nil {
|
||||
_ = s.cleanerOps.DeleteSnapshot(ctx, results.Snapshot.Name, results.Snapshot.Namespace)
|
||||
err := s.cleanerOps.DeleteSnapshot(ctx, results.Snapshot.Name, results.Snapshot.Namespace, s.SnapshotGroupVersion)
|
||||
if err != nil {
|
||||
fmt.Printf("Error deleteing Snapshot (%s) - (%v)\n", results.Snapshot.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +471,7 @@ func (c *applicationCreate) WaitForPodReady(ctx context.Context, namespace strin
|
|||
type SnapshotCreator interface {
|
||||
NewSnapshotter() (kansnapshot.Snapshotter, error)
|
||||
CreateSnapshot(ctx context.Context, snapshotter kansnapshot.Snapshotter, args *types.CreateSnapshotArgs) (*v1alpha1.VolumeSnapshot, error)
|
||||
CreateFromSourceCheck(ctx context.Context, snapshotter kansnapshot.Snapshotter, args *types.CreateFromSourceCheckArgs) error
|
||||
CreateFromSourceCheck(ctx context.Context, snapshotter kansnapshot.Snapshotter, args *types.CreateFromSourceCheckArgs, SnapshotGroupVersion *metav1.GroupVersionForDiscovery) error
|
||||
}
|
||||
|
||||
type snapshotCreate struct {
|
||||
|
@ -488,10 +507,13 @@ func (c *snapshotCreate) CreateSnapshot(ctx context.Context, snapshotter kansnap
|
|||
return snap, nil
|
||||
}
|
||||
|
||||
func (c *snapshotCreate) CreateFromSourceCheck(ctx context.Context, snapshotter kansnapshot.Snapshotter, args *types.CreateFromSourceCheckArgs) error {
|
||||
func (c *snapshotCreate) CreateFromSourceCheck(ctx context.Context, snapshotter kansnapshot.Snapshotter, args *types.CreateFromSourceCheckArgs, SnapshotGroupVersion *metav1.GroupVersionForDiscovery) error {
|
||||
if c.dynCli == nil {
|
||||
return fmt.Errorf("dynCli not initialized")
|
||||
}
|
||||
if SnapshotGroupVersion == nil || SnapshotGroupVersion.Version == "" {
|
||||
return fmt.Errorf("snapshot group version not provided")
|
||||
}
|
||||
if snapshotter == nil || args == nil {
|
||||
return fmt.Errorf("snapshotter or args are nil")
|
||||
}
|
||||
|
@ -499,13 +521,17 @@ func (c *snapshotCreate) CreateFromSourceCheck(ctx context.Context, snapshotter
|
|||
return err
|
||||
}
|
||||
targetSnapClassName := clonePrefix + args.VolumeSnapshotClass
|
||||
defer func() {
|
||||
_ = c.dynCli.Resource(v1alpha1.VolSnapClassGVR).Delete(ctx, targetSnapClassName, metav1.DeleteOptions{})
|
||||
}()
|
||||
err := snapshotter.CloneVolumeSnapshotClass(args.VolumeSnapshotClass, targetSnapClassName, kansnapshot.DeletionPolicyRetain, nil)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Failed to create a VolumeSnapshotClass to use to restore the snapshot")
|
||||
}
|
||||
defer func() {
|
||||
VolSnapClassGVR := schema.GroupVersionResource{Group: SnapGroupName, Version: SnapshotGroupVersion.Version, Resource: VolumeSnapshotClassResourcePlural}
|
||||
err := c.dynCli.Resource(VolSnapClassGVR).Delete(ctx, targetSnapClassName, metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
fmt.Printf("Delete VSC Error (%s) - (%v)\n", targetSnapClassName, err)
|
||||
}
|
||||
}()
|
||||
|
||||
snapSrc, err := snapshotter.GetSource(ctx, args.SnapshotName, args.Namespace)
|
||||
if err != nil {
|
||||
|
@ -532,7 +558,7 @@ func (c *snapshotCreate) CreateFromSourceCheck(ctx context.Context, snapshotter
|
|||
type Cleaner interface {
|
||||
DeletePVC(ctx context.Context, pvcName string, namespace string) error
|
||||
DeletePod(ctx context.Context, podName string, namespace string) error
|
||||
DeleteSnapshot(ctx context.Context, snapshotName string, namespace string) error
|
||||
DeleteSnapshot(ctx context.Context, snapshotName string, namespace string, SnapshotGroupVersion *metav1.GroupVersionForDiscovery) error
|
||||
}
|
||||
|
||||
type cleanse struct {
|
||||
|
@ -554,11 +580,15 @@ func (c *cleanse) DeletePod(ctx context.Context, podName string, namespace strin
|
|||
return c.kubeCli.CoreV1().Pods(namespace).Delete(ctx, podName, metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
func (c *cleanse) DeleteSnapshot(ctx context.Context, snapshotName string, namespace string) error {
|
||||
func (c *cleanse) DeleteSnapshot(ctx context.Context, snapshotName string, namespace string, SnapshotGroupVersion *metav1.GroupVersionForDiscovery) error {
|
||||
if c.dynCli == nil {
|
||||
return fmt.Errorf("dynCli not initialized")
|
||||
}
|
||||
return c.dynCli.Resource(v1alpha1.VolSnapGVR).Namespace(namespace).Delete(ctx, snapshotName, metav1.DeleteOptions{})
|
||||
if SnapshotGroupVersion == nil || SnapshotGroupVersion.Version == "" {
|
||||
return fmt.Errorf("snapshot group version not provided")
|
||||
}
|
||||
VolSnapGVR := schema.GroupVersionResource{Group: SnapGroupName, Version: SnapshotGroupVersion.Version, Resource: VolumeSnapshotResourcePlural}
|
||||
return c.dynCli.Resource(VolSnapGVR).Namespace(namespace).Delete(ctx, snapshotName, metav1.DeleteOptions{})
|
||||
}
|
||||
|
||||
//go:generate mockgen -destination=mocks/mock_api_version_fetcher.go -package=mocks . ApiVersionFetcher
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
kansnapshot "github.com/kanisterio/kanister/pkg/kube/snapshot"
|
||||
"github.com/kanisterio/kanister/pkg/kube/snapshot/apis/v1alpha1"
|
||||
"github.com/kanisterio/kanister/pkg/kube/snapshot/apis/v1beta1"
|
||||
"github.com/kastenhq/kubestr/pkg/csi/types"
|
||||
. "gopkg.in/check.v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
|
@ -618,11 +619,13 @@ func (s *CSITestSuite) TestCreateSnapshot(c *C) {
|
|||
|
||||
func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
||||
ctx := context.Background()
|
||||
gv := &metav1.GroupVersionForDiscovery{Version: v1alpha1.Version}
|
||||
for _, tc := range []struct {
|
||||
dyncli dynamic.Interface
|
||||
snapshotter kansnapshot.Snapshotter
|
||||
args *types.CreateFromSourceCheckArgs
|
||||
errChecker Checker
|
||||
dyncli dynamic.Interface
|
||||
snapshotter kansnapshot.Snapshotter
|
||||
args *types.CreateFromSourceCheckArgs
|
||||
groupVersion *metav1.GroupVersionForDiscovery
|
||||
errChecker Checker
|
||||
}{
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
|
@ -637,7 +640,8 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
SnapshotName: "snapshot",
|
||||
Namespace: "ns",
|
||||
},
|
||||
errChecker: IsNil,
|
||||
groupVersion: gv,
|
||||
errChecker: IsNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
|
@ -653,7 +657,8 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
SnapshotName: "snapshot",
|
||||
Namespace: "ns",
|
||||
},
|
||||
errChecker: NotNil,
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
|
@ -665,7 +670,8 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
SnapshotName: "snapshot",
|
||||
Namespace: "ns",
|
||||
},
|
||||
errChecker: NotNil,
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
|
@ -677,7 +683,8 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
SnapshotName: "snapshot",
|
||||
Namespace: "ns",
|
||||
},
|
||||
errChecker: NotNil,
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
|
@ -687,7 +694,8 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
SnapshotName: "snapshot",
|
||||
Namespace: "ns",
|
||||
},
|
||||
errChecker: NotNil,
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
|
@ -697,7 +705,8 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
SnapshotName: "",
|
||||
Namespace: "ns",
|
||||
},
|
||||
errChecker: NotNil,
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
|
@ -707,16 +716,24 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
SnapshotName: "snapshot",
|
||||
Namespace: "",
|
||||
},
|
||||
errChecker: NotNil,
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
snapshotter: &fakeSnapshotter{},
|
||||
errChecker: NotNil,
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
snapshotter: &fakeSnapshotter{},
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
errChecker: NotNil,
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
groupVersion: gv,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
groupVersion: nil,
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
dyncli: nil,
|
||||
|
@ -726,7 +743,7 @@ func (s *CSITestSuite) TestCreateFromSourceCheck(c *C) {
|
|||
snapCreator := &snapshotCreate{
|
||||
dynCli: tc.dyncli,
|
||||
}
|
||||
err := snapCreator.CreateFromSourceCheck(ctx, tc.snapshotter, tc.args)
|
||||
err := snapCreator.CreateFromSourceCheck(ctx, tc.snapshotter, tc.args, tc.groupVersion)
|
||||
c.Check(err, tc.errChecker)
|
||||
}
|
||||
}
|
||||
|
@ -887,13 +904,17 @@ func (s *CSITestSuite) TestDeleteSnapshot(c *C) {
|
|||
cli dynamic.Interface
|
||||
snapshotName string
|
||||
namespace string
|
||||
groupVersion *metav1.GroupVersionForDiscovery
|
||||
errChecker Checker
|
||||
}{
|
||||
{
|
||||
cli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
snapshotName: "snap1",
|
||||
namespace: "ns",
|
||||
errChecker: NotNil,
|
||||
groupVersion: &metav1.GroupVersionForDiscovery{
|
||||
Version: v1alpha1.Version,
|
||||
},
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
cli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme(),
|
||||
|
@ -910,6 +931,9 @@ func (s *CSITestSuite) TestDeleteSnapshot(c *C) {
|
|||
snapshotName: "pod",
|
||||
namespace: "ns",
|
||||
errChecker: NotNil,
|
||||
groupVersion: &metav1.GroupVersionForDiscovery{
|
||||
Version: v1alpha1.Version,
|
||||
},
|
||||
},
|
||||
{
|
||||
cli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme(),
|
||||
|
@ -926,6 +950,34 @@ func (s *CSITestSuite) TestDeleteSnapshot(c *C) {
|
|||
snapshotName: "snap1",
|
||||
namespace: "ns",
|
||||
errChecker: IsNil,
|
||||
groupVersion: &metav1.GroupVersionForDiscovery{
|
||||
Version: v1alpha1.Version,
|
||||
},
|
||||
},
|
||||
{
|
||||
cli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme(),
|
||||
&unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": fmt.Sprintf("%s/%s", v1beta1.GroupName, v1beta1.Version),
|
||||
"kind": "VolumeSnapshot",
|
||||
"metadata": map[string]interface{}{
|
||||
"name": "snap1",
|
||||
"namespace": "ns",
|
||||
},
|
||||
},
|
||||
}),
|
||||
snapshotName: "snap1",
|
||||
namespace: "ns",
|
||||
errChecker: NotNil,
|
||||
groupVersion: &metav1.GroupVersionForDiscovery{
|
||||
Version: v1alpha1.Version,
|
||||
},
|
||||
},
|
||||
{
|
||||
cli: fakedynamic.NewSimpleDynamicClient(runtime.NewScheme()),
|
||||
snapshotName: "pod",
|
||||
namespace: "ns",
|
||||
errChecker: NotNil,
|
||||
},
|
||||
{
|
||||
cli: nil,
|
||||
|
@ -937,7 +989,7 @@ func (s *CSITestSuite) TestDeleteSnapshot(c *C) {
|
|||
cleaner := &cleanse{
|
||||
dynCli: tc.cli,
|
||||
}
|
||||
err := cleaner.DeleteSnapshot(ctx, tc.snapshotName, tc.namespace)
|
||||
err := cleaner.DeleteSnapshot(ctx, tc.snapshotName, tc.namespace, tc.groupVersion)
|
||||
c.Check(err, tc.errChecker)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -345,6 +345,10 @@ func (s *CSITestSuite) TestCreateApplication(c *C) {
|
|||
func (s *CSITestSuite) TestSnapshotApplication(c *C) {
|
||||
ctx := context.Background()
|
||||
snapshotter := &fakeSnapshotter{name: "snapshotter"}
|
||||
groupversion := &metav1.GroupVersionForDiscovery{
|
||||
GroupVersion: "gv",
|
||||
Version: "v",
|
||||
}
|
||||
type fields struct {
|
||||
snapshotOps *mocks.MockSnapshotCreator
|
||||
}
|
||||
|
@ -384,7 +388,7 @@ func (s *CSITestSuite) TestSnapshotApplication(c *C) {
|
|||
VolumeSnapshotClass: "vsc",
|
||||
SnapshotName: "createdName",
|
||||
Namespace: "ns",
|
||||
}).Return(nil),
|
||||
}, groupversion).Return(nil),
|
||||
)
|
||||
},
|
||||
errChecker: IsNil,
|
||||
|
@ -448,7 +452,7 @@ func (s *CSITestSuite) TestSnapshotApplication(c *C) {
|
|||
VolumeSnapshotClass: "vsc",
|
||||
SnapshotName: "createdName",
|
||||
Namespace: "ns",
|
||||
}).Return(fmt.Errorf("cfs error")),
|
||||
}, groupversion).Return(fmt.Errorf("cfs error")),
|
||||
)
|
||||
},
|
||||
errChecker: NotNil,
|
||||
|
@ -508,7 +512,8 @@ func (s *CSITestSuite) TestSnapshotApplication(c *C) {
|
|||
tc.prepare(&f)
|
||||
}
|
||||
stepper := &snapshotRestoreSteps{
|
||||
snapshotCreateOps: f.snapshotOps,
|
||||
snapshotCreateOps: f.snapshotOps,
|
||||
SnapshotGroupVersion: groupversion,
|
||||
}
|
||||
snapshot, err := stepper.SnapshotApplication(ctx, tc.args, tc.pvc, tc.snapshotName)
|
||||
c.Check(err, tc.errChecker)
|
||||
|
@ -707,6 +712,10 @@ func (s *CSITestSuite) TestRestoreApplication(c *C) {
|
|||
|
||||
func (s *CSITestSuite) TestCleanup(c *C) {
|
||||
ctx := context.Background()
|
||||
groupversion := &metav1.GroupVersionForDiscovery{
|
||||
GroupVersion: "gv",
|
||||
Version: "v",
|
||||
}
|
||||
type fields struct {
|
||||
cleanerOps *mocks.MockCleaner
|
||||
}
|
||||
|
@ -756,7 +765,50 @@ func (s *CSITestSuite) TestCleanup(c *C) {
|
|||
f.cleanerOps.EXPECT().DeletePod(ctx, "pod1", "ns").Return(nil),
|
||||
f.cleanerOps.EXPECT().DeletePVC(ctx, "pvc2", "ns").Return(nil),
|
||||
f.cleanerOps.EXPECT().DeletePod(ctx, "pod2", "ns").Return(nil),
|
||||
f.cleanerOps.EXPECT().DeleteSnapshot(ctx, "snapshot", "ns").Return(nil),
|
||||
f.cleanerOps.EXPECT().DeleteSnapshot(ctx, "snapshot", "ns", groupversion).Return(nil),
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
results: &types.CSISnapshotRestoreResults{
|
||||
OriginalPVC: &v1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "pvc1",
|
||||
Namespace: "ns",
|
||||
},
|
||||
},
|
||||
OriginalPod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "pod1",
|
||||
Namespace: "ns",
|
||||
},
|
||||
},
|
||||
ClonedPVC: &v1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "pvc2",
|
||||
Namespace: "ns",
|
||||
},
|
||||
},
|
||||
ClonedPod: &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "pod2",
|
||||
Namespace: "ns",
|
||||
},
|
||||
},
|
||||
Snapshot: &v1alpha1.VolumeSnapshot{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "snapshot",
|
||||
Namespace: "ns",
|
||||
},
|
||||
},
|
||||
},
|
||||
prepare: func(f *fields) {
|
||||
gomock.InOrder(
|
||||
f.cleanerOps.EXPECT().DeletePVC(ctx, "pvc1", "ns").Return(fmt.Errorf("err")),
|
||||
f.cleanerOps.EXPECT().DeletePod(ctx, "pod1", "ns").Return(fmt.Errorf("err")),
|
||||
f.cleanerOps.EXPECT().DeletePVC(ctx, "pvc2", "ns").Return(fmt.Errorf("err")),
|
||||
f.cleanerOps.EXPECT().DeletePod(ctx, "pod2", "ns").Return(fmt.Errorf("err")),
|
||||
f.cleanerOps.EXPECT().DeleteSnapshot(ctx, "snapshot", "ns", groupversion).Return(fmt.Errorf("err")),
|
||||
)
|
||||
},
|
||||
},
|
||||
|
@ -770,7 +822,8 @@ func (s *CSITestSuite) TestCleanup(c *C) {
|
|||
tc.prepare(&f)
|
||||
}
|
||||
stepper := &snapshotRestoreSteps{
|
||||
cleanerOps: f.cleanerOps,
|
||||
cleanerOps: f.cleanerOps,
|
||||
SnapshotGroupVersion: groupversion,
|
||||
}
|
||||
stepper.Cleanup(ctx, tc.results)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ var CSIDriverList = []*CSIDriver{
|
|||
{NameUrl: "[HPE](https://github.com/hpe-storage/csi-driver)", DriverName: "csi.hpe.com", Versions: "v1.0, v1.1, v1.2", Description: "A [multi-platform](https://scod.hpedev.io/csi_driver) Container Storage Interface (CSI) driver. Supports [HPE Nimble Storage](https://hpe.com/storage/nimble), [HPE Primera](https://hpe.com/storage/primera) and [HPE 3PAR](https://hpe.com/storage/3par)", Persistence: "Persistent and Ephemeral", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: "Raw Block, Snapshot, Expansion, Cloning"},
|
||||
{NameUrl: "[Huawei Storage CSI](https://github.com/Huawei/eSDK_K8S_Plugin)", DriverName: "csi.huawei.com", Versions: "v1.0", Description: "A Container Storage Interface (CSI) Driver for FusionStorage, OceanStor 100D, OceanStor Dorado V3, OceanStor Dorado V6, OceanStor V3, OceanStor V5", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pod", DynamicProvisioning: "Yes", Features: "Snapshot, Expansion, Cloning"},
|
||||
{NameUrl: "[HyperV CSI](https://github.com/Zetanova/hyperv-csi-driver)", DriverName: "eu.zetanova.csi.hyperv", Versions: "v1.0, v1.1", Description: "A Container Storage Interface (CSI) driver to manage hyperv hosts", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: ""},
|
||||
{NameUrl: "[IBM Block Storage](https://github.com/ibm/ibm-block-csi-driver)", DriverName: "block.csi.ibm.com", Versions: "v1.0, v1.1, v1.2", Description: "A Container Storage Interface (CSI) [Driver](https://www.ibm.com/support/knowledgecenter/SSRQ8T) for IBM Spectrum Virtualize, IBM Storwize, IBM FlashSystem 9100, A9000 and A9000R, IBM DS8880 and DS8900.", Persistence: "Persistent", AccessModes: "Read/Write Single Pod", DynamicProvisioning: "Yes", Features: "Raw Block, Snapshot"},
|
||||
{NameUrl: "[IBM Block Storage](https://github.com/ibm/ibm-block-csi-driver)", DriverName: "block.csi.ibm.com", Versions: "v1.0, v1.1, v1.2", Description: "A Container Storage Interface (CSI) [Driver](https://www.ibm.com/support/knowledgecenter/SSRQ8T) for IBM Spectrum Virtualize Family, IBM FlashSystem A9000 and A9000R, IBM DS8880 and DS8900.", Persistence: "Persistent", AccessModes: "Read/Write Single Pod", DynamicProvisioning: "Yes", Features: "Raw Block, Snapshot, Expansion, Cloning"},
|
||||
{NameUrl: "[IBM Spectrum Scale](https://github.com/IBM/ibm-spectrum-scale-csi)", DriverName: "spectrumscale.csi.ibm.com", Versions: "v1.0, v1.1", Description: "A Container Storage Interface (CSI) [Driver](https://www.ibm.com/support/knowledgecenter/STXKQY_CSI_SHR) for the IBM Spectrum Scale File System", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pod", DynamicProvisioning: "Yes", Features: ""},
|
||||
{NameUrl: "[IBM Cloud Block Storage VPC CSI Driver](https://cloud.ibm.com/docs/containers?topic=containers-vpc-block)", DriverName: "vpc.block.csi.ibm.io", Versions: "v1.0", Description: "A Container Storage Interface (CSI) [Driver](https://cloud.ibm.com/docs/containers?topic=containers-vpc-block) for IBM Cloud Kubernetes Service and Red Hat OpenShift on IBM Cloud", Persistence: "Persistent", AccessModes: "Read/Write Single Pod", DynamicProvisioning: "Yes", Features: "Raw Block"},
|
||||
{NameUrl: "[Infinidat](https://github.com/Infinidat/infinibox-csi-driver)", DriverName: "infinibox-csi-driver", Versions: "v1.0, v1.1", Description: "A Container Storage Interface (CSI) Driver for Infinidat [InfiniBox](https://infinidat.com/en/products-technology/infinibox)", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: "Raw Block, Snapshot, Expansion, Cloning"},
|
||||
|
@ -77,7 +77,7 @@ var CSIDriverList = []*CSIDriver{
|
|||
{NameUrl: "[Quobyte](https://github.com/quobyte/quobyte-csi)", DriverName: "quobyte-csi", Versions: "v0.2", Description: "A Container Storage Interface (CSI) Driver for Quobyte", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: ""},
|
||||
{NameUrl: "[ROBIN](https://get.robin.io/)", DriverName: "robin", Versions: "v0.3, v1.0", Description: "A Container Storage Interface (CSI) Driver for [ROBIN](https://docs.robin.io)", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: "Raw Block, Snapshot, Cloning"},
|
||||
{NameUrl: "[SandStone](https://github.com/sandstone-storage/sandstone-csi-driver)", DriverName: "csi-sandstone-plugin", Versions: "v1.0", Description: "A Container Storage Interface (CSI) Driver for SandStone USP", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: "Raw Block, Snapshot, Expansion, Cloning"},
|
||||
{NameUrl: "[Sangfor-EDS](https://github.com/evan37717/sangfor-eds-csi)", DriverName: "eds.csi.sangfor.com", Versions: "v1.0", Description: "A Container Storage Interface (CSI) Driver for Sangfor Distributed File Storage(EDS)", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: ""},
|
||||
{NameUrl: "[Sangfor-EDS-File-Storage](https://github.com/evan37717/sangfor-eds-csi)", DriverName: "eds.csi.file.sangfor.com", Versions: "v1.0", Description: "A Container Storage Interface (CSI) Driver for Sangfor Distributed File Storage(EDS)", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: ""},
|
||||
{NameUrl: "[Sangfor-EDS-Block-Storage](https://github.com/eds-wzc/sangfor-eds-csi)", DriverName: "eds.csi.block.sangfor.com", Versions: "v1.0", Description: "A Container Storage Interface (CSI) Driver for Sangfor Block Storage(EDS)", Persistence: "Persistent", AccessModes: "Read/Write Single Pod", DynamicProvisioning: "Yes", Features: ""},
|
||||
{NameUrl: "[SeaweedFS](https://github.com/seaweedfs/seaweedfs-csi-driver)", DriverName: "seaweedfs-csi-driver", Versions: "v1.0", Description: "A Container Storage Interface (CSI Driver for [SeaweedFS](https://github.com/chrislusf/seaweedfs))", Persistence: "Persistent", AccessModes: "Read/Write Multiple Pods", DynamicProvisioning: "Yes", Features: ""},
|
||||
{NameUrl: "[Secrets Store CSI Driver](https://github.com/kubernetes-sigs/secrets-store-csi-driver)", DriverName: "secrets-store.csi.k8s.io", Versions: "v0.0.10", Description: "A Container Storage Interface (CSI) Driver for mounting secrets, keys, and certs stored in enterprise-grade external secrets stores as volumes.", Persistence: "Ephemeral", AccessModes: "N/A", DynamicProvisioning: "N/A", Features: ""},
|
||||
|
|
Loading…
Reference in a new issue