Merge pull request #1321 from skriss/rename-block-store

rename BlockStore to VolumeSnapshotter
pull/1325/head
Nolan Brubaker 2019-03-28 11:33:06 -04:00 committed by GitHub
commit 21f3169ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 592 additions and 590 deletions

View File

@ -0,0 +1 @@
rename BlockStore plugin to VolumeSnapshotter

View File

@ -15,7 +15,7 @@ A fully-functional [sample plugin repository][1] is provided to serve as a conve
Velero currently supports the following kinds of plugins: Velero currently supports the following kinds of plugins:
- **Object Store** - persists and retrieves backups, backup logs and restore logs - **Object Store** - persists and retrieves backups, backup logs and restore logs
- **Block Store** - creates volume snapshots (during backup) and restores volumes from snapshots (during restore) - **Volume Snapshotter** - creates volume snapshots (during backup) and restores volumes from snapshots (during restore)
- **Backup Item Action** - executes arbitrary logic for individual items prior to storing them in a backup file - **Backup Item Action** - executes arbitrary logic for individual items prior to storing them in a backup file
- **Restore Item Action** - executes arbitrary logic for individual items prior to restoring them into a cluster - **Restore Item Action** - executes arbitrary logic for individual items prior to restoring them into a cluster

View File

@ -49,7 +49,7 @@ const BackupVersion = 1
type Backupper interface { type Backupper interface {
// Backup takes a backup using the specification in the api.Backup and writes backup and log data // Backup takes a backup using the specification in the api.Backup and writes backup and log data
// to the given writers. // to the given writers.
Backup(logger logrus.FieldLogger, backup *Request, backupFile io.Writer, actions []velero.BackupItemAction, blockStoreGetter BlockStoreGetter) error Backup(logger logrus.FieldLogger, backup *Request, backupFile io.Writer, actions []velero.BackupItemAction, volumeSnapshotterGetter VolumeSnapshotterGetter) error
} }
// kubernetesBackupper implements Backupper. // kubernetesBackupper implements Backupper.
@ -209,13 +209,13 @@ func getResourceHook(hookSpec api.BackupResourceHookSpec, discoveryHelper discov
return h, nil return h, nil
} }
type BlockStoreGetter interface { type VolumeSnapshotterGetter interface {
GetBlockStore(name string) (velero.BlockStore, error) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error)
} }
// Backup backs up the items specified in the Backup, placing them in a gzip-compressed tar file // Backup backs up the items specified in the Backup, placing them in a gzip-compressed tar file
// written to backupFile. The finalized api.Backup is written to metadata. // written to backupFile. The finalized api.Backup is written to metadata.
func (kb *kubernetesBackupper) Backup(logger logrus.FieldLogger, backupRequest *Request, backupFile io.Writer, actions []velero.BackupItemAction, blockStoreGetter BlockStoreGetter) error { func (kb *kubernetesBackupper) Backup(logger logrus.FieldLogger, backupRequest *Request, backupFile io.Writer, actions []velero.BackupItemAction, volumeSnapshotterGetter VolumeSnapshotterGetter) error {
gzippedData := gzip.NewWriter(backupFile) gzippedData := gzip.NewWriter(backupFile)
defer gzippedData.Close() defer gzippedData.Close()
@ -280,7 +280,7 @@ func (kb *kubernetesBackupper) Backup(logger logrus.FieldLogger, backupRequest *
tw, tw,
resticBackupper, resticBackupper,
newPVCSnapshotTracker(), newPVCSnapshotTracker(),
blockStoreGetter, volumeSnapshotterGetter,
) )
var errs []error var errs []error

View File

@ -508,7 +508,7 @@ func TestBackup(t *testing.T) {
mock.Anything, // tarWriter mock.Anything, // tarWriter
mock.Anything, // restic backupper mock.Anything, // restic backupper
mock.Anything, // pvc snapshot tracker mock.Anything, // pvc snapshot tracker
mock.Anything, // block store getter mock.Anything, // volume snapshotter getter
).Return(groupBackupper) ).Return(groupBackupper)
for group, err := range test.backupGroupErrors { for group, err := range test.backupGroupErrors {
@ -613,7 +613,7 @@ func (f *mockGroupBackupperFactory) newGroupBackupper(
tarWriter tarWriter, tarWriter tarWriter,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) groupBackupper { ) groupBackupper {
args := f.Called( args := f.Called(
log, log,
@ -626,7 +626,7 @@ func (f *mockGroupBackupperFactory) newGroupBackupper(
tarWriter, tarWriter,
resticBackupper, resticBackupper,
resticSnapshotTracker, resticSnapshotTracker,
blockStoreGetter, volumeSnapshotterGetter,
) )
return args.Get(0).(groupBackupper) return args.Get(0).(groupBackupper)
} }

View File

@ -44,7 +44,7 @@ type groupBackupperFactory interface {
tarWriter tarWriter, tarWriter tarWriter,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) groupBackupper ) groupBackupper
} }
@ -61,7 +61,7 @@ func (f *defaultGroupBackupperFactory) newGroupBackupper(
tarWriter tarWriter, tarWriter tarWriter,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) groupBackupper { ) groupBackupper {
return &defaultGroupBackupper{ return &defaultGroupBackupper{
log: log, log: log,
@ -74,7 +74,7 @@ func (f *defaultGroupBackupperFactory) newGroupBackupper(
tarWriter: tarWriter, tarWriter: tarWriter,
resticBackupper: resticBackupper, resticBackupper: resticBackupper,
resticSnapshotTracker: resticSnapshotTracker, resticSnapshotTracker: resticSnapshotTracker,
blockStoreGetter: blockStoreGetter, volumeSnapshotterGetter: volumeSnapshotterGetter,
resourceBackupperFactory: &defaultResourceBackupperFactory{}, resourceBackupperFactory: &defaultResourceBackupperFactory{},
} }
@ -96,7 +96,7 @@ type defaultGroupBackupper struct {
resticBackupper restic.Backupper resticBackupper restic.Backupper
resticSnapshotTracker *pvcSnapshotTracker resticSnapshotTracker *pvcSnapshotTracker
resourceBackupperFactory resourceBackupperFactory resourceBackupperFactory resourceBackupperFactory
blockStoreGetter BlockStoreGetter volumeSnapshotterGetter VolumeSnapshotterGetter
} }
// backupGroup backs up a single API group. // backupGroup backs up a single API group.
@ -115,7 +115,7 @@ func (gb *defaultGroupBackupper) backupGroup(group *metav1.APIResourceList) erro
gb.tarWriter, gb.tarWriter,
gb.resticBackupper, gb.resticBackupper,
gb.resticSnapshotTracker, gb.resticSnapshotTracker,
gb.blockStoreGetter, gb.volumeSnapshotterGetter,
) )
) )

View File

@ -97,7 +97,7 @@ func (rbf *mockResourceBackupperFactory) newResourceBackupper(
tarWriter tarWriter, tarWriter tarWriter,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) resourceBackupper { ) resourceBackupper {
args := rbf.Called( args := rbf.Called(
log, log,
@ -110,7 +110,7 @@ func (rbf *mockResourceBackupperFactory) newResourceBackupper(
tarWriter, tarWriter,
resticBackupper, resticBackupper,
resticSnapshotTracker, resticSnapshotTracker,
blockStoreGetter, volumeSnapshotterGetter,
) )
return args.Get(0).(resourceBackupper) return args.Get(0).(resourceBackupper)
} }

View File

@ -52,7 +52,7 @@ type itemBackupperFactory interface {
discoveryHelper discovery.Helper, discoveryHelper discovery.Helper,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) ItemBackupper ) ItemBackupper
} }
@ -67,7 +67,7 @@ func (f *defaultItemBackupperFactory) newItemBackupper(
discoveryHelper discovery.Helper, discoveryHelper discovery.Helper,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) ItemBackupper { ) ItemBackupper {
ib := &defaultItemBackupper{ ib := &defaultItemBackupper{
backupRequest: backupRequest, backupRequest: backupRequest,
@ -77,7 +77,7 @@ func (f *defaultItemBackupperFactory) newItemBackupper(
discoveryHelper: discoveryHelper, discoveryHelper: discoveryHelper,
resticBackupper: resticBackupper, resticBackupper: resticBackupper,
resticSnapshotTracker: resticSnapshotTracker, resticSnapshotTracker: resticSnapshotTracker,
blockStoreGetter: blockStoreGetter, volumeSnapshotterGetter: volumeSnapshotterGetter,
itemHookHandler: &defaultItemHookHandler{ itemHookHandler: &defaultItemHookHandler{
podCommandExecutor: podCommandExecutor, podCommandExecutor: podCommandExecutor,
@ -102,11 +102,11 @@ type defaultItemBackupper struct {
discoveryHelper discovery.Helper discoveryHelper discovery.Helper
resticBackupper restic.Backupper resticBackupper restic.Backupper
resticSnapshotTracker *pvcSnapshotTracker resticSnapshotTracker *pvcSnapshotTracker
blockStoreGetter BlockStoreGetter volumeSnapshotterGetter VolumeSnapshotterGetter
itemHookHandler itemHookHandler itemHookHandler itemHookHandler
additionalItemBackupper ItemBackupper additionalItemBackupper ItemBackupper
snapshotLocationBlockStores map[string]velero.BlockStore snapshotLocationVolumeSnapshotters map[string]velero.VolumeSnapshotter
} }
// backupItem backs up an individual item to tarWriter. The item may be excluded based on the // backupItem backs up an individual item to tarWriter. The item may be excluded based on the
@ -343,14 +343,14 @@ func (ib *defaultItemBackupper) executeActions(
return obj, nil return obj, nil
} }
// blockStore instantiates and initializes a BlockStore given a VolumeSnapshotLocation, // volumeSnapshotter instantiates and initializes a VolumeSnapshotter given a VolumeSnapshotLocation,
// or returns an existing one if one's already been initialized for the location. // or returns an existing one if one's already been initialized for the location.
func (ib *defaultItemBackupper) blockStore(snapshotLocation *api.VolumeSnapshotLocation) (velero.BlockStore, error) { func (ib *defaultItemBackupper) volumeSnapshotter(snapshotLocation *api.VolumeSnapshotLocation) (velero.VolumeSnapshotter, error) {
if bs, ok := ib.snapshotLocationBlockStores[snapshotLocation.Name]; ok { if bs, ok := ib.snapshotLocationVolumeSnapshotters[snapshotLocation.Name]; ok {
return bs, nil return bs, nil
} }
bs, err := ib.blockStoreGetter.GetBlockStore(snapshotLocation.Spec.Provider) bs, err := ib.volumeSnapshotterGetter.GetVolumeSnapshotter(snapshotLocation.Spec.Provider)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -359,10 +359,10 @@ func (ib *defaultItemBackupper) blockStore(snapshotLocation *api.VolumeSnapshotL
return nil, err return nil, err
} }
if ib.snapshotLocationBlockStores == nil { if ib.snapshotLocationVolumeSnapshotters == nil {
ib.snapshotLocationBlockStores = make(map[string]velero.BlockStore) ib.snapshotLocationVolumeSnapshotters = make(map[string]velero.VolumeSnapshotter)
} }
ib.snapshotLocationBlockStores[snapshotLocation.Name] = bs ib.snapshotLocationVolumeSnapshotters[snapshotLocation.Name] = bs
return bs, nil return bs, nil
} }
@ -405,15 +405,15 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
var ( var (
volumeID, location string volumeID, location string
blockStore velero.BlockStore volumeSnapshotter velero.VolumeSnapshotter
) )
for _, snapshotLocation := range ib.backupRequest.SnapshotLocations { for _, snapshotLocation := range ib.backupRequest.SnapshotLocations {
log := log.WithField("volumeSnapshotLocation", snapshotLocation.Name) log := log.WithField("volumeSnapshotLocation", snapshotLocation.Name)
bs, err := ib.blockStore(snapshotLocation) bs, err := ib.volumeSnapshotter(snapshotLocation)
if err != nil { if err != nil {
log.WithError(err).Error("Error getting block store for volume snapshot location") log.WithError(err).Error("Error getting volume snapshotter for volume snapshot location")
continue continue
} }
@ -422,17 +422,17 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
continue continue
} }
if volumeID == "" { if volumeID == "" {
log.Infof("No volume ID returned by block store for persistent volume") log.Infof("No volume ID returned by volume snapshotter for persistent volume")
continue continue
} }
log.Infof("Got volume ID for persistent volume") log.Infof("Got volume ID for persistent volume")
blockStore = bs volumeSnapshotter = bs
location = snapshotLocation.Name location = snapshotLocation.Name
break break
} }
if blockStore == nil { if volumeSnapshotter == nil {
log.Info("PersistentVolume is not a supported volume type for snapshots, skipping.") log.Info("PersistentVolume is not a supported volume type for snapshots, skipping.")
return nil return nil
} }
@ -445,7 +445,7 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
} }
log.Info("Getting volume information") log.Info("Getting volume information")
volumeType, iops, err := blockStore.GetVolumeInfo(volumeID, pvFailureDomainZone) volumeType, iops, err := volumeSnapshotter.GetVolumeInfo(volumeID, pvFailureDomainZone)
if err != nil { if err != nil {
log.WithError(err).Error("error getting volume info") log.WithError(err).Error("error getting volume info")
return errors.WithMessage(err, "error getting volume info") return errors.WithMessage(err, "error getting volume info")
@ -455,7 +455,7 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
snapshot := volumeSnapshot(ib.backupRequest.Backup, pv.Name, volumeID, volumeType, pvFailureDomainZone, location, iops) snapshot := volumeSnapshot(ib.backupRequest.Backup, pv.Name, volumeID, volumeType, pvFailureDomainZone, location, iops)
var errs []error var errs []error
snapshotID, err := blockStore.CreateSnapshot(snapshot.Spec.ProviderVolumeID, snapshot.Spec.VolumeAZ, tags) snapshotID, err := volumeSnapshotter.CreateSnapshot(snapshot.Spec.ProviderVolumeID, snapshot.Spec.VolumeAZ, tags)
if err != nil { if err != nil {
log.WithError(err).Error("error creating snapshot") log.WithError(err).Error("error creating snapshot")
errs = append(errs, errors.Wrap(err, "error taking snapshot of volume")) errs = append(errs, errors.Wrap(err, "error taking snapshot of volume"))

View File

@ -284,7 +284,7 @@ func TestBackupItemNoSkips(t *testing.T) {
additionalItemError: errors.New("foo"), additionalItemError: errors.New("foo"),
}, },
{ {
name: "takePVSnapshot is not invoked for PVs when blockStore == nil", name: "takePVSnapshot is not invoked for PVs when volumeSnapshotter == nil",
namespaceIncludesExcludes: collections.NewIncludesExcludes().Includes("*"), namespaceIncludesExcludes: collections.NewIncludesExcludes().Includes("*"),
item: `{"apiVersion": "v1", "kind": "PersistentVolume", "metadata": {"name": "mypv", "labels": {"failure-domain.beta.kubernetes.io/zone": "us-east-1c"}}, "spec": {"awsElasticBlockStore": {"volumeID": "aws://us-east-1c/vol-abc123"}}}`, item: `{"apiVersion": "v1", "kind": "PersistentVolume", "metadata": {"name": "mypv", "labels": {"failure-domain.beta.kubernetes.io/zone": "us-east-1c"}}, "spec": {"awsElasticBlockStore": {"volumeID": "aws://us-east-1c/vol-abc123"}}}`,
expectError: false, expectError: false,
@ -293,7 +293,7 @@ func TestBackupItemNoSkips(t *testing.T) {
groupResource: "persistentvolumes", groupResource: "persistentvolumes",
}, },
{ {
name: "takePVSnapshot is invoked for PVs when blockStore != nil", name: "takePVSnapshot is invoked for PVs when volumeSnapshotter != nil",
namespaceIncludesExcludes: collections.NewIncludesExcludes().Includes("*"), namespaceIncludesExcludes: collections.NewIncludesExcludes().Includes("*"),
item: `{"apiVersion": "v1", "kind": "PersistentVolume", "metadata": {"name": "mypv", "labels": {"failure-domain.beta.kubernetes.io/zone": "us-east-1c"}}, "spec": {"awsElasticBlockStore": {"volumeID": "aws://us-east-1c/vol-abc123"}}}`, item: `{"apiVersion": "v1", "kind": "PersistentVolume", "metadata": {"name": "mypv", "labels": {"failure-domain.beta.kubernetes.io/zone": "us-east-1c"}}, "spec": {"awsElasticBlockStore": {"volumeID": "aws://us-east-1c/vol-abc123"}}}`,
expectError: false, expectError: false,
@ -312,7 +312,7 @@ func TestBackupItemNoSkips(t *testing.T) {
expectExcluded: false, expectExcluded: false,
expectedTarHeaderName: "resources/persistentvolumes/cluster/mypv.json", expectedTarHeaderName: "resources/persistentvolumes/cluster/mypv.json",
groupResource: "persistentvolumes", groupResource: "persistentvolumes",
// empty snapshottableVolumes causes a blockStore to be created, but no // empty snapshottableVolumes causes a volumeSnapshotter to be created, but no
// snapshots are expected to be taken. // snapshots are expected to be taken.
snapshottableVolumes: map[string]v1.VolumeBackupInfo{}, snapshottableVolumes: map[string]v1.VolumeBackupInfo{},
trackedPVCs: sets.NewString(key("pvc-ns", "pvc"), key("another-pvc-ns", "another-pvc")), trackedPVCs: sets.NewString(key("pvc-ns", "pvc"), key("another-pvc-ns", "another-pvc")),
@ -413,7 +413,7 @@ func TestBackupItemNoSkips(t *testing.T) {
discoveryHelper := velerotest.NewFakeDiscoveryHelper(true, nil) discoveryHelper := velerotest.NewFakeDiscoveryHelper(true, nil)
blockStoreGetter := &blockStoreGetter{} volumeSnapshotterGetter := &volumeSnapshotterGetter{}
b := (&defaultItemBackupperFactory{}).newItemBackupper( b := (&defaultItemBackupperFactory{}).newItemBackupper(
backup, backup,
@ -424,18 +424,18 @@ func TestBackupItemNoSkips(t *testing.T) {
discoveryHelper, discoveryHelper,
nil, // restic backupper nil, // restic backupper
newPVCSnapshotTracker(), newPVCSnapshotTracker(),
blockStoreGetter, volumeSnapshotterGetter,
).(*defaultItemBackupper) ).(*defaultItemBackupper)
var blockStore *velerotest.FakeBlockStore var volumeSnapshotter *velerotest.FakeVolumeSnapshotter
if test.snapshottableVolumes != nil { if test.snapshottableVolumes != nil {
blockStore = &velerotest.FakeBlockStore{ volumeSnapshotter = &velerotest.FakeVolumeSnapshotter{
SnapshottableVolumes: test.snapshottableVolumes, SnapshottableVolumes: test.snapshottableVolumes,
VolumeID: "vol-abc123", VolumeID: "vol-abc123",
Error: test.snapshotError, Error: test.snapshotError,
} }
blockStoreGetter.blockStore = blockStore volumeSnapshotterGetter.volumeSnapshotter = volumeSnapshotter
} }
if test.trackedPVCs != nil { if test.trackedPVCs != nil {
@ -523,7 +523,7 @@ func TestBackupItemNoSkips(t *testing.T) {
} }
if test.snapshottableVolumes != nil { if test.snapshottableVolumes != nil {
require.Equal(t, len(test.snapshottableVolumes), len(blockStore.SnapshotsTaken)) require.Equal(t, len(test.snapshottableVolumes), len(volumeSnapshotter.SnapshotsTaken))
} }
if len(test.snapshottableVolumes) > 0 { if len(test.snapshottableVolumes) > 0 {
@ -547,13 +547,13 @@ func TestBackupItemNoSkips(t *testing.T) {
} }
} }
type blockStoreGetter struct { type volumeSnapshotterGetter struct {
blockStore velero.BlockStore volumeSnapshotter velero.VolumeSnapshotter
} }
func (b *blockStoreGetter) GetBlockStore(name string) (velero.BlockStore, error) { func (b *volumeSnapshotterGetter) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error) {
if b.blockStore != nil { if b.volumeSnapshotter != nil {
return b.blockStore, nil return b.volumeSnapshotter, nil
} }
return nil, errors.New("plugin not found") return nil, errors.New("plugin not found")
} }
@ -787,7 +787,7 @@ func TestTakePVSnapshot(t *testing.T) {
}, },
} }
blockStore := &velerotest.FakeBlockStore{ volumeSnapshotter := &velerotest.FakeVolumeSnapshotter{
SnapshottableVolumes: test.volumeInfo, SnapshottableVolumes: test.volumeInfo,
VolumeID: test.expectedVolumeID, VolumeID: test.expectedVolumeID,
} }
@ -797,7 +797,7 @@ func TestTakePVSnapshot(t *testing.T) {
Backup: backup, Backup: backup,
SnapshotLocations: []*v1.VolumeSnapshotLocation{new(v1.VolumeSnapshotLocation)}, SnapshotLocations: []*v1.VolumeSnapshotLocation{new(v1.VolumeSnapshotLocation)},
}, },
blockStoreGetter: &blockStoreGetter{blockStore: blockStore}, volumeSnapshotterGetter: &volumeSnapshotterGetter{volumeSnapshotter: volumeSnapshotter},
} }
pv, err := velerotest.GetAsMap(test.pv) pv, err := velerotest.GetAsMap(test.pv)
@ -823,13 +823,13 @@ func TestTakePVSnapshot(t *testing.T) {
} }
// we should have exactly one snapshot taken // we should have exactly one snapshot taken
require.Equal(t, test.expectedSnapshotsTaken, blockStore.SnapshotsTaken.Len()) require.Equal(t, test.expectedSnapshotsTaken, volumeSnapshotter.SnapshotsTaken.Len())
if test.expectedSnapshotsTaken > 0 { if test.expectedSnapshotsTaken > 0 {
require.Len(t, ib.backupRequest.VolumeSnapshots, 1) require.Len(t, ib.backupRequest.VolumeSnapshots, 1)
snapshot := ib.backupRequest.VolumeSnapshots[0] snapshot := ib.backupRequest.VolumeSnapshots[0]
snapshotID, _ := blockStore.SnapshotsTaken.PopAny() snapshotID, _ := volumeSnapshotter.SnapshotsTaken.PopAny()
assert.Equal(t, snapshotID, snapshot.Status.ProviderSnapshotID) assert.Equal(t, snapshotID, snapshot.Status.ProviderSnapshotID)
assert.Equal(t, test.volumeInfo[test.expectedVolumeID].Type, snapshot.Spec.VolumeType) assert.Equal(t, test.volumeInfo[test.expectedVolumeID].Type, snapshot.Spec.VolumeType)
assert.Equal(t, test.volumeInfo[test.expectedVolumeID].Iops, snapshot.Spec.VolumeIOPS) assert.Equal(t, test.volumeInfo[test.expectedVolumeID].Iops, snapshot.Spec.VolumeIOPS)

View File

@ -46,7 +46,7 @@ type resourceBackupperFactory interface {
tarWriter tarWriter, tarWriter tarWriter,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) resourceBackupper ) resourceBackupper
} }
@ -63,7 +63,7 @@ func (f *defaultResourceBackupperFactory) newResourceBackupper(
tarWriter tarWriter, tarWriter tarWriter,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) resourceBackupper { ) resourceBackupper {
return &defaultResourceBackupper{ return &defaultResourceBackupper{
log: log, log: log,
@ -76,7 +76,7 @@ func (f *defaultResourceBackupperFactory) newResourceBackupper(
tarWriter: tarWriter, tarWriter: tarWriter,
resticBackupper: resticBackupper, resticBackupper: resticBackupper,
resticSnapshotTracker: resticSnapshotTracker, resticSnapshotTracker: resticSnapshotTracker,
blockStoreGetter: blockStoreGetter, volumeSnapshotterGetter: volumeSnapshotterGetter,
itemBackupperFactory: &defaultItemBackupperFactory{}, itemBackupperFactory: &defaultItemBackupperFactory{},
} }
@ -98,7 +98,7 @@ type defaultResourceBackupper struct {
resticBackupper restic.Backupper resticBackupper restic.Backupper
resticSnapshotTracker *pvcSnapshotTracker resticSnapshotTracker *pvcSnapshotTracker
itemBackupperFactory itemBackupperFactory itemBackupperFactory itemBackupperFactory
blockStoreGetter BlockStoreGetter volumeSnapshotterGetter VolumeSnapshotterGetter
} }
// backupResource backs up all the objects for a given group-version-resource. // backupResource backs up all the objects for a given group-version-resource.
@ -169,7 +169,7 @@ func (rb *defaultResourceBackupper) backupResource(
rb.discoveryHelper, rb.discoveryHelper,
rb.resticBackupper, rb.resticBackupper,
rb.resticSnapshotTracker, rb.resticSnapshotTracker,
rb.blockStoreGetter, rb.volumeSnapshotterGetter,
) )
namespacesToList := getNamespacesToList(rb.backupRequest.NamespaceIncludesExcludes) namespacesToList := getNamespacesToList(rb.backupRequest.NamespaceIncludesExcludes)

View File

@ -648,7 +648,7 @@ func (ibf *mockItemBackupperFactory) newItemBackupper(
discoveryHelper discovery.Helper, discoveryHelper discovery.Helper,
resticBackupper restic.Backupper, resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker, resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) ItemBackupper { ) ItemBackupper {
args := ibf.Called( args := ibf.Called(
backup, backup,
@ -659,7 +659,7 @@ func (ibf *mockItemBackupperFactory) newItemBackupper(
discoveryHelper, discoveryHelper,
resticBackupper, resticBackupper,
resticSnapshotTracker, resticSnapshotTracker,
blockStoreGetter, volumeSnapshotterGetter,
) )
return args.Get(0).(ItemBackupper) return args.Get(0).(ItemBackupper)
} }

View File

@ -41,7 +41,7 @@ const regionKey = "region"
// from snapshot. // from snapshot.
var iopsVolumeTypes = sets.NewString("io1") var iopsVolumeTypes = sets.NewString("io1")
type BlockStore struct { type VolumeSnapshotter struct {
log logrus.FieldLogger log logrus.FieldLogger
ec2 *ec2.EC2 ec2 *ec2.EC2
} }
@ -59,11 +59,11 @@ func getSession(config *aws.Config) (*session.Session, error) {
return sess, nil return sess, nil
} }
func NewBlockStore(logger logrus.FieldLogger) *BlockStore { func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
return &BlockStore{log: logger} return &VolumeSnapshotter{log: logger}
} }
func (b *BlockStore) Init(config map[string]string) error { func (b *VolumeSnapshotter) Init(config map[string]string) error {
region := config[regionKey] region := config[regionKey]
if region == "" { if region == "" {
return errors.Errorf("missing %s in aws configuration", regionKey) return errors.Errorf("missing %s in aws configuration", regionKey)
@ -81,7 +81,7 @@ func (b *BlockStore) Init(config map[string]string) error {
return nil return nil
} }
func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) { func (b *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) {
// describe the snapshot so we can apply its tags to the volume // describe the snapshot so we can apply its tags to the volume
snapReq := &ec2.DescribeSnapshotsInput{ snapReq := &ec2.DescribeSnapshotsInput{
SnapshotIds: []*string{&snapshotID}, SnapshotIds: []*string{&snapshotID},
@ -123,7 +123,7 @@ func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ s
return *res.VolumeId, nil return *res.VolumeId, nil
} }
func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) { func (b *VolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
volumeInfo, err := b.describeVolume(volumeID) volumeInfo, err := b.describeVolume(volumeID)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
@ -145,7 +145,7 @@ func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, e
return volumeType, iops, nil return volumeType, iops, nil
} }
func (b *BlockStore) describeVolume(volumeID string) (*ec2.Volume, error) { func (b *VolumeSnapshotter) describeVolume(volumeID string) (*ec2.Volume, error) {
req := &ec2.DescribeVolumesInput{ req := &ec2.DescribeVolumesInput{
VolumeIds: []*string{&volumeID}, VolumeIds: []*string{&volumeID},
} }
@ -161,7 +161,7 @@ func (b *BlockStore) describeVolume(volumeID string) (*ec2.Volume, error) {
return res.Volumes[0], nil return res.Volumes[0], nil
} }
func (b *BlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) { func (b *VolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
// describe the volume so we can copy its tags to the snapshot // describe the volume so we can copy its tags to the snapshot
volumeInfo, err := b.describeVolume(volumeID) volumeInfo, err := b.describeVolume(volumeID)
if err != nil { if err != nil {
@ -233,7 +233,7 @@ func ec2Tag(key, val string) *ec2.Tag {
return &ec2.Tag{Key: &key, Value: &val} return &ec2.Tag{Key: &key, Value: &val}
} }
func (b *BlockStore) DeleteSnapshot(snapshotID string) error { func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
req := &ec2.DeleteSnapshotInput{ req := &ec2.DeleteSnapshotInput{
SnapshotId: &snapshotID, SnapshotId: &snapshotID,
} }
@ -255,7 +255,7 @@ func (b *BlockStore) DeleteSnapshot(snapshotID string) error {
var ebsVolumeIDRegex = regexp.MustCompile("vol-.*") var ebsVolumeIDRegex = regexp.MustCompile("vol-.*")
func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) { func (b *VolumeSnapshotter) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) {
pv := new(v1.PersistentVolume) pv := new(v1.PersistentVolume)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil { if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return "", errors.WithStack(err) return "", errors.WithStack(err)
@ -272,7 +272,7 @@ func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, e
return ebsVolumeIDRegex.FindString(pv.Spec.AWSElasticBlockStore.VolumeID), nil return ebsVolumeIDRegex.FindString(pv.Spec.AWSElasticBlockStore.VolumeID), nil
} }
func (b *BlockStore) SetVolumeID(unstructuredPV runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (b *VolumeSnapshotter) SetVolumeID(unstructuredPV runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
pv := new(v1.PersistentVolume) pv := new(v1.PersistentVolume)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil { if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)

View File

@ -30,7 +30,7 @@ import (
) )
func TestGetVolumeID(t *testing.T) { func TestGetVolumeID(t *testing.T) {
b := &BlockStore{} b := &VolumeSnapshotter{}
pv := &unstructured.Unstructured{ pv := &unstructured.Unstructured{
Object: map[string]interface{}{}, Object: map[string]interface{}{},
@ -70,7 +70,7 @@ func TestGetVolumeID(t *testing.T) {
} }
func TestSetVolumeID(t *testing.T) { func TestSetVolumeID(t *testing.T) {
b := &BlockStore{} b := &VolumeSnapshotter{}
pv := &unstructured.Unstructured{ pv := &unstructured.Unstructured{
Object: map[string]interface{}{}, Object: map[string]interface{}{},
@ -105,7 +105,7 @@ func TestSetVolumeID(t *testing.T) {
} }
func TestSetVolumeIDNoZone(t *testing.T) { func TestSetVolumeIDNoZone(t *testing.T) {
b := &BlockStore{} b := &VolumeSnapshotter{}
pv := &unstructured.Unstructured{ pv := &unstructured.Unstructured{
Object: map[string]interface{}{}, Object: map[string]interface{}{},

View File

@ -45,7 +45,7 @@ const (
disksResource = "disks" disksResource = "disks"
) )
type BlockStore struct { type VolumeSnapshotter struct {
log logrus.FieldLogger log logrus.FieldLogger
disks *disk.DisksClient disks *disk.DisksClient
snaps *disk.SnapshotsClient snaps *disk.SnapshotsClient
@ -65,11 +65,11 @@ func (si *snapshotIdentifier) String() string {
return getComputeResourceName(si.subscription, si.resourceGroup, snapshotsResource, si.name) return getComputeResourceName(si.subscription, si.resourceGroup, snapshotsResource, si.name)
} }
func NewBlockStore(logger logrus.FieldLogger) *BlockStore { func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
return &BlockStore{log: logger} return &VolumeSnapshotter{log: logger}
} }
func (b *BlockStore) Init(config map[string]string) error { func (b *VolumeSnapshotter) Init(config map[string]string) error {
// 1. we need AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP // 1. we need AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP
envVars, err := getRequiredValues(os.Getenv, tenantIDEnvVar, clientIDEnvVar, clientSecretEnvVar, subscriptionIDEnvVar, resourceGroupEnvVar) envVars, err := getRequiredValues(os.Getenv, tenantIDEnvVar, clientIDEnvVar, clientSecretEnvVar, subscriptionIDEnvVar, resourceGroupEnvVar)
if err != nil { if err != nil {
@ -122,7 +122,7 @@ func (b *BlockStore) Init(config map[string]string) error {
return nil return nil
} }
func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error) { func (b *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error) {
snapshotIdentifier, err := b.parseSnapshotName(snapshotID) snapshotIdentifier, err := b.parseSnapshotName(snapshotID)
if err != nil { if err != nil {
return "", err return "", err
@ -168,7 +168,7 @@ func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ s
return diskName, nil return diskName, nil
} }
func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) { func (b *VolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
res, err := b.disks.Get(context.TODO(), b.disksResourceGroup, volumeID) res, err := b.disks.Get(context.TODO(), b.disksResourceGroup, volumeID)
if err != nil { if err != nil {
return "", nil, errors.WithStack(err) return "", nil, errors.WithStack(err)
@ -181,7 +181,7 @@ func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, e
return string(res.Sku.Name), nil, nil return string(res.Sku.Name), nil, nil
} }
func (b *BlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) { func (b *VolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
// Lookup disk info for its Location // Lookup disk info for its Location
diskInfo, err := b.disks.Get(context.TODO(), b.disksResourceGroup, volumeID) diskInfo, err := b.disks.Get(context.TODO(), b.disksResourceGroup, volumeID)
if err != nil { if err != nil {
@ -259,7 +259,7 @@ func stringPtr(s string) *string {
return &s return &s
} }
func (b *BlockStore) DeleteSnapshot(snapshotID string) error { func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
snapshotInfo, err := b.parseSnapshotName(snapshotID) snapshotInfo, err := b.parseSnapshotName(snapshotID)
if err != nil { if err != nil {
return err return err
@ -303,11 +303,11 @@ var snapshotURIRegexp = regexp.MustCompile(
// parseSnapshotName takes a snapshot name, either fully-qualified or not, and returns // parseSnapshotName takes a snapshot name, either fully-qualified or not, and returns
// a snapshot identifier or an error if the name is not in a valid format. If the name // a snapshot identifier or an error if the name is not in a valid format. If the name
// is not fully-qualified, the subscription and resource group are assumed to be the // is not fully-qualified, the subscription and resource group are assumed to be the
// ones that the block store is configured with. // ones that the volume snapshotter is configured with.
// //
// TODO(1.0) remove this function and replace usage with `parseFullSnapshotName` since // TODO(1.0) remove this function and replace usage with `parseFullSnapshotName` since
// we won't support the legacy snapshot name format for 1.0. // we won't support the legacy snapshot name format for 1.0.
func (b *BlockStore) parseSnapshotName(name string) (*snapshotIdentifier, error) { func (b *VolumeSnapshotter) parseSnapshotName(name string) (*snapshotIdentifier, error) {
switch { switch {
// legacy format - name only (not fully-qualified) // legacy format - name only (not fully-qualified)
case !strings.Contains(name, "/"): case !strings.Contains(name, "/"):
@ -357,7 +357,7 @@ func parseFullSnapshotName(name string) (*snapshotIdentifier, error) {
return snapshotID, nil return snapshotID, nil
} }
func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) { func (b *VolumeSnapshotter) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) {
pv := new(v1.PersistentVolume) pv := new(v1.PersistentVolume)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil { if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return "", errors.WithStack(err) return "", errors.WithStack(err)
@ -374,7 +374,7 @@ func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, e
return pv.Spec.AzureDisk.DiskName, nil return pv.Spec.AzureDisk.DiskName, nil
} }
func (b *BlockStore) SetVolumeID(unstructuredPV runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (b *VolumeSnapshotter) SetVolumeID(unstructuredPV runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
pv := new(v1.PersistentVolume) pv := new(v1.PersistentVolume)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil { if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)

View File

@ -27,7 +27,7 @@ import (
) )
func TestGetVolumeID(t *testing.T) { func TestGetVolumeID(t *testing.T) {
b := &BlockStore{} b := &VolumeSnapshotter{}
pv := &unstructured.Unstructured{ pv := &unstructured.Unstructured{
Object: map[string]interface{}{}, Object: map[string]interface{}{},
@ -55,7 +55,7 @@ func TestGetVolumeID(t *testing.T) {
} }
func TestSetVolumeID(t *testing.T) { func TestSetVolumeID(t *testing.T) {
b := &BlockStore{ b := &VolumeSnapshotter{
disksResourceGroup: "rg", disksResourceGroup: "rg",
subscription: "sub", subscription: "sub",
} }
@ -98,7 +98,7 @@ func TestSetVolumeID(t *testing.T) {
// the `parseFullSnapshotName` function, and remove case for legacy // the `parseFullSnapshotName` function, and remove case for legacy
// format // format
func TestParseSnapshotName(t *testing.T) { func TestParseSnapshotName(t *testing.T) {
b := &BlockStore{ b := &VolumeSnapshotter{
subscription: "default-sub", subscription: "default-sub",
disksResourceGroup: "default-rg-legacy", disksResourceGroup: "default-rg-legacy",
} }

View File

@ -40,17 +40,17 @@ const (
zoneSeparator = "__" zoneSeparator = "__"
) )
type BlockStore struct { type VolumeSnapshotter struct {
gce *compute.Service gce *compute.Service
project string project string
log logrus.FieldLogger log logrus.FieldLogger
} }
func NewBlockStore(logger logrus.FieldLogger) *BlockStore { func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
return &BlockStore{log: logger} return &VolumeSnapshotter{log: logger}
} }
func (b *BlockStore) Init(config map[string]string) error { func (b *VolumeSnapshotter) Init(config map[string]string) error {
project, err := extractProjectFromCreds() project, err := extractProjectFromCreds()
if err != nil { if err != nil {
return err return err
@ -125,7 +125,7 @@ func parseRegion(volumeAZ string) (string, error) {
} }
// Retrieve the URLs for zones via the GCP API. // Retrieve the URLs for zones via the GCP API.
func (b *BlockStore) getZoneURLs(volumeAZ string) ([]string, error) { func (b *VolumeSnapshotter) getZoneURLs(volumeAZ string) ([]string, error) {
zones := strings.Split(volumeAZ, zoneSeparator) zones := strings.Split(volumeAZ, zoneSeparator)
var zoneURLs []string var zoneURLs []string
for _, z := range zones { for _, z := range zones {
@ -140,7 +140,7 @@ func (b *BlockStore) getZoneURLs(volumeAZ string) ([]string, error) {
return zoneURLs, nil return zoneURLs, nil
} }
func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) { func (b *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) {
// get the snapshot so we can apply its tags to the volume // get the snapshot so we can apply its tags to the volume
res, err := b.gce.Snapshots.Get(b.project, snapshotID).Do() res, err := b.gce.Snapshots.Get(b.project, snapshotID).Do()
if err != nil { if err != nil {
@ -185,7 +185,7 @@ func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ s
return disk.Name, nil return disk.Name, nil
} }
func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) { func (b *VolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
var ( var (
res *compute.Disk res *compute.Disk
err error err error
@ -209,7 +209,7 @@ func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, e
return res.Type, nil, nil return res.Type, nil, nil
} }
func (b *BlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) { func (b *VolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
// snapshot names must adhere to RFC1035 and be 1-63 characters // snapshot names must adhere to RFC1035 and be 1-63 characters
// long // long
var snapshotName string var snapshotName string
@ -232,7 +232,7 @@ func (b *BlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]s
} }
} }
func (b *BlockStore) createSnapshot(snapshotName, volumeID, volumeAZ string, tags map[string]string) (string, error) { func (b *VolumeSnapshotter) createSnapshot(snapshotName, volumeID, volumeAZ string, tags map[string]string) (string, error) {
disk, err := b.gce.Disks.Get(b.project, volumeAZ, volumeID).Do() disk, err := b.gce.Disks.Get(b.project, volumeAZ, volumeID).Do()
if err != nil { if err != nil {
return "", errors.WithStack(err) return "", errors.WithStack(err)
@ -251,7 +251,7 @@ func (b *BlockStore) createSnapshot(snapshotName, volumeID, volumeAZ string, tag
return gceSnap.Name, nil return gceSnap.Name, nil
} }
func (b *BlockStore) createRegionSnapshot(snapshotName, volumeID, volumeRegion string, tags map[string]string) (string, error) { func (b *VolumeSnapshotter) createRegionSnapshot(snapshotName, volumeID, volumeRegion string, tags map[string]string) (string, error) {
disk, err := b.gce.RegionDisks.Get(b.project, volumeRegion, volumeID).Do() disk, err := b.gce.RegionDisks.Get(b.project, volumeRegion, volumeID).Do()
if err != nil { if err != nil {
return "", errors.WithStack(err) return "", errors.WithStack(err)
@ -304,7 +304,7 @@ func getSnapshotTags(veleroTags map[string]string, diskDescription string, log l
return string(tagsJSON) return string(tagsJSON)
} }
func (b *BlockStore) DeleteSnapshot(snapshotID string) error { func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
_, err := b.gce.Snapshots.Delete(b.project, snapshotID).Do() _, err := b.gce.Snapshots.Delete(b.project, snapshotID).Do()
// if it's a 404 (not found) error, we don't need to return an error // if it's a 404 (not found) error, we don't need to return an error
@ -319,7 +319,7 @@ func (b *BlockStore) DeleteSnapshot(snapshotID string) error {
return nil return nil
} }
func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) { func (b *VolumeSnapshotter) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) {
pv := new(v1.PersistentVolume) pv := new(v1.PersistentVolume)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil { if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return "", errors.WithStack(err) return "", errors.WithStack(err)
@ -336,7 +336,7 @@ func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, e
return pv.Spec.GCEPersistentDisk.PDName, nil return pv.Spec.GCEPersistentDisk.PDName, nil
} }
func (b *BlockStore) SetVolumeID(unstructuredPV runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (b *VolumeSnapshotter) SetVolumeID(unstructuredPV runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
pv := new(v1.PersistentVolume) pv := new(v1.PersistentVolume)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil { if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)

View File

@ -31,7 +31,7 @@ import (
) )
func TestGetVolumeID(t *testing.T) { func TestGetVolumeID(t *testing.T) {
b := &BlockStore{} b := &VolumeSnapshotter{}
pv := &unstructured.Unstructured{ pv := &unstructured.Unstructured{
Object: map[string]interface{}{}, Object: map[string]interface{}{},
@ -59,7 +59,7 @@ func TestGetVolumeID(t *testing.T) {
} }
func TestSetVolumeID(t *testing.T) { func TestSetVolumeID(t *testing.T) {
b := &BlockStore{} b := &VolumeSnapshotter{}
pv := &unstructured.Unstructured{ pv := &unstructured.Unstructured{
Object: map[string]interface{}{}, Object: map[string]interface{}{},

View File

@ -20,13 +20,13 @@ package mocks
import mock "github.com/stretchr/testify/mock" import mock "github.com/stretchr/testify/mock"
import runtime "k8s.io/apimachinery/pkg/runtime" import runtime "k8s.io/apimachinery/pkg/runtime"
// BlockStore is an autogenerated mock type for the BlockStore type // VolumeSnapshotter is an autogenerated mock type for the VolumeSnapshotter type
type BlockStore struct { type VolumeSnapshotter struct {
mock.Mock mock.Mock
} }
// CreateSnapshot provides a mock function with given fields: volumeID, volumeAZ, tags // CreateSnapshot provides a mock function with given fields: volumeID, volumeAZ, tags
func (_m *BlockStore) CreateSnapshot(volumeID string, volumeAZ string, tags map[string]string) (string, error) { func (_m *VolumeSnapshotter) CreateSnapshot(volumeID string, volumeAZ string, tags map[string]string) (string, error) {
ret := _m.Called(volumeID, volumeAZ, tags) ret := _m.Called(volumeID, volumeAZ, tags)
var r0 string var r0 string
@ -47,7 +47,7 @@ func (_m *BlockStore) CreateSnapshot(volumeID string, volumeAZ string, tags map[
} }
// CreateVolumeFromSnapshot provides a mock function with given fields: snapshotID, volumeType, volumeAZ, iops // CreateVolumeFromSnapshot provides a mock function with given fields: snapshotID, volumeType, volumeAZ, iops
func (_m *BlockStore) CreateVolumeFromSnapshot(snapshotID string, volumeType string, volumeAZ string, iops *int64) (string, error) { func (_m *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID string, volumeType string, volumeAZ string, iops *int64) (string, error) {
ret := _m.Called(snapshotID, volumeType, volumeAZ, iops) ret := _m.Called(snapshotID, volumeType, volumeAZ, iops)
var r0 string var r0 string
@ -68,7 +68,7 @@ func (_m *BlockStore) CreateVolumeFromSnapshot(snapshotID string, volumeType str
} }
// DeleteSnapshot provides a mock function with given fields: snapshotID // DeleteSnapshot provides a mock function with given fields: snapshotID
func (_m *BlockStore) DeleteSnapshot(snapshotID string) error { func (_m *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
ret := _m.Called(snapshotID) ret := _m.Called(snapshotID)
var r0 error var r0 error
@ -82,7 +82,7 @@ func (_m *BlockStore) DeleteSnapshot(snapshotID string) error {
} }
// GetVolumeID provides a mock function with given fields: pv // GetVolumeID provides a mock function with given fields: pv
func (_m *BlockStore) GetVolumeID(pv runtime.Unstructured) (string, error) { func (_m *VolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error) {
ret := _m.Called(pv) ret := _m.Called(pv)
var r0 string var r0 string
@ -103,7 +103,7 @@ func (_m *BlockStore) GetVolumeID(pv runtime.Unstructured) (string, error) {
} }
// GetVolumeInfo provides a mock function with given fields: volumeID, volumeAZ // GetVolumeInfo provides a mock function with given fields: volumeID, volumeAZ
func (_m *BlockStore) GetVolumeInfo(volumeID string, volumeAZ string) (string, *int64, error) { func (_m *VolumeSnapshotter) GetVolumeInfo(volumeID string, volumeAZ string) (string, *int64, error) {
ret := _m.Called(volumeID, volumeAZ) ret := _m.Called(volumeID, volumeAZ)
var r0 string var r0 string
@ -133,7 +133,7 @@ func (_m *BlockStore) GetVolumeInfo(volumeID string, volumeAZ string) (string, *
} }
// Init provides a mock function with given fields: config // Init provides a mock function with given fields: config
func (_m *BlockStore) Init(config map[string]string) error { func (_m *VolumeSnapshotter) Init(config map[string]string) error {
ret := _m.Called(config) ret := _m.Called(config)
var r0 error var r0 error
@ -147,7 +147,7 @@ func (_m *BlockStore) Init(config map[string]string) error {
} }
// SetVolumeID provides a mock function with given fields: pv, volumeID // SetVolumeID provides a mock function with given fields: pv, volumeID
func (_m *BlockStore) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (_m *VolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
ret := _m.Called(pv, volumeID) ret := _m.Called(pv, volumeID)
var r0 runtime.Unstructured var r0 runtime.Unstructured

View File

@ -41,9 +41,9 @@ func NewCommand(f client.Factory) *cobra.Command {
RegisterObjectStore("aws", newAwsObjectStore). RegisterObjectStore("aws", newAwsObjectStore).
RegisterObjectStore("azure", newAzureObjectStore). RegisterObjectStore("azure", newAzureObjectStore).
RegisterObjectStore("gcp", newGcpObjectStore). RegisterObjectStore("gcp", newGcpObjectStore).
RegisterBlockStore("aws", newAwsBlockStore). RegisterVolumeSnapshotter("aws", newAwsVolumeSnapshotter).
RegisterBlockStore("azure", newAzureBlockStore). RegisterVolumeSnapshotter("azure", newAzureVolumeSnapshotter).
RegisterBlockStore("gcp", newGcpBlockStore). RegisterVolumeSnapshotter("gcp", newGcpVolumeSnapshotter).
RegisterBackupItemAction("pv", newPVBackupItemAction). RegisterBackupItemAction("pv", newPVBackupItemAction).
RegisterBackupItemAction("pod", newPodBackupItemAction). RegisterBackupItemAction("pod", newPodBackupItemAction).
RegisterBackupItemAction("serviceaccount", newServiceAccountBackupItemAction(f)). RegisterBackupItemAction("serviceaccount", newServiceAccountBackupItemAction(f)).
@ -73,16 +73,16 @@ func newGcpObjectStore(logger logrus.FieldLogger) (interface{}, error) {
return gcp.NewObjectStore(logger), nil return gcp.NewObjectStore(logger), nil
} }
func newAwsBlockStore(logger logrus.FieldLogger) (interface{}, error) { func newAwsVolumeSnapshotter(logger logrus.FieldLogger) (interface{}, error) {
return aws.NewBlockStore(logger), nil return aws.NewVolumeSnapshotter(logger), nil
} }
func newAzureBlockStore(logger logrus.FieldLogger) (interface{}, error) { func newAzureVolumeSnapshotter(logger logrus.FieldLogger) (interface{}, error) {
return azure.NewBlockStore(logger), nil return azure.NewVolumeSnapshotter(logger), nil
} }
func newGcpBlockStore(logger logrus.FieldLogger) (interface{}, error) { func newGcpVolumeSnapshotter(logger logrus.FieldLogger) (interface{}, error) {
return gcp.NewBlockStore(logger), nil return gcp.NewVolumeSnapshotter(logger), nil
} }
func newPVBackupItemAction(logger logrus.FieldLogger) (interface{}, error) { func newPVBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {

View File

@ -51,8 +51,8 @@ type fakeBackupper struct {
mock.Mock mock.Mock
} }
func (b *fakeBackupper) Backup(logger logrus.FieldLogger, backup *pkgbackup.Request, backupFile io.Writer, actions []velero.BackupItemAction, blockStoreGetter pkgbackup.BlockStoreGetter) error { func (b *fakeBackupper) Backup(logger logrus.FieldLogger, backup *pkgbackup.Request, backupFile io.Writer, actions []velero.BackupItemAction, volumeSnapshotterGetter pkgbackup.VolumeSnapshotterGetter) error {
args := b.Called(logger, backup, backupFile, actions, blockStoreGetter) args := b.Called(logger, backup, backupFile, actions, volumeSnapshotterGetter)
return args.Error(0) return args.Error(0)
} }

View File

@ -254,12 +254,12 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e
} else if len(locations) != 1 { } else if len(locations) != 1 {
errs = append(errs, errors.Errorf("unable to delete pre-v0.10 volume snapshots because exactly one volume snapshot location must exist, got %d", len(locations)).Error()) errs = append(errs, errors.Errorf("unable to delete pre-v0.10 volume snapshots because exactly one volume snapshot location must exist, got %d", len(locations)).Error())
} else { } else {
blockStore, err := blockStoreForSnapshotLocation(backup.Namespace, locations[0].Name, c.snapshotLocationLister, pluginManager) volumeSnapshotter, err := volumeSnapshotterForSnapshotLocation(backup.Namespace, locations[0].Name, c.snapshotLocationLister, pluginManager)
if err != nil { if err != nil {
errs = append(errs, err.Error()) errs = append(errs, err.Error())
} else { } else {
for _, snapshot := range backup.Status.VolumeBackups { for _, snapshot := range backup.Status.VolumeBackups {
if err := blockStore.DeleteSnapshot(snapshot.SnapshotID); err != nil { if err := volumeSnapshotter.DeleteSnapshot(snapshot.SnapshotID); err != nil {
errs = append(errs, errors.Wrapf(err, "error deleting snapshot %s", snapshot.SnapshotID).Error()) errs = append(errs, errors.Wrapf(err, "error deleting snapshot %s", snapshot.SnapshotID).Error())
} }
} }
@ -270,21 +270,21 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e
if snapshots, err := backupStore.GetBackupVolumeSnapshots(backup.Name); err != nil { if snapshots, err := backupStore.GetBackupVolumeSnapshots(backup.Name); err != nil {
errs = append(errs, errors.Wrap(err, "error getting backup's volume snapshots").Error()) errs = append(errs, errors.Wrap(err, "error getting backup's volume snapshots").Error())
} else { } else {
blockStores := make(map[string]velero.BlockStore) volumeSnapshotters := make(map[string]velero.VolumeSnapshotter)
for _, snapshot := range snapshots { for _, snapshot := range snapshots {
log.WithField("providerSnapshotID", snapshot.Status.ProviderSnapshotID).Info("Removing snapshot associated with backup") log.WithField("providerSnapshotID", snapshot.Status.ProviderSnapshotID).Info("Removing snapshot associated with backup")
blockStore, ok := blockStores[snapshot.Spec.Location] volumeSnapshotter, ok := volumeSnapshotters[snapshot.Spec.Location]
if !ok { if !ok {
if blockStore, err = blockStoreForSnapshotLocation(backup.Namespace, snapshot.Spec.Location, c.snapshotLocationLister, pluginManager); err != nil { if volumeSnapshotter, err = volumeSnapshotterForSnapshotLocation(backup.Namespace, snapshot.Spec.Location, c.snapshotLocationLister, pluginManager); err != nil {
errs = append(errs, err.Error()) errs = append(errs, err.Error())
continue continue
} }
blockStores[snapshot.Spec.Location] = blockStore volumeSnapshotters[snapshot.Spec.Location] = volumeSnapshotter
} }
if err := blockStore.DeleteSnapshot(snapshot.Status.ProviderSnapshotID); err != nil { if err := volumeSnapshotter.DeleteSnapshot(snapshot.Status.ProviderSnapshotID); err != nil {
errs = append(errs, errors.Wrapf(err, "error deleting snapshot %s", snapshot.Status.ProviderSnapshotID).Error()) errs = append(errs, errors.Wrapf(err, "error deleting snapshot %s", snapshot.Status.ProviderSnapshotID).Error())
} }
} }
@ -361,26 +361,26 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e
return nil return nil
} }
func blockStoreForSnapshotLocation( func volumeSnapshotterForSnapshotLocation(
namespace, snapshotLocationName string, namespace, snapshotLocationName string,
snapshotLocationLister listers.VolumeSnapshotLocationLister, snapshotLocationLister listers.VolumeSnapshotLocationLister,
pluginManager clientmgmt.Manager, pluginManager clientmgmt.Manager,
) (velero.BlockStore, error) { ) (velero.VolumeSnapshotter, error) {
snapshotLocation, err := snapshotLocationLister.VolumeSnapshotLocations(namespace).Get(snapshotLocationName) snapshotLocation, err := snapshotLocationLister.VolumeSnapshotLocations(namespace).Get(snapshotLocationName)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error getting volume snapshot location %s", snapshotLocationName) return nil, errors.Wrapf(err, "error getting volume snapshot location %s", snapshotLocationName)
} }
blockStore, err := pluginManager.GetBlockStore(snapshotLocation.Spec.Provider) volumeSnapshotter, err := pluginManager.GetVolumeSnapshotter(snapshotLocation.Spec.Provider)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error getting block store for provider %s", snapshotLocation.Spec.Provider) return nil, errors.Wrapf(err, "error getting volume snapshotter for provider %s", snapshotLocation.Spec.Provider)
} }
if err = blockStore.Init(snapshotLocation.Spec.Config); err != nil { if err = volumeSnapshotter.Init(snapshotLocation.Spec.Config); err != nil {
return nil, errors.Wrapf(err, "error initializing block store for volume snapshot location %s", snapshotLocationName) return nil, errors.Wrapf(err, "error initializing volume snapshotter for volume snapshot location %s", snapshotLocationName)
} }
return blockStore, nil return volumeSnapshotter, nil
} }
func (c *backupDeletionController) backupStoreForBackup(backup *v1.Backup, pluginManager clientmgmt.Manager, log logrus.FieldLogger) (persistence.BackupStore, error) { func (c *backupDeletionController) backupStoreForBackup(backup *v1.Backup, pluginManager clientmgmt.Manager, log logrus.FieldLogger) (persistence.BackupStore, error) {

View File

@ -113,7 +113,7 @@ func TestBackupDeletionControllerProcessQueueItem(t *testing.T) {
type backupDeletionControllerTestData struct { type backupDeletionControllerTestData struct {
client *fake.Clientset client *fake.Clientset
sharedInformers informers.SharedInformerFactory sharedInformers informers.SharedInformerFactory
blockStore *velerotest.FakeBlockStore volumeSnapshotter *velerotest.FakeVolumeSnapshotter
backupStore *persistencemocks.BackupStore backupStore *persistencemocks.BackupStore
controller *backupDeletionController controller *backupDeletionController
req *v1.DeleteBackupRequest req *v1.DeleteBackupRequest
@ -123,7 +123,7 @@ func setupBackupDeletionControllerTest(objects ...runtime.Object) *backupDeletio
var ( var (
client = fake.NewSimpleClientset(objects...) client = fake.NewSimpleClientset(objects...)
sharedInformers = informers.NewSharedInformerFactory(client, 0) sharedInformers = informers.NewSharedInformerFactory(client, 0)
blockStore = &velerotest.FakeBlockStore{SnapshotsTaken: sets.NewString()} volumeSnapshotter = &velerotest.FakeVolumeSnapshotter{SnapshotsTaken: sets.NewString()}
pluginManager = &pluginmocks.Manager{} pluginManager = &pluginmocks.Manager{}
backupStore = &persistencemocks.BackupStore{} backupStore = &persistencemocks.BackupStore{}
req = pkgbackup.NewDeleteBackupRequest("foo", "uid") req = pkgbackup.NewDeleteBackupRequest("foo", "uid")
@ -132,7 +132,7 @@ func setupBackupDeletionControllerTest(objects ...runtime.Object) *backupDeletio
data := &backupDeletionControllerTestData{ data := &backupDeletionControllerTestData{
client: client, client: client,
sharedInformers: sharedInformers, sharedInformers: sharedInformers,
blockStore: blockStore, volumeSnapshotter: volumeSnapshotter,
backupStore: backupStore, backupStore: backupStore,
controller: NewBackupDeletionController( controller: NewBackupDeletionController(
velerotest.NewLogger(), velerotest.NewLogger(),
@ -376,7 +376,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
td.client.PrependReactor("get", "backups", func(action core.Action) (bool, runtime.Object, error) { td.client.PrependReactor("get", "backups", func(action core.Action) (bool, runtime.Object, error) {
return true, backup, nil return true, backup, nil
}) })
td.blockStore.SnapshotsTaken.Insert("snap-1") td.volumeSnapshotter.SnapshotsTaken.Insert("snap-1")
td.client.PrependReactor("patch", "deletebackuprequests", func(action core.Action) (bool, runtime.Object, error) { td.client.PrependReactor("patch", "deletebackuprequests", func(action core.Action) (bool, runtime.Object, error) {
return true, td.req, nil return true, td.req, nil
@ -387,7 +387,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
}) })
pluginManager := &pluginmocks.Manager{} pluginManager := &pluginmocks.Manager{}
pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil) pluginManager.On("GetVolumeSnapshotter", "provider-1").Return(td.volumeSnapshotter, nil)
pluginManager.On("CleanupClients") pluginManager.On("CleanupClients")
td.controller.newPluginManager = func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager } td.controller.newPluginManager = func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager }
@ -453,7 +453,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
velerotest.CompareActions(t, expectedActions, td.client.Actions()) velerotest.CompareActions(t, expectedActions, td.client.Actions())
// Make sure snapshot was deleted // Make sure snapshot was deleted
assert.Equal(t, 0, td.blockStore.SnapshotsTaken.Len()) assert.Equal(t, 0, td.volumeSnapshotter.SnapshotsTaken.Len())
}) })
t.Run("full delete, no errors", func(t *testing.T) { t.Run("full delete, no errors", func(t *testing.T) {
@ -504,7 +504,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
td.client.PrependReactor("get", "backups", func(action core.Action) (bool, runtime.Object, error) { td.client.PrependReactor("get", "backups", func(action core.Action) (bool, runtime.Object, error) {
return true, backup, nil return true, backup, nil
}) })
td.blockStore.SnapshotsTaken.Insert("snap-1") td.volumeSnapshotter.SnapshotsTaken.Insert("snap-1")
td.client.PrependReactor("patch", "deletebackuprequests", func(action core.Action) (bool, runtime.Object, error) { td.client.PrependReactor("patch", "deletebackuprequests", func(action core.Action) (bool, runtime.Object, error) {
return true, td.req, nil return true, td.req, nil
@ -526,7 +526,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
} }
pluginManager := &pluginmocks.Manager{} pluginManager := &pluginmocks.Manager{}
pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil) pluginManager.On("GetVolumeSnapshotter", "provider-1").Return(td.volumeSnapshotter, nil)
pluginManager.On("CleanupClients") pluginManager.On("CleanupClients")
td.controller.newPluginManager = func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager } td.controller.newPluginManager = func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager }
@ -593,7 +593,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
velerotest.CompareActions(t, expectedActions, td.client.Actions()) velerotest.CompareActions(t, expectedActions, td.client.Actions())
// Make sure snapshot was deleted // Make sure snapshot was deleted
assert.Equal(t, 0, td.blockStore.SnapshotsTaken.Len()) assert.Equal(t, 0, td.volumeSnapshotter.SnapshotsTaken.Len())
}) })
} }

View File

@ -925,7 +925,7 @@ func (r *fakeRestorer) Restore(
backupReader io.Reader, backupReader io.Reader,
actions []velero.RestoreItemAction, actions []velero.RestoreItemAction,
snapshotLocationLister listers.VolumeSnapshotLocationLister, snapshotLocationLister listers.VolumeSnapshotLocationLister,
blockStoreGetter restore.BlockStoreGetter, volumeSnapshotterGetter restore.VolumeSnapshotterGetter,
) (api.RestoreResult, api.RestoreResult) { ) (api.RestoreResult, api.RestoreResult) {
res := r.Called(log, restore, backup, backupReader, actions) res := r.Called(log, restore, backup, backupReader, actions)

View File

@ -64,7 +64,7 @@ func (b *clientBuilder) clientConfig() *hcplugin.ClientConfig {
AllowedProtocols: []hcplugin.Protocol{hcplugin.ProtocolGRPC}, AllowedProtocols: []hcplugin.Protocol{hcplugin.ProtocolGRPC},
Plugins: map[string]hcplugin.Plugin{ Plugins: map[string]hcplugin.Plugin{
string(framework.PluginKindBackupItemAction): framework.NewBackupItemActionPlugin(framework.ClientLogger(b.clientLogger)), string(framework.PluginKindBackupItemAction): framework.NewBackupItemActionPlugin(framework.ClientLogger(b.clientLogger)),
string(framework.PluginKindBlockStore): framework.NewBlockStorePlugin(framework.ClientLogger(b.clientLogger)), string(framework.PluginKindVolumeSnapshotter): framework.NewVolumeSnapshotterPlugin(framework.ClientLogger(b.clientLogger)),
string(framework.PluginKindObjectStore): framework.NewObjectStorePlugin(framework.ClientLogger(b.clientLogger)), string(framework.PluginKindObjectStore): framework.NewObjectStorePlugin(framework.ClientLogger(b.clientLogger)),
string(framework.PluginKindPluginLister): &framework.PluginListerPlugin{}, string(framework.PluginKindPluginLister): &framework.PluginListerPlugin{},
string(framework.PluginKindRestoreItemAction): framework.NewRestoreItemActionPlugin(framework.ClientLogger(b.clientLogger)), string(framework.PluginKindRestoreItemAction): framework.NewRestoreItemActionPlugin(framework.ClientLogger(b.clientLogger)),
@ -74,7 +74,7 @@ func (b *clientBuilder) clientConfig() *hcplugin.ClientConfig {
} }
} }
// client creates a new go-plugin Client with support for all of Velero's plugin kinds (BackupItemAction, BlockStore, // client creates a new go-plugin Client with support for all of Velero's plugin kinds (BackupItemAction, VolumeSnapshotter,
// ObjectStore, PluginLister, RestoreItemAction). // ObjectStore, PluginLister, RestoreItemAction).
func (b *clientBuilder) client() *hcplugin.Client { func (b *clientBuilder) client() *hcplugin.Client {
return hcplugin.NewClient(b.clientConfig()) return hcplugin.NewClient(b.clientConfig())

View File

@ -53,7 +53,7 @@ func TestClientConfig(t *testing.T) {
AllowedProtocols: []hcplugin.Protocol{hcplugin.ProtocolGRPC}, AllowedProtocols: []hcplugin.Protocol{hcplugin.ProtocolGRPC},
Plugins: map[string]hcplugin.Plugin{ Plugins: map[string]hcplugin.Plugin{
string(framework.PluginKindBackupItemAction): framework.NewBackupItemActionPlugin(framework.ClientLogger(logger)), string(framework.PluginKindBackupItemAction): framework.NewBackupItemActionPlugin(framework.ClientLogger(logger)),
string(framework.PluginKindBlockStore): framework.NewBlockStorePlugin(framework.ClientLogger(logger)), string(framework.PluginKindVolumeSnapshotter): framework.NewVolumeSnapshotterPlugin(framework.ClientLogger(logger)),
string(framework.PluginKindObjectStore): framework.NewObjectStorePlugin(framework.ClientLogger(logger)), string(framework.PluginKindObjectStore): framework.NewObjectStorePlugin(framework.ClientLogger(logger)),
string(framework.PluginKindPluginLister): &framework.PluginListerPlugin{}, string(framework.PluginKindPluginLister): &framework.PluginListerPlugin{},
string(framework.PluginKindRestoreItemAction): framework.NewRestoreItemActionPlugin(framework.ClientLogger(logger)), string(framework.PluginKindRestoreItemAction): framework.NewRestoreItemActionPlugin(framework.ClientLogger(logger)),

View File

@ -30,8 +30,8 @@ type Manager interface {
// GetObjectStore returns the ObjectStore plugin for name. // GetObjectStore returns the ObjectStore plugin for name.
GetObjectStore(name string) (velero.ObjectStore, error) GetObjectStore(name string) (velero.ObjectStore, error)
// GetBlockStore returns the BlockStore plugin for name. // GetVolumeSnapshotter returns the VolumeSnapshotter plugin for name.
GetBlockStore(name string) (velero.BlockStore, error) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error)
// GetBackupItemActions returns all backup item action plugins. // GetBackupItemActions returns all backup item action plugins.
GetBackupItemActions() ([]velero.BackupItemAction, error) GetBackupItemActions() ([]velero.BackupItemAction, error)
@ -134,14 +134,14 @@ func (m *manager) GetObjectStore(name string) (velero.ObjectStore, error) {
return r, nil return r, nil
} }
// GetBlockStore returns a restartableBlockStore for name. // GetVolumeSnapshotter returns a restartableVolumeSnapshotter for name.
func (m *manager) GetBlockStore(name string) (velero.BlockStore, error) { func (m *manager) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error) {
restartableProcess, err := m.getRestartableProcess(framework.PluginKindBlockStore, name) restartableProcess, err := m.getRestartableProcess(framework.PluginKindVolumeSnapshotter, name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
r := newRestartableBlockStore(name, restartableProcess) r := newRestartableVolumeSnapshotter(name, restartableProcess)
return r, nil return r, nil
} }

View File

@ -190,16 +190,16 @@ func TestGetObjectStore(t *testing.T) {
) )
} }
func TestGetBlockStore(t *testing.T) { func TestGetVolumeSnapshotter(t *testing.T) {
getPluginTest(t, getPluginTest(t,
framework.PluginKindBlockStore, framework.PluginKindVolumeSnapshotter,
"aws", "aws",
func(m Manager, name string) (interface{}, error) { func(m Manager, name string) (interface{}, error) {
return m.GetBlockStore(name) return m.GetVolumeSnapshotter(name)
}, },
func(name string, sharedPluginProcess RestartableProcess) interface{} { func(name string, sharedPluginProcess RestartableProcess) interface{} {
return &restartableBlockStore{ return &restartableVolumeSnapshotter{
key: kindAndName{kind: framework.PluginKindBlockStore, name: name}, key: kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name},
sharedPluginProcess: sharedPluginProcess, sharedPluginProcess: sharedPluginProcess,
} }
}, },

View File

@ -24,20 +24,20 @@ import (
"github.com/heptio/velero/pkg/plugin/velero" "github.com/heptio/velero/pkg/plugin/velero"
) )
// restartableBlockStore is an object store for a given implementation (such as "aws"). It is associated with // restartableVolumeSnapshotter is a volume snapshotter for a given implementation (such as "aws"). It is associated with
// a restartableProcess, which may be shared and used to run multiple plugins. At the beginning of each method // a restartableProcess, which may be shared and used to run multiple plugins. At the beginning of each method
// call, the restartableBlockStore asks its restartableProcess to restart itself if needed (e.g. if the // call, the restartableVolumeSnapshotter asks its restartableProcess to restart itself if needed (e.g. if the
// process terminated for any reason), then it proceeds with the actual call. // process terminated for any reason), then it proceeds with the actual call.
type restartableBlockStore struct { type restartableVolumeSnapshotter struct {
key kindAndName key kindAndName
sharedPluginProcess RestartableProcess sharedPluginProcess RestartableProcess
config map[string]string config map[string]string
} }
// newRestartableBlockStore returns a new restartableBlockStore. // newRestartableVolumeSnapshotter returns a new restartableVolumeSnapshotter.
func newRestartableBlockStore(name string, sharedPluginProcess RestartableProcess) *restartableBlockStore { func newRestartableVolumeSnapshotter(name string, sharedPluginProcess RestartableProcess) *restartableVolumeSnapshotter {
key := kindAndName{kind: framework.PluginKindBlockStore, name: name} key := kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name}
r := &restartableBlockStore{ r := &restartableVolumeSnapshotter{
key: key, key: key,
sharedPluginProcess: sharedPluginProcess, sharedPluginProcess: sharedPluginProcess,
} }
@ -49,48 +49,48 @@ func newRestartableBlockStore(name string, sharedPluginProcess RestartableProces
} }
// reinitialize reinitializes a re-dispensed plugin using the initial data passed to Init(). // reinitialize reinitializes a re-dispensed plugin using the initial data passed to Init().
func (r *restartableBlockStore) reinitialize(dispensed interface{}) error { func (r *restartableVolumeSnapshotter) reinitialize(dispensed interface{}) error {
blockStore, ok := dispensed.(velero.BlockStore) volumeSnapshotter, ok := dispensed.(velero.VolumeSnapshotter)
if !ok { if !ok {
return errors.Errorf("%T is not a BlockStore!", dispensed) return errors.Errorf("%T is not a VolumeSnapshotter!", dispensed)
} }
return r.init(blockStore, r.config) return r.init(volumeSnapshotter, r.config)
} }
// getBlockStore returns the block store for this restartableBlockStore. It does *not* restart the // getVolumeSnapshotter returns the volume snapshotter for this restartableVolumeSnapshotter. It does *not* restart the
// plugin process. // plugin process.
func (r *restartableBlockStore) getBlockStore() (velero.BlockStore, error) { func (r *restartableVolumeSnapshotter) getVolumeSnapshotter() (velero.VolumeSnapshotter, error) {
plugin, err := r.sharedPluginProcess.getByKindAndName(r.key) plugin, err := r.sharedPluginProcess.getByKindAndName(r.key)
if err != nil { if err != nil {
return nil, err return nil, err
} }
blockStore, ok := plugin.(velero.BlockStore) volumeSnapshotter, ok := plugin.(velero.VolumeSnapshotter)
if !ok { if !ok {
return nil, errors.Errorf("%T is not a BlockStore!", plugin) return nil, errors.Errorf("%T is not a VolumeSnapshotter!", plugin)
} }
return blockStore, nil return volumeSnapshotter, nil
} }
// getDelegate restarts the plugin process (if needed) and returns the block store for this restartableBlockStore. // getDelegate restarts the plugin process (if needed) and returns the volume snapshotter for this restartableVolumeSnapshotter.
func (r *restartableBlockStore) getDelegate() (velero.BlockStore, error) { func (r *restartableVolumeSnapshotter) getDelegate() (velero.VolumeSnapshotter, error) {
if err := r.sharedPluginProcess.resetIfNeeded(); err != nil { if err := r.sharedPluginProcess.resetIfNeeded(); err != nil {
return nil, err return nil, err
} }
return r.getBlockStore() return r.getVolumeSnapshotter()
} }
// Init initializes the block store instance using config. If this is the first invocation, r stores config for future // Init initializes the volume snapshotter instance using config. If this is the first invocation, r stores config for future
// reinitialization needs. Init does NOT restart the shared plugin process. Init may only be called once. // reinitialization needs. Init does NOT restart the shared plugin process. Init may only be called once.
func (r *restartableBlockStore) Init(config map[string]string) error { func (r *restartableVolumeSnapshotter) Init(config map[string]string) error {
if r.config != nil { if r.config != nil {
return errors.Errorf("already initialized") return errors.Errorf("already initialized")
} }
// Not using getDelegate() to avoid possible infinite recursion // Not using getDelegate() to avoid possible infinite recursion
delegate, err := r.getBlockStore() delegate, err := r.getVolumeSnapshotter()
if err != nil { if err != nil {
return err return err
} }
@ -100,14 +100,14 @@ func (r *restartableBlockStore) Init(config map[string]string) error {
return r.init(delegate, config) return r.init(delegate, config)
} }
// init calls Init on blockStore with config. This is split out from Init() so that both Init() and reinitialize() may // init calls Init on volumeSnapshotter with config. This is split out from Init() so that both Init() and reinitialize() may
// call it using a specific BlockStore. // call it using a specific VolumeSnapshotter.
func (r *restartableBlockStore) init(blockStore velero.BlockStore, config map[string]string) error { func (r *restartableVolumeSnapshotter) init(volumeSnapshotter velero.VolumeSnapshotter, config map[string]string) error {
return blockStore.Init(config) return volumeSnapshotter.Init(config)
} }
// CreateVolumeFromSnapshot restarts the plugin's process if needed, then delegates the call. // CreateVolumeFromSnapshot restarts the plugin's process if needed, then delegates the call.
func (r *restartableBlockStore) CreateVolumeFromSnapshot(snapshotID string, volumeType string, volumeAZ string, iops *int64) (volumeID string, err error) { func (r *restartableVolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID string, volumeType string, volumeAZ string, iops *int64) (volumeID string, err error) {
delegate, err := r.getDelegate() delegate, err := r.getDelegate()
if err != nil { if err != nil {
return "", err return "", err
@ -116,7 +116,7 @@ func (r *restartableBlockStore) CreateVolumeFromSnapshot(snapshotID string, volu
} }
// GetVolumeID restarts the plugin's process if needed, then delegates the call. // GetVolumeID restarts the plugin's process if needed, then delegates the call.
func (r *restartableBlockStore) GetVolumeID(pv runtime.Unstructured) (string, error) { func (r *restartableVolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error) {
delegate, err := r.getDelegate() delegate, err := r.getDelegate()
if err != nil { if err != nil {
return "", err return "", err
@ -125,7 +125,7 @@ func (r *restartableBlockStore) GetVolumeID(pv runtime.Unstructured) (string, er
} }
// SetVolumeID restarts the plugin's process if needed, then delegates the call. // SetVolumeID restarts the plugin's process if needed, then delegates the call.
func (r *restartableBlockStore) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (r *restartableVolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
delegate, err := r.getDelegate() delegate, err := r.getDelegate()
if err != nil { if err != nil {
return nil, err return nil, err
@ -134,7 +134,7 @@ func (r *restartableBlockStore) SetVolumeID(pv runtime.Unstructured, volumeID st
} }
// GetVolumeInfo restarts the plugin's process if needed, then delegates the call. // GetVolumeInfo restarts the plugin's process if needed, then delegates the call.
func (r *restartableBlockStore) GetVolumeInfo(volumeID string, volumeAZ string) (string, *int64, error) { func (r *restartableVolumeSnapshotter) GetVolumeInfo(volumeID string, volumeAZ string) (string, *int64, error) {
delegate, err := r.getDelegate() delegate, err := r.getDelegate()
if err != nil { if err != nil {
return "", nil, err return "", nil, err
@ -143,7 +143,7 @@ func (r *restartableBlockStore) GetVolumeInfo(volumeID string, volumeAZ string)
} }
// CreateSnapshot restarts the plugin's process if needed, then delegates the call. // CreateSnapshot restarts the plugin's process if needed, then delegates the call.
func (r *restartableBlockStore) CreateSnapshot(volumeID string, volumeAZ string, tags map[string]string) (snapshotID string, err error) { func (r *restartableVolumeSnapshotter) CreateSnapshot(volumeID string, volumeAZ string, tags map[string]string) (snapshotID string, err error) {
delegate, err := r.getDelegate() delegate, err := r.getDelegate()
if err != nil { if err != nil {
return "", err return "", err
@ -152,7 +152,7 @@ func (r *restartableBlockStore) CreateSnapshot(volumeID string, volumeAZ string,
} }
// DeleteSnapshot restarts the plugin's process if needed, then delegates the call. // DeleteSnapshot restarts the plugin's process if needed, then delegates the call.
func (r *restartableBlockStore) DeleteSnapshot(snapshotID string) error { func (r *restartableVolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
delegate, err := r.getDelegate() delegate, err := r.getDelegate()
if err != nil { if err != nil {
return err return err

View File

@ -29,7 +29,7 @@ import (
"github.com/heptio/velero/pkg/plugin/framework" "github.com/heptio/velero/pkg/plugin/framework"
) )
func TestRestartableGetBlockStore(t *testing.T) { func TestRestartableGetVolumeSnapshotter(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
plugin interface{} plugin interface{}
@ -44,11 +44,11 @@ func TestRestartableGetBlockStore(t *testing.T) {
{ {
name: "wrong type", name: "wrong type",
plugin: 3, plugin: 3,
expectedError: "int is not a BlockStore!", expectedError: "int is not a VolumeSnapshotter!",
}, },
{ {
name: "happy path", name: "happy path",
plugin: new(mocks.BlockStore), plugin: new(mocks.VolumeSnapshotter),
}, },
} }
@ -59,14 +59,14 @@ func TestRestartableGetBlockStore(t *testing.T) {
defer p.AssertExpectations(t) defer p.AssertExpectations(t)
name := "aws" name := "aws"
key := kindAndName{kind: framework.PluginKindBlockStore, name: name} key := kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name}
p.On("getByKindAndName", key).Return(tc.plugin, tc.getError) p.On("getByKindAndName", key).Return(tc.plugin, tc.getError)
r := &restartableBlockStore{ r := &restartableVolumeSnapshotter{
key: key, key: key,
sharedPluginProcess: p, sharedPluginProcess: p,
} }
a, err := r.getBlockStore() a, err := r.getVolumeSnapshotter()
if tc.expectedError != "" { if tc.expectedError != "" {
assert.EqualError(t, err, tc.expectedError) assert.EqualError(t, err, tc.expectedError)
return return
@ -78,14 +78,14 @@ func TestRestartableGetBlockStore(t *testing.T) {
} }
} }
func TestRestartableBlockStoreReinitialize(t *testing.T) { func TestRestartableVolumeSnapshotterReinitialize(t *testing.T) {
p := new(mockRestartableProcess) p := new(mockRestartableProcess)
p.Test(t) p.Test(t)
defer p.AssertExpectations(t) defer p.AssertExpectations(t)
name := "aws" name := "aws"
key := kindAndName{kind: framework.PluginKindBlockStore, name: name} key := kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name}
r := &restartableBlockStore{ r := &restartableVolumeSnapshotter{
key: key, key: key,
sharedPluginProcess: p, sharedPluginProcess: p,
config: map[string]string{ config: map[string]string{
@ -94,22 +94,22 @@ func TestRestartableBlockStoreReinitialize(t *testing.T) {
} }
err := r.reinitialize(3) err := r.reinitialize(3)
assert.EqualError(t, err, "int is not a BlockStore!") assert.EqualError(t, err, "int is not a VolumeSnapshotter!")
blockStore := new(mocks.BlockStore) volumeSnapshotter := new(mocks.VolumeSnapshotter)
blockStore.Test(t) volumeSnapshotter.Test(t)
defer blockStore.AssertExpectations(t) defer volumeSnapshotter.AssertExpectations(t)
blockStore.On("Init", r.config).Return(errors.Errorf("init error")).Once() volumeSnapshotter.On("Init", r.config).Return(errors.Errorf("init error")).Once()
err = r.reinitialize(blockStore) err = r.reinitialize(volumeSnapshotter)
assert.EqualError(t, err, "init error") assert.EqualError(t, err, "init error")
blockStore.On("Init", r.config).Return(nil) volumeSnapshotter.On("Init", r.config).Return(nil)
err = r.reinitialize(blockStore) err = r.reinitialize(volumeSnapshotter)
assert.NoError(t, err) assert.NoError(t, err)
} }
func TestRestartableBlockStoreGetDelegate(t *testing.T) { func TestRestartableVolumeSnapshotterGetDelegate(t *testing.T) {
p := new(mockRestartableProcess) p := new(mockRestartableProcess)
p.Test(t) p.Test(t)
defer p.AssertExpectations(t) defer p.AssertExpectations(t)
@ -117,8 +117,8 @@ func TestRestartableBlockStoreGetDelegate(t *testing.T) {
// Reset error // Reset error
p.On("resetIfNeeded").Return(errors.Errorf("reset error")).Once() p.On("resetIfNeeded").Return(errors.Errorf("reset error")).Once()
name := "aws" name := "aws"
key := kindAndName{kind: framework.PluginKindBlockStore, name: name} key := kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name}
r := &restartableBlockStore{ r := &restartableVolumeSnapshotter{
key: key, key: key,
sharedPluginProcess: p, sharedPluginProcess: p,
} }
@ -128,25 +128,25 @@ func TestRestartableBlockStoreGetDelegate(t *testing.T) {
// Happy path // Happy path
p.On("resetIfNeeded").Return(nil) p.On("resetIfNeeded").Return(nil)
blockStore := new(mocks.BlockStore) volumeSnapshotter := new(mocks.VolumeSnapshotter)
blockStore.Test(t) volumeSnapshotter.Test(t)
defer blockStore.AssertExpectations(t) defer volumeSnapshotter.AssertExpectations(t)
p.On("getByKindAndName", key).Return(blockStore, nil) p.On("getByKindAndName", key).Return(volumeSnapshotter, nil)
a, err = r.getDelegate() a, err = r.getDelegate()
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, blockStore, a) assert.Equal(t, volumeSnapshotter, a)
} }
func TestRestartableBlockStoreInit(t *testing.T) { func TestRestartableVolumeSnapshotterInit(t *testing.T) {
p := new(mockRestartableProcess) p := new(mockRestartableProcess)
p.Test(t) p.Test(t)
defer p.AssertExpectations(t) defer p.AssertExpectations(t)
// getBlockStore error // getVolumeSnapshottererror
name := "aws" name := "aws"
key := kindAndName{kind: framework.PluginKindBlockStore, name: name} key := kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name}
r := &restartableBlockStore{ r := &restartableVolumeSnapshotter{
key: key, key: key,
sharedPluginProcess: p, sharedPluginProcess: p,
} }
@ -159,11 +159,11 @@ func TestRestartableBlockStoreInit(t *testing.T) {
assert.EqualError(t, err, "getByKindAndName error") assert.EqualError(t, err, "getByKindAndName error")
// Delegate returns error // Delegate returns error
blockStore := new(mocks.BlockStore) volumeSnapshotter := new(mocks.VolumeSnapshotter)
blockStore.Test(t) volumeSnapshotter.Test(t)
defer blockStore.AssertExpectations(t) defer volumeSnapshotter.AssertExpectations(t)
p.On("getByKindAndName", key).Return(blockStore, nil) p.On("getByKindAndName", key).Return(volumeSnapshotter, nil)
blockStore.On("Init", config).Return(errors.Errorf("Init error")).Once() volumeSnapshotter.On("Init", config).Return(errors.Errorf("Init error")).Once()
err = r.Init(config) err = r.Init(config)
assert.EqualError(t, err, "Init error") assert.EqualError(t, err, "Init error")
@ -172,7 +172,7 @@ func TestRestartableBlockStoreInit(t *testing.T) {
r.config = nil r.config = nil
// Happy path // Happy path
blockStore.On("Init", config).Return(nil) volumeSnapshotter.On("Init", config).Return(nil)
err = r.Init(config) err = r.Init(config)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, config, r.config) assert.Equal(t, config, r.config)
@ -182,7 +182,7 @@ func TestRestartableBlockStoreInit(t *testing.T) {
assert.EqualError(t, err, "already initialized") assert.EqualError(t, err, "already initialized")
} }
func TestRestartableBlockStoreDelegatedFunctions(t *testing.T) { func TestRestartableVolumeSnapshotterDelegatedFunctions(t *testing.T) {
pv := &unstructured.Unstructured{ pv := &unstructured.Unstructured{
Object: map[string]interface{}{ Object: map[string]interface{}{
"color": "blue", "color": "blue",
@ -197,15 +197,15 @@ func TestRestartableBlockStoreDelegatedFunctions(t *testing.T) {
runRestartableDelegateTests( runRestartableDelegateTests(
t, t,
framework.PluginKindBlockStore, framework.PluginKindVolumeSnapshotter,
func(key kindAndName, p RestartableProcess) interface{} { func(key kindAndName, p RestartableProcess) interface{} {
return &restartableBlockStore{ return &restartableVolumeSnapshotter{
key: key, key: key,
sharedPluginProcess: p, sharedPluginProcess: p,
} }
}, },
func() mockable { func() mockable {
return new(mocks.BlockStore) return new(mocks.VolumeSnapshotter)
}, },
restartableDelegateTest{ restartableDelegateTest{
function: "CreateVolumeFromSnapshot", function: "CreateVolumeFromSnapshot",

View File

@ -21,30 +21,30 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
) )
func ExampleNewServer_blockStore() { func ExampleNewServer_volumeSnapshotter() {
NewServer(). // call the server NewServer(). // call the server
RegisterBlockStore("example-blockstore", newBlockStore). // register the plugin RegisterVolumeSnapshotter("example-volumesnapshotter", newVolumeSnapshotter). // register the plugin
Serve() // serve the plugin Serve() // serve the plugin
} }
func newBlockStore(logger logrus.FieldLogger) (interface{}, error) { func newVolumeSnapshotter(logger logrus.FieldLogger) (interface{}, error) {
return &BlockStore{FieldLogger: logger}, nil return &VolumeSnapshotter{FieldLogger: logger}, nil
} }
type BlockStore struct { type VolumeSnapshotter struct {
FieldLogger logrus.FieldLogger FieldLogger logrus.FieldLogger
} }
// Implement all methods for the BlockStore interface... // Implement all methods for the VolumeSnapshotter interface...
func (b *BlockStore) Init(config map[string]string) error { func (b *VolumeSnapshotter) Init(config map[string]string) error {
b.FieldLogger.Infof("BlockStore.Init called") b.FieldLogger.Infof("VolumeSnapshotter.Init called")
// ... // ...
return nil return nil
} }
func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) { func (b *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) {
b.FieldLogger.Infof("CreateVolumeFromSnapshot called") b.FieldLogger.Infof("CreateVolumeFromSnapshot called")
// ... // ...
@ -52,7 +52,7 @@ func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ s
return "volumeID", nil return "volumeID", nil
} }
func (b *BlockStore) GetVolumeID(pv runtime.Unstructured) (string, error) { func (b *VolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error) {
b.FieldLogger.Infof("GetVolumeID called") b.FieldLogger.Infof("GetVolumeID called")
// ... // ...
@ -60,7 +60,7 @@ func (b *BlockStore) GetVolumeID(pv runtime.Unstructured) (string, error) {
return "volumeID", nil return "volumeID", nil
} }
func (b *BlockStore) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (b *VolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
b.FieldLogger.Infof("SetVolumeID called") b.FieldLogger.Infof("SetVolumeID called")
// ... // ...
@ -68,7 +68,7 @@ func (b *BlockStore) SetVolumeID(pv runtime.Unstructured, volumeID string) (runt
return nil, nil return nil, nil
} }
func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) { func (b *VolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
b.FieldLogger.Infof("GetVolumeInfo called") b.FieldLogger.Infof("GetVolumeInfo called")
// ... // ...
@ -76,7 +76,7 @@ func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, e
return "volumeFilesystemType", nil, nil return "volumeFilesystemType", nil, nil
} }
func (b *BlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error) { func (b *VolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error) {
b.FieldLogger.Infof("CreateSnapshot called") b.FieldLogger.Infof("CreateSnapshot called")
// ... // ...
@ -84,7 +84,7 @@ func (b *BlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]s
return "snapshotID", nil return "snapshotID", nil
} }
func (b *BlockStore) DeleteSnapshot(snapshotID string) error { func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
b.FieldLogger.Infof("DeleteSnapshot called") b.FieldLogger.Infof("DeleteSnapshot called")
// ... // ...

View File

@ -33,8 +33,8 @@ const (
// PluginKindObjectStore represents an object store plugin. // PluginKindObjectStore represents an object store plugin.
PluginKindObjectStore PluginKind = "ObjectStore" PluginKindObjectStore PluginKind = "ObjectStore"
// PluginKindBlockStore represents a block store plugin. // PluginKindVolumeSnapshotter represents a volume snapshotter plugin.
PluginKindBlockStore PluginKind = "BlockStore" PluginKindVolumeSnapshotter PluginKind = "VolumeSnapshotter"
// PluginKindBackupItemAction represents a backup item action plugin. // PluginKindBackupItemAction represents a backup item action plugin.
PluginKindBackupItemAction PluginKind = "BackupItemAction" PluginKindBackupItemAction PluginKind = "BackupItemAction"
@ -50,7 +50,7 @@ const (
// kind that a developer would ever need to implement (it's handled by Velero and the Velero plugin library code). // kind that a developer would ever need to implement (it's handled by Velero and the Velero plugin library code).
var allPluginKinds = sets.NewString( var allPluginKinds = sets.NewString(
PluginKindObjectStore.String(), PluginKindObjectStore.String(),
PluginKindBlockStore.String(), PluginKindVolumeSnapshotter.String(),
PluginKindBackupItemAction.String(), PluginKindBackupItemAction.String(),
PluginKindRestoreItemAction.String(), PluginKindRestoreItemAction.String(),
) )

View File

@ -25,7 +25,7 @@ import (
func TestAllPluginKinds(t *testing.T) { func TestAllPluginKinds(t *testing.T) {
expected := sets.NewString( expected := sets.NewString(
PluginKindObjectStore.String(), PluginKindObjectStore.String(),
PluginKindBlockStore.String(), PluginKindVolumeSnapshotter.String(),
PluginKindBackupItemAction.String(), PluginKindBackupItemAction.String(),
PluginKindRestoreItemAction.String(), PluginKindRestoreItemAction.String(),
) )

View File

@ -25,7 +25,7 @@ import (
func TestPluginImplementationsAreGRPCPlugins(t *testing.T) { func TestPluginImplementationsAreGRPCPlugins(t *testing.T) {
pluginImpls := []interface{}{ pluginImpls := []interface{}{
new(BlockStorePlugin), new(VolumeSnapshotterPlugin),
new(BackupItemActionPlugin), new(BackupItemActionPlugin),
new(ObjectStorePlugin), new(ObjectStorePlugin),
new(PluginListerPlugin), new(PluginListerPlugin),

View File

@ -54,11 +54,11 @@ type Server interface {
// RegisterBackupItemActions registers multiple backup item actions. // RegisterBackupItemActions registers multiple backup item actions.
RegisterBackupItemActions(map[string]HandlerInitializer) Server RegisterBackupItemActions(map[string]HandlerInitializer) Server
// RegisterBlockStore registers a block store. // RegisterVolumeSnapshotter registers a volume snapshotter.
RegisterBlockStore(name string, initializer HandlerInitializer) Server RegisterVolumeSnapshotter(name string, initializer HandlerInitializer) Server
// RegisterBlockStores registers multiple block stores. // RegisterVolumeSnapshotters registers multiple volume snapshotters.
RegisterBlockStores(map[string]HandlerInitializer) Server RegisterVolumeSnapshotters(map[string]HandlerInitializer) Server
// RegisterObjectStore registers an object store. // RegisterObjectStore registers an object store.
RegisterObjectStore(name string, initializer HandlerInitializer) Server RegisterObjectStore(name string, initializer HandlerInitializer) Server
@ -82,7 +82,7 @@ type server struct {
logLevelFlag *logging.LevelFlag logLevelFlag *logging.LevelFlag
flagSet *pflag.FlagSet flagSet *pflag.FlagSet
backupItemAction *BackupItemActionPlugin backupItemAction *BackupItemActionPlugin
blockStore *BlockStorePlugin volumeSnapshotter *VolumeSnapshotterPlugin
objectStore *ObjectStorePlugin objectStore *ObjectStorePlugin
restoreItemAction *RestoreItemActionPlugin restoreItemAction *RestoreItemActionPlugin
} }
@ -95,7 +95,7 @@ func NewServer() Server {
log: log, log: log,
logLevelFlag: logging.LogLevelFlag(log.Level), logLevelFlag: logging.LogLevelFlag(log.Level),
backupItemAction: NewBackupItemActionPlugin(serverLogger(log)), backupItemAction: NewBackupItemActionPlugin(serverLogger(log)),
blockStore: NewBlockStorePlugin(serverLogger(log)), volumeSnapshotter: NewVolumeSnapshotterPlugin(serverLogger(log)),
objectStore: NewObjectStorePlugin(serverLogger(log)), objectStore: NewObjectStorePlugin(serverLogger(log)),
restoreItemAction: NewRestoreItemActionPlugin(serverLogger(log)), restoreItemAction: NewRestoreItemActionPlugin(serverLogger(log)),
} }
@ -120,14 +120,14 @@ func (s *server) RegisterBackupItemActions(m map[string]HandlerInitializer) Serv
return s return s
} }
func (s *server) RegisterBlockStore(name string, initializer HandlerInitializer) Server { func (s *server) RegisterVolumeSnapshotter(name string, initializer HandlerInitializer) Server {
s.blockStore.register(name, initializer) s.volumeSnapshotter.register(name, initializer)
return s return s
} }
func (s *server) RegisterBlockStores(m map[string]HandlerInitializer) Server { func (s *server) RegisterVolumeSnapshotters(m map[string]HandlerInitializer) Server {
for name := range m { for name := range m {
s.RegisterBlockStore(name, m[name]) s.RegisterVolumeSnapshotter(name, m[name])
} }
return s return s
} }
@ -181,7 +181,7 @@ func (s *server) Serve() {
var pluginIdentifiers []PluginIdentifier var pluginIdentifiers []PluginIdentifier
pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindBackupItemAction, s.backupItemAction)...) pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindBackupItemAction, s.backupItemAction)...)
pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindBlockStore, s.blockStore)...) pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindVolumeSnapshotter, s.volumeSnapshotter)...)
pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindObjectStore, s.objectStore)...) pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindObjectStore, s.objectStore)...)
pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindRestoreItemAction, s.restoreItemAction)...) pluginIdentifiers = append(pluginIdentifiers, getNames(command, PluginKindRestoreItemAction, s.restoreItemAction)...)
@ -191,7 +191,7 @@ func (s *server) Serve() {
HandshakeConfig: Handshake, HandshakeConfig: Handshake,
Plugins: map[string]plugin.Plugin{ Plugins: map[string]plugin.Plugin{
string(PluginKindBackupItemAction): s.backupItemAction, string(PluginKindBackupItemAction): s.backupItemAction,
string(PluginKindBlockStore): s.blockStore, string(PluginKindVolumeSnapshotter): s.volumeSnapshotter,
string(PluginKindObjectStore): s.objectStore, string(PluginKindObjectStore): s.objectStore,
string(PluginKindPluginLister): NewPluginListerPlugin(pluginLister), string(PluginKindPluginLister): NewPluginListerPlugin(pluginLister),
string(PluginKindRestoreItemAction): s.restoreItemAction, string(PluginKindRestoreItemAction): s.restoreItemAction,

View File

@ -23,7 +23,7 @@ import (
) )
// HandlerInitializer is a function that initializes and returns a new instance of one of Velero's plugin interfaces // HandlerInitializer is a function that initializes and returns a new instance of one of Velero's plugin interfaces
// (ObjectStore, BlockStore, BackupItemAction, RestoreItemAction). // (ObjectStore, VolumeSnapshotter, BackupItemAction, RestoreItemAction).
type HandlerInitializer func(logger logrus.FieldLogger) (interface{}, error) type HandlerInitializer func(logger logrus.FieldLogger) (interface{}, error)
// serverMux manages multiple implementations of a single plugin kind, such as pod and pvc BackupItemActions. // serverMux manages multiple implementations of a single plugin kind, such as pod and pvc BackupItemActions.

View File

@ -24,21 +24,21 @@ import (
proto "github.com/heptio/velero/pkg/plugin/generated" proto "github.com/heptio/velero/pkg/plugin/generated"
) )
// BlockStorePlugin is an implementation of go-plugin's Plugin // VolumeSnapshotterPlugin is an implementation of go-plugin's Plugin
// interface with support for gRPC for the cloudprovider/BlockStore // interface with support for gRPC for the cloudprovider/VolumeSnapshotter
// interface. // interface.
type BlockStorePlugin struct { type VolumeSnapshotterPlugin struct {
plugin.NetRPCUnsupportedPlugin plugin.NetRPCUnsupportedPlugin
*pluginBase *pluginBase
} }
// GRPCClient returns a BlockStore gRPC client. // GRPCClient returns a VolumeSnapshotter gRPC client.
func (p *BlockStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) { func (p *VolumeSnapshotterPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
return newClientDispenser(p.clientLogger, clientConn, newBlockStoreGRPCClient), nil return newClientDispenser(p.clientLogger, clientConn, newVolumeSnapshotterGRPCClient), nil
} }
// GRPCServer registers a BlockStore gRPC server. // GRPCServer registers a VolumeSnapshotter gRPC server.
func (p *BlockStorePlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error { func (p *VolumeSnapshotterPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
proto.RegisterBlockStoreServer(server, &BlockStoreGRPCServer{mux: p.serverMux}) proto.RegisterVolumeSnapshotterServer(server, &VolumeSnapshotterGRPCServer{mux: p.serverMux})
return nil return nil
} }

View File

@ -28,31 +28,31 @@ import (
proto "github.com/heptio/velero/pkg/plugin/generated" proto "github.com/heptio/velero/pkg/plugin/generated"
) )
// NewBlockStorePlugin constructs a BlockStorePlugin. // NewVolumeSnapshotterPlugin constructs a VolumeSnapshotterPlugin.
func NewBlockStorePlugin(options ...PluginOption) *BlockStorePlugin { func NewVolumeSnapshotterPlugin(options ...PluginOption) *VolumeSnapshotterPlugin {
return &BlockStorePlugin{ return &VolumeSnapshotterPlugin{
pluginBase: newPluginBase(options...), pluginBase: newPluginBase(options...),
} }
} }
// BlockStoreGRPCClient implements the cloudprovider.BlockStore interface and uses a // VolumeSnapshotterGRPCClient implements the cloudprovider.VolumeSnapshotter interface and uses a
// gRPC client to make calls to the plugin server. // gRPC client to make calls to the plugin server.
type BlockStoreGRPCClient struct { type VolumeSnapshotterGRPCClient struct {
*clientBase *clientBase
grpcClient proto.BlockStoreClient grpcClient proto.VolumeSnapshotterClient
} }
func newBlockStoreGRPCClient(base *clientBase, clientConn *grpc.ClientConn) interface{} { func newVolumeSnapshotterGRPCClient(base *clientBase, clientConn *grpc.ClientConn) interface{} {
return &BlockStoreGRPCClient{ return &VolumeSnapshotterGRPCClient{
clientBase: base, clientBase: base,
grpcClient: proto.NewBlockStoreClient(clientConn), grpcClient: proto.NewVolumeSnapshotterClient(clientConn),
} }
} }
// Init prepares the BlockStore for usage using the provided map of // Init prepares the VolumeSnapshotter for usage using the provided map of
// configuration key-value pairs. It returns an error if the BlockStore // configuration key-value pairs. It returns an error if the VolumeSnapshotter
// cannot be initialized from the provided config. // cannot be initialized from the provided config.
func (c *BlockStoreGRPCClient) Init(config map[string]string) error { func (c *VolumeSnapshotterGRPCClient) Init(config map[string]string) error {
req := &proto.InitRequest{ req := &proto.InitRequest{
Plugin: c.plugin, Plugin: c.plugin,
Config: config, Config: config,
@ -67,7 +67,7 @@ func (c *BlockStoreGRPCClient) Init(config map[string]string) error {
// CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot, // CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot,
// and with the specified type and IOPS (if using provisioned IOPS). // and with the specified type and IOPS (if using provisioned IOPS).
func (c *BlockStoreGRPCClient) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error) { func (c *VolumeSnapshotterGRPCClient) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error) {
req := &proto.CreateVolumeRequest{ req := &proto.CreateVolumeRequest{
Plugin: c.plugin, Plugin: c.plugin,
SnapshotID: snapshotID, SnapshotID: snapshotID,
@ -91,7 +91,7 @@ func (c *BlockStoreGRPCClient) CreateVolumeFromSnapshot(snapshotID, volumeType,
// GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block // GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block
// volume. // volume.
func (c *BlockStoreGRPCClient) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) { func (c *VolumeSnapshotterGRPCClient) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
req := &proto.GetVolumeInfoRequest{ req := &proto.GetVolumeInfoRequest{
Plugin: c.plugin, Plugin: c.plugin,
VolumeID: volumeID, VolumeID: volumeID,
@ -113,7 +113,7 @@ func (c *BlockStoreGRPCClient) GetVolumeInfo(volumeID, volumeAZ string) (string,
// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided // CreateSnapshot creates a snapshot of the specified block volume, and applies the provided
// set of tags to the snapshot. // set of tags to the snapshot.
func (c *BlockStoreGRPCClient) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) { func (c *VolumeSnapshotterGRPCClient) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
req := &proto.CreateSnapshotRequest{ req := &proto.CreateSnapshotRequest{
Plugin: c.plugin, Plugin: c.plugin,
VolumeID: volumeID, VolumeID: volumeID,
@ -130,7 +130,7 @@ func (c *BlockStoreGRPCClient) CreateSnapshot(volumeID, volumeAZ string, tags ma
} }
// DeleteSnapshot deletes the specified volume snapshot. // DeleteSnapshot deletes the specified volume snapshot.
func (c *BlockStoreGRPCClient) DeleteSnapshot(snapshotID string) error { func (c *VolumeSnapshotterGRPCClient) DeleteSnapshot(snapshotID string) error {
req := &proto.DeleteSnapshotRequest{ req := &proto.DeleteSnapshotRequest{
Plugin: c.plugin, Plugin: c.plugin,
SnapshotID: snapshotID, SnapshotID: snapshotID,
@ -143,7 +143,7 @@ func (c *BlockStoreGRPCClient) DeleteSnapshot(snapshotID string) error {
return nil return nil
} }
func (c *BlockStoreGRPCClient) GetVolumeID(pv runtime.Unstructured) (string, error) { func (c *VolumeSnapshotterGRPCClient) GetVolumeID(pv runtime.Unstructured) (string, error) {
encodedPV, err := json.Marshal(pv.UnstructuredContent()) encodedPV, err := json.Marshal(pv.UnstructuredContent())
if err != nil { if err != nil {
return "", errors.WithStack(err) return "", errors.WithStack(err)
@ -162,7 +162,7 @@ func (c *BlockStoreGRPCClient) GetVolumeID(pv runtime.Unstructured) (string, err
return resp.VolumeID, nil return resp.VolumeID, nil
} }
func (c *BlockStoreGRPCClient) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (c *VolumeSnapshotterGRPCClient) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
encodedPV, err := json.Marshal(pv.UnstructuredContent()) encodedPV, err := json.Marshal(pv.UnstructuredContent())
if err != nil { if err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)

View File

@ -27,30 +27,30 @@ import (
"github.com/heptio/velero/pkg/plugin/velero" "github.com/heptio/velero/pkg/plugin/velero"
) )
// BlockStoreGRPCServer implements the proto-generated BlockStoreServer interface, and accepts // VolumeSnapshotterGRPCServer implements the proto-generated VolumeSnapshotterServer interface, and accepts
// gRPC calls and forwards them to an implementation of the pluggable interface. // gRPC calls and forwards them to an implementation of the pluggable interface.
type BlockStoreGRPCServer struct { type VolumeSnapshotterGRPCServer struct {
mux *serverMux mux *serverMux
} }
func (s *BlockStoreGRPCServer) getImpl(name string) (velero.BlockStore, error) { func (s *VolumeSnapshotterGRPCServer) getImpl(name string) (velero.VolumeSnapshotter, error) {
impl, err := s.mux.getHandler(name) impl, err := s.mux.getHandler(name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
blockStore, ok := impl.(velero.BlockStore) volumeSnapshotter, ok := impl.(velero.VolumeSnapshotter)
if !ok { if !ok {
return nil, errors.Errorf("%T is not a block store", impl) return nil, errors.Errorf("%T is not a volume snapshotter", impl)
} }
return blockStore, nil return volumeSnapshotter, nil
} }
// Init prepares the BlockStore for usage using the provided map of // Init prepares the VolumeSnapshotter for usage using the provided map of
// configuration key-value pairs. It returns an error if the BlockStore // configuration key-value pairs. It returns an error if the VolumeSnapshotter
// cannot be initialized from the provided config. // cannot be initialized from the provided config.
func (s *BlockStoreGRPCServer) Init(ctx context.Context, req *proto.InitRequest) (response *proto.Empty, err error) { func (s *VolumeSnapshotterGRPCServer) Init(ctx context.Context, req *proto.InitRequest) (response *proto.Empty, err error) {
defer func() { defer func() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil { if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr err = recoveredErr
@ -71,7 +71,7 @@ func (s *BlockStoreGRPCServer) Init(ctx context.Context, req *proto.InitRequest)
// CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot, // CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot,
// and with the specified type and IOPS (if using provisioned IOPS). // and with the specified type and IOPS (if using provisioned IOPS).
func (s *BlockStoreGRPCServer) CreateVolumeFromSnapshot(ctx context.Context, req *proto.CreateVolumeRequest) (response *proto.CreateVolumeResponse, err error) { func (s *VolumeSnapshotterGRPCServer) CreateVolumeFromSnapshot(ctx context.Context, req *proto.CreateVolumeRequest) (response *proto.CreateVolumeResponse, err error) {
defer func() { defer func() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil { if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr err = recoveredErr
@ -102,7 +102,7 @@ func (s *BlockStoreGRPCServer) CreateVolumeFromSnapshot(ctx context.Context, req
// GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block // GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block
// volume. // volume.
func (s *BlockStoreGRPCServer) GetVolumeInfo(ctx context.Context, req *proto.GetVolumeInfoRequest) (response *proto.GetVolumeInfoResponse, err error) { func (s *VolumeSnapshotterGRPCServer) GetVolumeInfo(ctx context.Context, req *proto.GetVolumeInfoRequest) (response *proto.GetVolumeInfoResponse, err error) {
defer func() { defer func() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil { if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr err = recoveredErr
@ -132,7 +132,7 @@ func (s *BlockStoreGRPCServer) GetVolumeInfo(ctx context.Context, req *proto.Get
// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided // CreateSnapshot creates a snapshot of the specified block volume, and applies the provided
// set of tags to the snapshot. // set of tags to the snapshot.
func (s *BlockStoreGRPCServer) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotRequest) (response *proto.CreateSnapshotResponse, err error) { func (s *VolumeSnapshotterGRPCServer) CreateSnapshot(ctx context.Context, req *proto.CreateSnapshotRequest) (response *proto.CreateSnapshotResponse, err error) {
defer func() { defer func() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil { if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr err = recoveredErr
@ -153,7 +153,7 @@ func (s *BlockStoreGRPCServer) CreateSnapshot(ctx context.Context, req *proto.Cr
} }
// DeleteSnapshot deletes the specified volume snapshot. // DeleteSnapshot deletes the specified volume snapshot.
func (s *BlockStoreGRPCServer) DeleteSnapshot(ctx context.Context, req *proto.DeleteSnapshotRequest) (response *proto.Empty, err error) { func (s *VolumeSnapshotterGRPCServer) DeleteSnapshot(ctx context.Context, req *proto.DeleteSnapshotRequest) (response *proto.Empty, err error) {
defer func() { defer func() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil { if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr err = recoveredErr
@ -172,7 +172,7 @@ func (s *BlockStoreGRPCServer) DeleteSnapshot(ctx context.Context, req *proto.De
return &proto.Empty{}, nil return &proto.Empty{}, nil
} }
func (s *BlockStoreGRPCServer) GetVolumeID(ctx context.Context, req *proto.GetVolumeIDRequest) (response *proto.GetVolumeIDResponse, err error) { func (s *VolumeSnapshotterGRPCServer) GetVolumeID(ctx context.Context, req *proto.GetVolumeIDRequest) (response *proto.GetVolumeIDResponse, err error) {
defer func() { defer func() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil { if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr err = recoveredErr
@ -198,7 +198,7 @@ func (s *BlockStoreGRPCServer) GetVolumeID(ctx context.Context, req *proto.GetVo
return &proto.GetVolumeIDResponse{VolumeID: volumeID}, nil return &proto.GetVolumeIDResponse{VolumeID: volumeID}, nil
} }
func (s *BlockStoreGRPCServer) SetVolumeID(ctx context.Context, req *proto.SetVolumeIDRequest) (response *proto.SetVolumeIDResponse, err error) { func (s *VolumeSnapshotterGRPCServer) SetVolumeID(ctx context.Context, req *proto.SetVolumeIDRequest) (response *proto.SetVolumeIDResponse, err error) {
defer func() { defer func() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil { if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr err = recoveredErr

View File

@ -6,27 +6,16 @@ Package generated is a generated protocol buffer package.
It is generated from these files: It is generated from these files:
BackupItemAction.proto BackupItemAction.proto
BlockStore.proto
ObjectStore.proto ObjectStore.proto
PluginLister.proto PluginLister.proto
RestoreItemAction.proto RestoreItemAction.proto
Shared.proto Shared.proto
VolumeSnapshotter.proto
It has these top-level messages: It has these top-level messages:
ExecuteRequest ExecuteRequest
ExecuteResponse ExecuteResponse
ResourceIdentifier ResourceIdentifier
CreateVolumeRequest
CreateVolumeResponse
GetVolumeInfoRequest
GetVolumeInfoResponse
CreateSnapshotRequest
CreateSnapshotResponse
DeleteSnapshotRequest
GetVolumeIDRequest
GetVolumeIDResponse
SetVolumeIDRequest
SetVolumeIDResponse
PutObjectRequest PutObjectRequest
GetObjectRequest GetObjectRequest
Bytes Bytes
@ -47,6 +36,17 @@ It has these top-level messages:
AppliesToResponse AppliesToResponse
Stack Stack
StackFrame StackFrame
CreateVolumeRequest
CreateVolumeResponse
GetVolumeInfoRequest
GetVolumeInfoResponse
CreateSnapshotRequest
CreateSnapshotResponse
DeleteSnapshotRequest
GetVolumeIDRequest
GetVolumeIDResponse
SetVolumeIDRequest
SetVolumeIDResponse
*/ */
package generated package generated

View File

@ -27,7 +27,7 @@ type PutObjectRequest struct {
func (m *PutObjectRequest) Reset() { *m = PutObjectRequest{} } func (m *PutObjectRequest) Reset() { *m = PutObjectRequest{} }
func (m *PutObjectRequest) String() string { return proto.CompactTextString(m) } func (m *PutObjectRequest) String() string { return proto.CompactTextString(m) }
func (*PutObjectRequest) ProtoMessage() {} func (*PutObjectRequest) ProtoMessage() {}
func (*PutObjectRequest) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } func (*PutObjectRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} }
func (m *PutObjectRequest) GetPlugin() string { func (m *PutObjectRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -66,7 +66,7 @@ type GetObjectRequest struct {
func (m *GetObjectRequest) Reset() { *m = GetObjectRequest{} } func (m *GetObjectRequest) Reset() { *m = GetObjectRequest{} }
func (m *GetObjectRequest) String() string { return proto.CompactTextString(m) } func (m *GetObjectRequest) String() string { return proto.CompactTextString(m) }
func (*GetObjectRequest) ProtoMessage() {} func (*GetObjectRequest) ProtoMessage() {}
func (*GetObjectRequest) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{1} } func (*GetObjectRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} }
func (m *GetObjectRequest) GetPlugin() string { func (m *GetObjectRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -96,7 +96,7 @@ type Bytes struct {
func (m *Bytes) Reset() { *m = Bytes{} } func (m *Bytes) Reset() { *m = Bytes{} }
func (m *Bytes) String() string { return proto.CompactTextString(m) } func (m *Bytes) String() string { return proto.CompactTextString(m) }
func (*Bytes) ProtoMessage() {} func (*Bytes) ProtoMessage() {}
func (*Bytes) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{2} } func (*Bytes) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} }
func (m *Bytes) GetData() []byte { func (m *Bytes) GetData() []byte {
if m != nil { if m != nil {
@ -115,7 +115,7 @@ type ListCommonPrefixesRequest struct {
func (m *ListCommonPrefixesRequest) Reset() { *m = ListCommonPrefixesRequest{} } func (m *ListCommonPrefixesRequest) Reset() { *m = ListCommonPrefixesRequest{} }
func (m *ListCommonPrefixesRequest) String() string { return proto.CompactTextString(m) } func (m *ListCommonPrefixesRequest) String() string { return proto.CompactTextString(m) }
func (*ListCommonPrefixesRequest) ProtoMessage() {} func (*ListCommonPrefixesRequest) ProtoMessage() {}
func (*ListCommonPrefixesRequest) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{3} } func (*ListCommonPrefixesRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} }
func (m *ListCommonPrefixesRequest) GetPlugin() string { func (m *ListCommonPrefixesRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -152,7 +152,7 @@ type ListCommonPrefixesResponse struct {
func (m *ListCommonPrefixesResponse) Reset() { *m = ListCommonPrefixesResponse{} } func (m *ListCommonPrefixesResponse) Reset() { *m = ListCommonPrefixesResponse{} }
func (m *ListCommonPrefixesResponse) String() string { return proto.CompactTextString(m) } func (m *ListCommonPrefixesResponse) String() string { return proto.CompactTextString(m) }
func (*ListCommonPrefixesResponse) ProtoMessage() {} func (*ListCommonPrefixesResponse) ProtoMessage() {}
func (*ListCommonPrefixesResponse) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{4} } func (*ListCommonPrefixesResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} }
func (m *ListCommonPrefixesResponse) GetPrefixes() []string { func (m *ListCommonPrefixesResponse) GetPrefixes() []string {
if m != nil { if m != nil {
@ -170,7 +170,7 @@ type ListObjectsRequest struct {
func (m *ListObjectsRequest) Reset() { *m = ListObjectsRequest{} } func (m *ListObjectsRequest) Reset() { *m = ListObjectsRequest{} }
func (m *ListObjectsRequest) String() string { return proto.CompactTextString(m) } func (m *ListObjectsRequest) String() string { return proto.CompactTextString(m) }
func (*ListObjectsRequest) ProtoMessage() {} func (*ListObjectsRequest) ProtoMessage() {}
func (*ListObjectsRequest) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{5} } func (*ListObjectsRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} }
func (m *ListObjectsRequest) GetPlugin() string { func (m *ListObjectsRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -200,7 +200,7 @@ type ListObjectsResponse struct {
func (m *ListObjectsResponse) Reset() { *m = ListObjectsResponse{} } func (m *ListObjectsResponse) Reset() { *m = ListObjectsResponse{} }
func (m *ListObjectsResponse) String() string { return proto.CompactTextString(m) } func (m *ListObjectsResponse) String() string { return proto.CompactTextString(m) }
func (*ListObjectsResponse) ProtoMessage() {} func (*ListObjectsResponse) ProtoMessage() {}
func (*ListObjectsResponse) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{6} } func (*ListObjectsResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} }
func (m *ListObjectsResponse) GetKeys() []string { func (m *ListObjectsResponse) GetKeys() []string {
if m != nil { if m != nil {
@ -218,7 +218,7 @@ type DeleteObjectRequest struct {
func (m *DeleteObjectRequest) Reset() { *m = DeleteObjectRequest{} } func (m *DeleteObjectRequest) Reset() { *m = DeleteObjectRequest{} }
func (m *DeleteObjectRequest) String() string { return proto.CompactTextString(m) } func (m *DeleteObjectRequest) String() string { return proto.CompactTextString(m) }
func (*DeleteObjectRequest) ProtoMessage() {} func (*DeleteObjectRequest) ProtoMessage() {}
func (*DeleteObjectRequest) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{7} } func (*DeleteObjectRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} }
func (m *DeleteObjectRequest) GetPlugin() string { func (m *DeleteObjectRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -251,7 +251,7 @@ type CreateSignedURLRequest struct {
func (m *CreateSignedURLRequest) Reset() { *m = CreateSignedURLRequest{} } func (m *CreateSignedURLRequest) Reset() { *m = CreateSignedURLRequest{} }
func (m *CreateSignedURLRequest) String() string { return proto.CompactTextString(m) } func (m *CreateSignedURLRequest) String() string { return proto.CompactTextString(m) }
func (*CreateSignedURLRequest) ProtoMessage() {} func (*CreateSignedURLRequest) ProtoMessage() {}
func (*CreateSignedURLRequest) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{8} } func (*CreateSignedURLRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{8} }
func (m *CreateSignedURLRequest) GetPlugin() string { func (m *CreateSignedURLRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -288,7 +288,7 @@ type CreateSignedURLResponse struct {
func (m *CreateSignedURLResponse) Reset() { *m = CreateSignedURLResponse{} } func (m *CreateSignedURLResponse) Reset() { *m = CreateSignedURLResponse{} }
func (m *CreateSignedURLResponse) String() string { return proto.CompactTextString(m) } func (m *CreateSignedURLResponse) String() string { return proto.CompactTextString(m) }
func (*CreateSignedURLResponse) ProtoMessage() {} func (*CreateSignedURLResponse) ProtoMessage() {}
func (*CreateSignedURLResponse) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{9} } func (*CreateSignedURLResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{9} }
func (m *CreateSignedURLResponse) GetUrl() string { func (m *CreateSignedURLResponse) GetUrl() string {
if m != nil { if m != nil {
@ -642,9 +642,9 @@ var _ObjectStore_serviceDesc = grpc.ServiceDesc{
Metadata: "ObjectStore.proto", Metadata: "ObjectStore.proto",
} }
func init() { proto.RegisterFile("ObjectStore.proto", fileDescriptor2) } func init() { proto.RegisterFile("ObjectStore.proto", fileDescriptor1) }
var fileDescriptor2 = []byte{ var fileDescriptor1 = []byte{
// 468 bytes of a gzipped FileDescriptorProto // 468 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x51, 0x8b, 0xd3, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x51, 0x8b, 0xd3, 0x40,
0x10, 0x26, 0x26, 0x1e, 0x66, 0xae, 0x60, 0x9c, 0x83, 0x1a, 0x73, 0x2a, 0x75, 0x51, 0xa8, 0x08, 0x10, 0x26, 0x26, 0x1e, 0x66, 0xae, 0x60, 0x9c, 0x83, 0x1a, 0x73, 0x2a, 0x75, 0x51, 0xa8, 0x08,

View File

@ -26,7 +26,7 @@ type PluginIdentifier struct {
func (m *PluginIdentifier) Reset() { *m = PluginIdentifier{} } func (m *PluginIdentifier) Reset() { *m = PluginIdentifier{} }
func (m *PluginIdentifier) String() string { return proto.CompactTextString(m) } func (m *PluginIdentifier) String() string { return proto.CompactTextString(m) }
func (*PluginIdentifier) ProtoMessage() {} func (*PluginIdentifier) ProtoMessage() {}
func (*PluginIdentifier) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } func (*PluginIdentifier) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} }
func (m *PluginIdentifier) GetCommand() string { func (m *PluginIdentifier) GetCommand() string {
if m != nil { if m != nil {
@ -56,7 +56,7 @@ type ListPluginsResponse struct {
func (m *ListPluginsResponse) Reset() { *m = ListPluginsResponse{} } func (m *ListPluginsResponse) Reset() { *m = ListPluginsResponse{} }
func (m *ListPluginsResponse) String() string { return proto.CompactTextString(m) } func (m *ListPluginsResponse) String() string { return proto.CompactTextString(m) }
func (*ListPluginsResponse) ProtoMessage() {} func (*ListPluginsResponse) ProtoMessage() {}
func (*ListPluginsResponse) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} } func (*ListPluginsResponse) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{1} }
func (m *ListPluginsResponse) GetPlugins() []*PluginIdentifier { func (m *ListPluginsResponse) GetPlugins() []*PluginIdentifier {
if m != nil { if m != nil {
@ -142,9 +142,9 @@ var _PluginLister_serviceDesc = grpc.ServiceDesc{
Metadata: "PluginLister.proto", Metadata: "PluginLister.proto",
} }
func init() { proto.RegisterFile("PluginLister.proto", fileDescriptor3) } func init() { proto.RegisterFile("PluginLister.proto", fileDescriptor2) }
var fileDescriptor3 = []byte{ var fileDescriptor2 = []byte{
// 201 bytes of a gzipped FileDescriptorProto // 201 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x0a, 0xc8, 0x29, 0x4d, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x0a, 0xc8, 0x29, 0x4d,
0xcf, 0xcc, 0xf3, 0xc9, 0x2c, 0x2e, 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xcf, 0xcc, 0xf3, 0xc9, 0x2c, 0x2e, 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2,

View File

@ -27,7 +27,7 @@ type RestoreExecuteRequest struct {
func (m *RestoreExecuteRequest) Reset() { *m = RestoreExecuteRequest{} } func (m *RestoreExecuteRequest) Reset() { *m = RestoreExecuteRequest{} }
func (m *RestoreExecuteRequest) String() string { return proto.CompactTextString(m) } func (m *RestoreExecuteRequest) String() string { return proto.CompactTextString(m) }
func (*RestoreExecuteRequest) ProtoMessage() {} func (*RestoreExecuteRequest) ProtoMessage() {}
func (*RestoreExecuteRequest) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{0} } func (*RestoreExecuteRequest) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{0} }
func (m *RestoreExecuteRequest) GetPlugin() string { func (m *RestoreExecuteRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -65,7 +65,7 @@ type RestoreExecuteResponse struct {
func (m *RestoreExecuteResponse) Reset() { *m = RestoreExecuteResponse{} } func (m *RestoreExecuteResponse) Reset() { *m = RestoreExecuteResponse{} }
func (m *RestoreExecuteResponse) String() string { return proto.CompactTextString(m) } func (m *RestoreExecuteResponse) String() string { return proto.CompactTextString(m) }
func (*RestoreExecuteResponse) ProtoMessage() {} func (*RestoreExecuteResponse) ProtoMessage() {}
func (*RestoreExecuteResponse) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{1} } func (*RestoreExecuteResponse) Descriptor() ([]byte, []int) { return fileDescriptor3, []int{1} }
func (m *RestoreExecuteResponse) GetItem() []byte { func (m *RestoreExecuteResponse) GetItem() []byte {
if m != nil { if m != nil {
@ -191,9 +191,9 @@ var _RestoreItemAction_serviceDesc = grpc.ServiceDesc{
Metadata: "RestoreItemAction.proto", Metadata: "RestoreItemAction.proto",
} }
func init() { proto.RegisterFile("RestoreItemAction.proto", fileDescriptor4) } func init() { proto.RegisterFile("RestoreItemAction.proto", fileDescriptor3) }
var fileDescriptor4 = []byte{ var fileDescriptor3 = []byte{
// 252 bytes of a gzipped FileDescriptorProto // 252 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x4b, 0x4e, 0xc3, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x4b, 0x4e, 0xc3, 0x30,
0x14, 0x94, 0xa1, 0x6a, 0x95, 0xa7, 0x0a, 0x89, 0x27, 0x51, 0xac, 0xc0, 0x22, 0x74, 0x81, 0xba, 0x14, 0x94, 0xa1, 0x6a, 0x95, 0xa7, 0x0a, 0x89, 0x27, 0x51, 0xac, 0xc0, 0x22, 0x74, 0x81, 0xba,

View File

@ -18,7 +18,7 @@ type Empty struct {
func (m *Empty) Reset() { *m = Empty{} } func (m *Empty) Reset() { *m = Empty{} }
func (m *Empty) String() string { return proto.CompactTextString(m) } func (m *Empty) String() string { return proto.CompactTextString(m) }
func (*Empty) ProtoMessage() {} func (*Empty) ProtoMessage() {}
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} } func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{0} }
type InitRequest struct { type InitRequest struct {
Plugin string `protobuf:"bytes,1,opt,name=plugin" json:"plugin,omitempty"` Plugin string `protobuf:"bytes,1,opt,name=plugin" json:"plugin,omitempty"`
@ -28,7 +28,7 @@ type InitRequest struct {
func (m *InitRequest) Reset() { *m = InitRequest{} } func (m *InitRequest) Reset() { *m = InitRequest{} }
func (m *InitRequest) String() string { return proto.CompactTextString(m) } func (m *InitRequest) String() string { return proto.CompactTextString(m) }
func (*InitRequest) ProtoMessage() {} func (*InitRequest) ProtoMessage() {}
func (*InitRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{1} } func (*InitRequest) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{1} }
func (m *InitRequest) GetPlugin() string { func (m *InitRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -51,7 +51,7 @@ type AppliesToRequest struct {
func (m *AppliesToRequest) Reset() { *m = AppliesToRequest{} } func (m *AppliesToRequest) Reset() { *m = AppliesToRequest{} }
func (m *AppliesToRequest) String() string { return proto.CompactTextString(m) } func (m *AppliesToRequest) String() string { return proto.CompactTextString(m) }
func (*AppliesToRequest) ProtoMessage() {} func (*AppliesToRequest) ProtoMessage() {}
func (*AppliesToRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{2} } func (*AppliesToRequest) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{2} }
func (m *AppliesToRequest) GetPlugin() string { func (m *AppliesToRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -71,7 +71,7 @@ type AppliesToResponse struct {
func (m *AppliesToResponse) Reset() { *m = AppliesToResponse{} } func (m *AppliesToResponse) Reset() { *m = AppliesToResponse{} }
func (m *AppliesToResponse) String() string { return proto.CompactTextString(m) } func (m *AppliesToResponse) String() string { return proto.CompactTextString(m) }
func (*AppliesToResponse) ProtoMessage() {} func (*AppliesToResponse) ProtoMessage() {}
func (*AppliesToResponse) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{3} } func (*AppliesToResponse) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{3} }
func (m *AppliesToResponse) GetIncludedNamespaces() []string { func (m *AppliesToResponse) GetIncludedNamespaces() []string {
if m != nil { if m != nil {
@ -115,7 +115,7 @@ type Stack struct {
func (m *Stack) Reset() { *m = Stack{} } func (m *Stack) Reset() { *m = Stack{} }
func (m *Stack) String() string { return proto.CompactTextString(m) } func (m *Stack) String() string { return proto.CompactTextString(m) }
func (*Stack) ProtoMessage() {} func (*Stack) ProtoMessage() {}
func (*Stack) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{4} } func (*Stack) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{4} }
func (m *Stack) GetFrames() []*StackFrame { func (m *Stack) GetFrames() []*StackFrame {
if m != nil { if m != nil {
@ -133,7 +133,7 @@ type StackFrame struct {
func (m *StackFrame) Reset() { *m = StackFrame{} } func (m *StackFrame) Reset() { *m = StackFrame{} }
func (m *StackFrame) String() string { return proto.CompactTextString(m) } func (m *StackFrame) String() string { return proto.CompactTextString(m) }
func (*StackFrame) ProtoMessage() {} func (*StackFrame) ProtoMessage() {}
func (*StackFrame) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{5} } func (*StackFrame) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{5} }
func (m *StackFrame) GetFile() string { func (m *StackFrame) GetFile() string {
if m != nil { if m != nil {
@ -165,9 +165,9 @@ func init() {
proto.RegisterType((*StackFrame)(nil), "generated.StackFrame") proto.RegisterType((*StackFrame)(nil), "generated.StackFrame")
} }
func init() { proto.RegisterFile("Shared.proto", fileDescriptor5) } func init() { proto.RegisterFile("Shared.proto", fileDescriptor4) }
var fileDescriptor5 = []byte{ var fileDescriptor4 = []byte{
// 345 bytes of a gzipped FileDescriptorProto // 345 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x4a, 0xeb, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xc1, 0x4a, 0xeb, 0x40,
0x14, 0x86, 0x49, 0xd2, 0xe4, 0xde, 0x9e, 0xdc, 0x45, 0x3b, 0x5c, 0x25, 0x74, 0x55, 0xb2, 0x2a, 0x14, 0x86, 0x49, 0xd2, 0xe4, 0xde, 0x9e, 0xdc, 0x45, 0x3b, 0x5c, 0x25, 0x74, 0x55, 0xb2, 0x2a,

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: BlockStore.proto // source: VolumeSnapshotter.proto
package generated package generated
@ -28,7 +28,7 @@ type CreateVolumeRequest struct {
func (m *CreateVolumeRequest) Reset() { *m = CreateVolumeRequest{} } func (m *CreateVolumeRequest) Reset() { *m = CreateVolumeRequest{} }
func (m *CreateVolumeRequest) String() string { return proto.CompactTextString(m) } func (m *CreateVolumeRequest) String() string { return proto.CompactTextString(m) }
func (*CreateVolumeRequest) ProtoMessage() {} func (*CreateVolumeRequest) ProtoMessage() {}
func (*CreateVolumeRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} } func (*CreateVolumeRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} }
func (m *CreateVolumeRequest) GetPlugin() string { func (m *CreateVolumeRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -72,7 +72,7 @@ type CreateVolumeResponse struct {
func (m *CreateVolumeResponse) Reset() { *m = CreateVolumeResponse{} } func (m *CreateVolumeResponse) Reset() { *m = CreateVolumeResponse{} }
func (m *CreateVolumeResponse) String() string { return proto.CompactTextString(m) } func (m *CreateVolumeResponse) String() string { return proto.CompactTextString(m) }
func (*CreateVolumeResponse) ProtoMessage() {} func (*CreateVolumeResponse) ProtoMessage() {}
func (*CreateVolumeResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} } func (*CreateVolumeResponse) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{1} }
func (m *CreateVolumeResponse) GetVolumeID() string { func (m *CreateVolumeResponse) GetVolumeID() string {
if m != nil { if m != nil {
@ -90,7 +90,7 @@ type GetVolumeInfoRequest struct {
func (m *GetVolumeInfoRequest) Reset() { *m = GetVolumeInfoRequest{} } func (m *GetVolumeInfoRequest) Reset() { *m = GetVolumeInfoRequest{} }
func (m *GetVolumeInfoRequest) String() string { return proto.CompactTextString(m) } func (m *GetVolumeInfoRequest) String() string { return proto.CompactTextString(m) }
func (*GetVolumeInfoRequest) ProtoMessage() {} func (*GetVolumeInfoRequest) ProtoMessage() {}
func (*GetVolumeInfoRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} } func (*GetVolumeInfoRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{2} }
func (m *GetVolumeInfoRequest) GetPlugin() string { func (m *GetVolumeInfoRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -121,7 +121,7 @@ type GetVolumeInfoResponse struct {
func (m *GetVolumeInfoResponse) Reset() { *m = GetVolumeInfoResponse{} } func (m *GetVolumeInfoResponse) Reset() { *m = GetVolumeInfoResponse{} }
func (m *GetVolumeInfoResponse) String() string { return proto.CompactTextString(m) } func (m *GetVolumeInfoResponse) String() string { return proto.CompactTextString(m) }
func (*GetVolumeInfoResponse) ProtoMessage() {} func (*GetVolumeInfoResponse) ProtoMessage() {}
func (*GetVolumeInfoResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} } func (*GetVolumeInfoResponse) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{3} }
func (m *GetVolumeInfoResponse) GetVolumeType() string { func (m *GetVolumeInfoResponse) GetVolumeType() string {
if m != nil { if m != nil {
@ -147,7 +147,7 @@ type CreateSnapshotRequest struct {
func (m *CreateSnapshotRequest) Reset() { *m = CreateSnapshotRequest{} } func (m *CreateSnapshotRequest) Reset() { *m = CreateSnapshotRequest{} }
func (m *CreateSnapshotRequest) String() string { return proto.CompactTextString(m) } func (m *CreateSnapshotRequest) String() string { return proto.CompactTextString(m) }
func (*CreateSnapshotRequest) ProtoMessage() {} func (*CreateSnapshotRequest) ProtoMessage() {}
func (*CreateSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} } func (*CreateSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{4} }
func (m *CreateSnapshotRequest) GetPlugin() string { func (m *CreateSnapshotRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -184,7 +184,7 @@ type CreateSnapshotResponse struct {
func (m *CreateSnapshotResponse) Reset() { *m = CreateSnapshotResponse{} } func (m *CreateSnapshotResponse) Reset() { *m = CreateSnapshotResponse{} }
func (m *CreateSnapshotResponse) String() string { return proto.CompactTextString(m) } func (m *CreateSnapshotResponse) String() string { return proto.CompactTextString(m) }
func (*CreateSnapshotResponse) ProtoMessage() {} func (*CreateSnapshotResponse) ProtoMessage() {}
func (*CreateSnapshotResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} } func (*CreateSnapshotResponse) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{5} }
func (m *CreateSnapshotResponse) GetSnapshotID() string { func (m *CreateSnapshotResponse) GetSnapshotID() string {
if m != nil { if m != nil {
@ -201,7 +201,7 @@ type DeleteSnapshotRequest struct {
func (m *DeleteSnapshotRequest) Reset() { *m = DeleteSnapshotRequest{} } func (m *DeleteSnapshotRequest) Reset() { *m = DeleteSnapshotRequest{} }
func (m *DeleteSnapshotRequest) String() string { return proto.CompactTextString(m) } func (m *DeleteSnapshotRequest) String() string { return proto.CompactTextString(m) }
func (*DeleteSnapshotRequest) ProtoMessage() {} func (*DeleteSnapshotRequest) ProtoMessage() {}
func (*DeleteSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} } func (*DeleteSnapshotRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{6} }
func (m *DeleteSnapshotRequest) GetPlugin() string { func (m *DeleteSnapshotRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -225,7 +225,7 @@ type GetVolumeIDRequest struct {
func (m *GetVolumeIDRequest) Reset() { *m = GetVolumeIDRequest{} } func (m *GetVolumeIDRequest) Reset() { *m = GetVolumeIDRequest{} }
func (m *GetVolumeIDRequest) String() string { return proto.CompactTextString(m) } func (m *GetVolumeIDRequest) String() string { return proto.CompactTextString(m) }
func (*GetVolumeIDRequest) ProtoMessage() {} func (*GetVolumeIDRequest) ProtoMessage() {}
func (*GetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{7} } func (*GetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{7} }
func (m *GetVolumeIDRequest) GetPlugin() string { func (m *GetVolumeIDRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -248,7 +248,7 @@ type GetVolumeIDResponse struct {
func (m *GetVolumeIDResponse) Reset() { *m = GetVolumeIDResponse{} } func (m *GetVolumeIDResponse) Reset() { *m = GetVolumeIDResponse{} }
func (m *GetVolumeIDResponse) String() string { return proto.CompactTextString(m) } func (m *GetVolumeIDResponse) String() string { return proto.CompactTextString(m) }
func (*GetVolumeIDResponse) ProtoMessage() {} func (*GetVolumeIDResponse) ProtoMessage() {}
func (*GetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{8} } func (*GetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{8} }
func (m *GetVolumeIDResponse) GetVolumeID() string { func (m *GetVolumeIDResponse) GetVolumeID() string {
if m != nil { if m != nil {
@ -266,7 +266,7 @@ type SetVolumeIDRequest struct {
func (m *SetVolumeIDRequest) Reset() { *m = SetVolumeIDRequest{} } func (m *SetVolumeIDRequest) Reset() { *m = SetVolumeIDRequest{} }
func (m *SetVolumeIDRequest) String() string { return proto.CompactTextString(m) } func (m *SetVolumeIDRequest) String() string { return proto.CompactTextString(m) }
func (*SetVolumeIDRequest) ProtoMessage() {} func (*SetVolumeIDRequest) ProtoMessage() {}
func (*SetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{9} } func (*SetVolumeIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{9} }
func (m *SetVolumeIDRequest) GetPlugin() string { func (m *SetVolumeIDRequest) GetPlugin() string {
if m != nil { if m != nil {
@ -296,7 +296,7 @@ type SetVolumeIDResponse struct {
func (m *SetVolumeIDResponse) Reset() { *m = SetVolumeIDResponse{} } func (m *SetVolumeIDResponse) Reset() { *m = SetVolumeIDResponse{} }
func (m *SetVolumeIDResponse) String() string { return proto.CompactTextString(m) } func (m *SetVolumeIDResponse) String() string { return proto.CompactTextString(m) }
func (*SetVolumeIDResponse) ProtoMessage() {} func (*SetVolumeIDResponse) ProtoMessage() {}
func (*SetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{10} } func (*SetVolumeIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{10} }
func (m *SetVolumeIDResponse) GetPersistentVolume() []byte { func (m *SetVolumeIDResponse) GetPersistentVolume() []byte {
if m != nil { if m != nil {
@ -327,9 +327,9 @@ var _ grpc.ClientConn
// is compatible with the grpc package it is being compiled against. // is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4 const _ = grpc.SupportPackageIsVersion4
// Client API for BlockStore service // Client API for VolumeSnapshotter service
type BlockStoreClient interface { type VolumeSnapshotterClient interface {
Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*Empty, error) Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*Empty, error)
CreateVolumeFromSnapshot(ctx context.Context, in *CreateVolumeRequest, opts ...grpc.CallOption) (*CreateVolumeResponse, error) CreateVolumeFromSnapshot(ctx context.Context, in *CreateVolumeRequest, opts ...grpc.CallOption) (*CreateVolumeResponse, error)
GetVolumeInfo(ctx context.Context, in *GetVolumeInfoRequest, opts ...grpc.CallOption) (*GetVolumeInfoResponse, error) GetVolumeInfo(ctx context.Context, in *GetVolumeInfoRequest, opts ...grpc.CallOption) (*GetVolumeInfoResponse, error)
@ -339,80 +339,80 @@ type BlockStoreClient interface {
SetVolumeID(ctx context.Context, in *SetVolumeIDRequest, opts ...grpc.CallOption) (*SetVolumeIDResponse, error) SetVolumeID(ctx context.Context, in *SetVolumeIDRequest, opts ...grpc.CallOption) (*SetVolumeIDResponse, error)
} }
type blockStoreClient struct { type volumeSnapshotterClient struct {
cc *grpc.ClientConn cc *grpc.ClientConn
} }
func NewBlockStoreClient(cc *grpc.ClientConn) BlockStoreClient { func NewVolumeSnapshotterClient(cc *grpc.ClientConn) VolumeSnapshotterClient {
return &blockStoreClient{cc} return &volumeSnapshotterClient{cc}
} }
func (c *blockStoreClient) Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*Empty, error) { func (c *volumeSnapshotterClient) Init(ctx context.Context, in *InitRequest, opts ...grpc.CallOption) (*Empty, error) {
out := new(Empty) out := new(Empty)
err := grpc.Invoke(ctx, "/generated.BlockStore/Init", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/generated.VolumeSnapshotter/Init", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *blockStoreClient) CreateVolumeFromSnapshot(ctx context.Context, in *CreateVolumeRequest, opts ...grpc.CallOption) (*CreateVolumeResponse, error) { func (c *volumeSnapshotterClient) CreateVolumeFromSnapshot(ctx context.Context, in *CreateVolumeRequest, opts ...grpc.CallOption) (*CreateVolumeResponse, error) {
out := new(CreateVolumeResponse) out := new(CreateVolumeResponse)
err := grpc.Invoke(ctx, "/generated.BlockStore/CreateVolumeFromSnapshot", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/generated.VolumeSnapshotter/CreateVolumeFromSnapshot", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *blockStoreClient) GetVolumeInfo(ctx context.Context, in *GetVolumeInfoRequest, opts ...grpc.CallOption) (*GetVolumeInfoResponse, error) { func (c *volumeSnapshotterClient) GetVolumeInfo(ctx context.Context, in *GetVolumeInfoRequest, opts ...grpc.CallOption) (*GetVolumeInfoResponse, error) {
out := new(GetVolumeInfoResponse) out := new(GetVolumeInfoResponse)
err := grpc.Invoke(ctx, "/generated.BlockStore/GetVolumeInfo", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/generated.VolumeSnapshotter/GetVolumeInfo", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *blockStoreClient) CreateSnapshot(ctx context.Context, in *CreateSnapshotRequest, opts ...grpc.CallOption) (*CreateSnapshotResponse, error) { func (c *volumeSnapshotterClient) CreateSnapshot(ctx context.Context, in *CreateSnapshotRequest, opts ...grpc.CallOption) (*CreateSnapshotResponse, error) {
out := new(CreateSnapshotResponse) out := new(CreateSnapshotResponse)
err := grpc.Invoke(ctx, "/generated.BlockStore/CreateSnapshot", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/generated.VolumeSnapshotter/CreateSnapshot", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *blockStoreClient) DeleteSnapshot(ctx context.Context, in *DeleteSnapshotRequest, opts ...grpc.CallOption) (*Empty, error) { func (c *volumeSnapshotterClient) DeleteSnapshot(ctx context.Context, in *DeleteSnapshotRequest, opts ...grpc.CallOption) (*Empty, error) {
out := new(Empty) out := new(Empty)
err := grpc.Invoke(ctx, "/generated.BlockStore/DeleteSnapshot", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/generated.VolumeSnapshotter/DeleteSnapshot", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *blockStoreClient) GetVolumeID(ctx context.Context, in *GetVolumeIDRequest, opts ...grpc.CallOption) (*GetVolumeIDResponse, error) { func (c *volumeSnapshotterClient) GetVolumeID(ctx context.Context, in *GetVolumeIDRequest, opts ...grpc.CallOption) (*GetVolumeIDResponse, error) {
out := new(GetVolumeIDResponse) out := new(GetVolumeIDResponse)
err := grpc.Invoke(ctx, "/generated.BlockStore/GetVolumeID", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/generated.VolumeSnapshotter/GetVolumeID", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
func (c *blockStoreClient) SetVolumeID(ctx context.Context, in *SetVolumeIDRequest, opts ...grpc.CallOption) (*SetVolumeIDResponse, error) { func (c *volumeSnapshotterClient) SetVolumeID(ctx context.Context, in *SetVolumeIDRequest, opts ...grpc.CallOption) (*SetVolumeIDResponse, error) {
out := new(SetVolumeIDResponse) out := new(SetVolumeIDResponse)
err := grpc.Invoke(ctx, "/generated.BlockStore/SetVolumeID", in, out, c.cc, opts...) err := grpc.Invoke(ctx, "/generated.VolumeSnapshotter/SetVolumeID", in, out, c.cc, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return out, nil return out, nil
} }
// Server API for BlockStore service // Server API for VolumeSnapshotter service
type BlockStoreServer interface { type VolumeSnapshotterServer interface {
Init(context.Context, *InitRequest) (*Empty, error) Init(context.Context, *InitRequest) (*Empty, error)
CreateVolumeFromSnapshot(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error) CreateVolumeFromSnapshot(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error)
GetVolumeInfo(context.Context, *GetVolumeInfoRequest) (*GetVolumeInfoResponse, error) GetVolumeInfo(context.Context, *GetVolumeInfoRequest) (*GetVolumeInfoResponse, error)
@ -422,208 +422,208 @@ type BlockStoreServer interface {
SetVolumeID(context.Context, *SetVolumeIDRequest) (*SetVolumeIDResponse, error) SetVolumeID(context.Context, *SetVolumeIDRequest) (*SetVolumeIDResponse, error)
} }
func RegisterBlockStoreServer(s *grpc.Server, srv BlockStoreServer) { func RegisterVolumeSnapshotterServer(s *grpc.Server, srv VolumeSnapshotterServer) {
s.RegisterService(&_BlockStore_serviceDesc, srv) s.RegisterService(&_VolumeSnapshotter_serviceDesc, srv)
} }
func _BlockStore_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _VolumeSnapshotter_Init_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(InitRequest) in := new(InitRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(BlockStoreServer).Init(ctx, in) return srv.(VolumeSnapshotterServer).Init(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/generated.BlockStore/Init", FullMethod: "/generated.VolumeSnapshotter/Init",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BlockStoreServer).Init(ctx, req.(*InitRequest)) return srv.(VolumeSnapshotterServer).Init(ctx, req.(*InitRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _BlockStore_CreateVolumeFromSnapshot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _VolumeSnapshotter_CreateVolumeFromSnapshot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateVolumeRequest) in := new(CreateVolumeRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(BlockStoreServer).CreateVolumeFromSnapshot(ctx, in) return srv.(VolumeSnapshotterServer).CreateVolumeFromSnapshot(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/generated.BlockStore/CreateVolumeFromSnapshot", FullMethod: "/generated.VolumeSnapshotter/CreateVolumeFromSnapshot",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BlockStoreServer).CreateVolumeFromSnapshot(ctx, req.(*CreateVolumeRequest)) return srv.(VolumeSnapshotterServer).CreateVolumeFromSnapshot(ctx, req.(*CreateVolumeRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _BlockStore_GetVolumeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _VolumeSnapshotter_GetVolumeInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetVolumeInfoRequest) in := new(GetVolumeInfoRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(BlockStoreServer).GetVolumeInfo(ctx, in) return srv.(VolumeSnapshotterServer).GetVolumeInfo(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/generated.BlockStore/GetVolumeInfo", FullMethod: "/generated.VolumeSnapshotter/GetVolumeInfo",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BlockStoreServer).GetVolumeInfo(ctx, req.(*GetVolumeInfoRequest)) return srv.(VolumeSnapshotterServer).GetVolumeInfo(ctx, req.(*GetVolumeInfoRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _BlockStore_CreateSnapshot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _VolumeSnapshotter_CreateSnapshot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateSnapshotRequest) in := new(CreateSnapshotRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(BlockStoreServer).CreateSnapshot(ctx, in) return srv.(VolumeSnapshotterServer).CreateSnapshot(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/generated.BlockStore/CreateSnapshot", FullMethod: "/generated.VolumeSnapshotter/CreateSnapshot",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BlockStoreServer).CreateSnapshot(ctx, req.(*CreateSnapshotRequest)) return srv.(VolumeSnapshotterServer).CreateSnapshot(ctx, req.(*CreateSnapshotRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _BlockStore_DeleteSnapshot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _VolumeSnapshotter_DeleteSnapshot_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteSnapshotRequest) in := new(DeleteSnapshotRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(BlockStoreServer).DeleteSnapshot(ctx, in) return srv.(VolumeSnapshotterServer).DeleteSnapshot(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/generated.BlockStore/DeleteSnapshot", FullMethod: "/generated.VolumeSnapshotter/DeleteSnapshot",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BlockStoreServer).DeleteSnapshot(ctx, req.(*DeleteSnapshotRequest)) return srv.(VolumeSnapshotterServer).DeleteSnapshot(ctx, req.(*DeleteSnapshotRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _BlockStore_GetVolumeID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _VolumeSnapshotter_GetVolumeID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetVolumeIDRequest) in := new(GetVolumeIDRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(BlockStoreServer).GetVolumeID(ctx, in) return srv.(VolumeSnapshotterServer).GetVolumeID(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/generated.BlockStore/GetVolumeID", FullMethod: "/generated.VolumeSnapshotter/GetVolumeID",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BlockStoreServer).GetVolumeID(ctx, req.(*GetVolumeIDRequest)) return srv.(VolumeSnapshotterServer).GetVolumeID(ctx, req.(*GetVolumeIDRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _BlockStore_SetVolumeID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _VolumeSnapshotter_SetVolumeID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SetVolumeIDRequest) in := new(SetVolumeIDRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(BlockStoreServer).SetVolumeID(ctx, in) return srv.(VolumeSnapshotterServer).SetVolumeID(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/generated.BlockStore/SetVolumeID", FullMethod: "/generated.VolumeSnapshotter/SetVolumeID",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BlockStoreServer).SetVolumeID(ctx, req.(*SetVolumeIDRequest)) return srv.(VolumeSnapshotterServer).SetVolumeID(ctx, req.(*SetVolumeIDRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
var _BlockStore_serviceDesc = grpc.ServiceDesc{ var _VolumeSnapshotter_serviceDesc = grpc.ServiceDesc{
ServiceName: "generated.BlockStore", ServiceName: "generated.VolumeSnapshotter",
HandlerType: (*BlockStoreServer)(nil), HandlerType: (*VolumeSnapshotterServer)(nil),
Methods: []grpc.MethodDesc{ Methods: []grpc.MethodDesc{
{ {
MethodName: "Init", MethodName: "Init",
Handler: _BlockStore_Init_Handler, Handler: _VolumeSnapshotter_Init_Handler,
}, },
{ {
MethodName: "CreateVolumeFromSnapshot", MethodName: "CreateVolumeFromSnapshot",
Handler: _BlockStore_CreateVolumeFromSnapshot_Handler, Handler: _VolumeSnapshotter_CreateVolumeFromSnapshot_Handler,
}, },
{ {
MethodName: "GetVolumeInfo", MethodName: "GetVolumeInfo",
Handler: _BlockStore_GetVolumeInfo_Handler, Handler: _VolumeSnapshotter_GetVolumeInfo_Handler,
}, },
{ {
MethodName: "CreateSnapshot", MethodName: "CreateSnapshot",
Handler: _BlockStore_CreateSnapshot_Handler, Handler: _VolumeSnapshotter_CreateSnapshot_Handler,
}, },
{ {
MethodName: "DeleteSnapshot", MethodName: "DeleteSnapshot",
Handler: _BlockStore_DeleteSnapshot_Handler, Handler: _VolumeSnapshotter_DeleteSnapshot_Handler,
}, },
{ {
MethodName: "GetVolumeID", MethodName: "GetVolumeID",
Handler: _BlockStore_GetVolumeID_Handler, Handler: _VolumeSnapshotter_GetVolumeID_Handler,
}, },
{ {
MethodName: "SetVolumeID", MethodName: "SetVolumeID",
Handler: _BlockStore_SetVolumeID_Handler, Handler: _VolumeSnapshotter_SetVolumeID_Handler,
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "BlockStore.proto", Metadata: "VolumeSnapshotter.proto",
} }
func init() { proto.RegisterFile("BlockStore.proto", fileDescriptor1) } func init() { proto.RegisterFile("VolumeSnapshotter.proto", fileDescriptor5) }
var fileDescriptor1 = []byte{ var fileDescriptor5 = []byte{
// 527 bytes of a gzipped FileDescriptorProto // 525 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xd3, 0x4e, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xd3, 0x40,
0x10, 0x95, 0x63, 0xb7, 0xfa, 0x65, 0xd2, 0x5f, 0x15, 0x4d, 0xfe, 0xc8, 0xb2, 0x44, 0x30, 0x3e, 0x10, 0xd6, 0xc6, 0x6e, 0x45, 0x26, 0xa5, 0x0a, 0x93, 0x1f, 0x2c, 0x4b, 0x04, 0xe3, 0x53, 0xd4,
0x45, 0x3d, 0x44, 0x10, 0x0e, 0x54, 0x1c, 0x90, 0x0a, 0x2e, 0x28, 0xa2, 0x12, 0x92, 0x5d, 0x10, 0x43, 0x04, 0xe1, 0x40, 0xc5, 0x01, 0xa9, 0xc2, 0x05, 0x45, 0x54, 0x42, 0xb2, 0x0b, 0x42, 0x70,
0x82, 0x93, 0xa1, 0xd3, 0x34, 0xaa, 0xe3, 0x35, 0xde, 0x4d, 0xa5, 0x7c, 0x18, 0xee, 0x7c, 0x2c, 0x32, 0xea, 0x34, 0x8d, 0x48, 0x6c, 0xe3, 0xdd, 0x54, 0xca, 0xc3, 0xf0, 0x0c, 0xbc, 0x12, 0x8f,
0x3e, 0x0a, 0x8a, 0xbd, 0x49, 0x76, 0x93, 0x4d, 0xd3, 0x4b, 0x6f, 0x9e, 0x19, 0xcf, 0x9b, 0xf7, 0x82, 0x62, 0x6f, 0x92, 0xdd, 0x64, 0x53, 0xf7, 0xd2, 0x9b, 0x67, 0x66, 0xe7, 0x9b, 0x6f, 0x66,
0xc6, 0x6f, 0xd7, 0xd0, 0x7c, 0x9b, 0xb2, 0x9f, 0xb7, 0xb1, 0x60, 0x05, 0x0d, 0xf2, 0x82, 0x09, 0xbf, 0x59, 0xc3, 0xd3, 0xaf, 0xe9, 0x74, 0x3e, 0xa3, 0x28, 0x89, 0x33, 0x7e, 0x93, 0x0a, 0x41,
0x86, 0xf5, 0x31, 0x65, 0x54, 0x24, 0x82, 0xae, 0xbc, 0xa3, 0xf8, 0x26, 0x29, 0xe8, 0xaa, 0x2a, 0xf9, 0x20, 0xcb, 0x53, 0x91, 0x62, 0x7d, 0x4c, 0x09, 0xe5, 0xb1, 0xa0, 0x2b, 0xf7, 0x28, 0xba,
0x04, 0xbf, 0x2d, 0x68, 0xbd, 0x2b, 0x28, 0x11, 0xf4, 0x85, 0xa5, 0xb3, 0x29, 0x45, 0xf4, 0x6b, 0x89, 0x73, 0xba, 0x2a, 0x03, 0xfe, 0x1f, 0x06, 0xad, 0xf7, 0x39, 0xc5, 0x82, 0xca, 0xd4, 0x90,
0x46, 0x5c, 0x60, 0x17, 0x0e, 0xf3, 0x74, 0x36, 0x9e, 0x64, 0xae, 0xe5, 0x5b, 0xfd, 0x7a, 0x24, 0x7e, 0xcf, 0x89, 0x0b, 0xec, 0xc2, 0x61, 0x36, 0x9d, 0x8f, 0x27, 0x89, 0xc3, 0x3c, 0xd6, 0xaf,
0x23, 0xec, 0x01, 0xf0, 0x2c, 0xc9, 0xf9, 0x0d, 0x13, 0xa3, 0xd0, 0xad, 0x95, 0x35, 0x25, 0xb3, 0x87, 0xd2, 0xc2, 0x1e, 0x00, 0x97, 0xe8, 0xa3, 0xc0, 0xa9, 0x15, 0x31, 0xc5, 0xb3, 0x8c, 0xdf,
0xa8, 0xdf, 0x95, 0x40, 0x97, 0xf3, 0x9c, 0x5c, 0xbb, 0xaa, 0xaf, 0x33, 0xe8, 0xc1, 0x7f, 0x55, 0x16, 0x40, 0x97, 0x8b, 0x8c, 0x1c, 0xab, 0x8c, 0x6f, 0x3c, 0xe8, 0xc2, 0xa3, 0xd2, 0x3a, 0xfb,
0x74, 0xf6, 0xcd, 0x75, 0xca, 0xea, 0x2a, 0x46, 0x04, 0x67, 0xc2, 0x72, 0xee, 0x1e, 0xf8, 0x56, 0xee, 0xd8, 0x45, 0x74, 0x6d, 0x23, 0x82, 0x3d, 0x49, 0x33, 0xee, 0x1c, 0x78, 0xac, 0x6f, 0x85,
0xdf, 0x8e, 0xca, 0xe7, 0x60, 0x08, 0x6d, 0x9d, 0x1e, 0xcf, 0x59, 0xc6, 0x15, 0x9c, 0x51, 0x28, 0xc5, 0xb7, 0x3f, 0x84, 0xb6, 0x4e, 0x8f, 0x67, 0x69, 0xc2, 0x15, 0x9c, 0x51, 0x20, 0x19, 0xae,
0x19, 0xae, 0xe2, 0xe0, 0x1a, 0xda, 0x1f, 0x48, 0x54, 0x0d, 0xa3, 0xec, 0x9a, 0xed, 0xd3, 0xa4, 0x6d, 0xff, 0x1a, 0xda, 0x1f, 0x49, 0x94, 0x09, 0xa3, 0xe4, 0x3a, 0xad, 0xea, 0x49, 0xc5, 0xaa,
0x62, 0xd5, 0x74, 0x2c, 0x8d, 0xaf, 0xad, 0xf3, 0x0d, 0x3e, 0x42, 0x67, 0x63, 0x8e, 0x24, 0xa7, 0xe9, 0x58, 0x1a, 0x5f, 0x4b, 0xe7, 0xeb, 0x7f, 0x82, 0xce, 0x56, 0x1d, 0x49, 0x4e, 0x1f, 0x02,
0x2f, 0xc1, 0xda, 0x5a, 0xc2, 0x52, 0x68, 0x4d, 0x11, 0xfa, 0xd7, 0x82, 0x4e, 0xa5, 0x34, 0x96, 0xdb, 0x19, 0xc2, 0xaa, 0xd1, 0x9a, 0xd2, 0xe8, 0x3f, 0x06, 0x9d, 0xb2, 0xd3, 0xd5, 0xed, 0x3d,
0xdb, 0x7c, 0x24, 0xda, 0xf8, 0x06, 0x1c, 0x91, 0x8c, 0xb9, 0xeb, 0xf8, 0x76, 0xbf, 0x31, 0x3c, 0x10, 0x6d, 0x7c, 0x07, 0xb6, 0x88, 0xc7, 0xdc, 0xb1, 0x3d, 0xab, 0xdf, 0x18, 0x9e, 0x0c, 0xd6,
0x19, 0xac, 0xac, 0x31, 0x30, 0xce, 0x1f, 0x5c, 0x26, 0x63, 0x7e, 0x9e, 0x89, 0x62, 0x1e, 0x95, 0xd2, 0x18, 0x18, 0xeb, 0x0f, 0x2e, 0xe3, 0x31, 0x3f, 0x4f, 0x44, 0xbe, 0x08, 0x8b, 0x3c, 0xf7,
0x7d, 0xde, 0x2b, 0xa8, 0xaf, 0x52, 0xd8, 0x04, 0xfb, 0x96, 0xe6, 0x92, 0xd9, 0xe2, 0x11, 0xdb, 0x0d, 0xd4, 0xd7, 0x2e, 0x6c, 0x82, 0xf5, 0x8b, 0x16, 0x92, 0xd9, 0xf2, 0x13, 0xdb, 0x70, 0x70,
0x70, 0x70, 0x97, 0xa4, 0x33, 0x92, 0x9c, 0xaa, 0xe0, 0x75, 0xed, 0xd4, 0x0a, 0x4e, 0xa1, 0xbb, 0x1b, 0x4f, 0xe7, 0x24, 0x39, 0x95, 0xc6, 0xdb, 0xda, 0x29, 0xf3, 0x4f, 0xa1, 0xbb, 0x5d, 0x61,
0x39, 0x61, 0xbd, 0x30, 0xc5, 0x55, 0xd6, 0xa6, 0xab, 0x82, 0x4f, 0xd0, 0x09, 0x29, 0xa5, 0x87, 0x33, 0x30, 0x45, 0x55, 0x6c, 0x5b, 0x55, 0xfe, 0x67, 0xe8, 0x04, 0x34, 0xa5, 0xfb, 0xcf, 0xa6,
0xef, 0x66, 0x8f, 0x4d, 0x83, 0xaf, 0x80, 0xeb, 0x4f, 0x17, 0xee, 0x43, 0x3b, 0x81, 0x66, 0x4e, 0x42, 0xa6, 0xfe, 0x37, 0xc0, 0xcd, 0xd5, 0x05, 0x55, 0x68, 0x27, 0xd0, 0xcc, 0x28, 0xe7, 0x13,
0x05, 0x9f, 0x70, 0x41, 0x99, 0x6c, 0x2a, 0x31, 0x8f, 0xa2, 0xad, 0x7c, 0xf0, 0x02, 0x5a, 0x1a, 0x2e, 0x28, 0x91, 0x49, 0x05, 0xe6, 0x51, 0xb8, 0xe3, 0xf7, 0x5f, 0x41, 0x4b, 0x43, 0xbe, 0x87,
0xf2, 0x03, 0xfc, 0x2a, 0x00, 0xe3, 0x47, 0x21, 0xa3, 0x4d, 0xb5, 0x37, 0xa6, 0x9e, 0x41, 0x2b, 0x5e, 0x05, 0x60, 0xf4, 0x20, 0x64, 0xb4, 0xaa, 0xd6, 0x56, 0xd5, 0x33, 0x68, 0x45, 0x06, 0xa2,
0x36, 0x10, 0x35, 0xc1, 0x5b, 0x66, 0xf8, 0xe1, 0x1f, 0x07, 0x60, 0x7d, 0xd5, 0xe0, 0x73, 0x70, 0x26, 0x78, 0x66, 0x86, 0x1f, 0xfe, 0xb5, 0xe1, 0xc9, 0xce, 0x8b, 0x83, 0x2f, 0xc1, 0x1e, 0x25,
0x46, 0xd9, 0x44, 0x60, 0x57, 0xb1, 0xd4, 0x22, 0x21, 0x15, 0x79, 0x4d, 0x25, 0x7f, 0x3e, 0xcd, 0x13, 0x81, 0x5d, 0x45, 0x59, 0x4b, 0x87, 0x6c, 0xcc, 0x6d, 0x2a, 0xfe, 0xf3, 0x59, 0x26, 0x16,
0xc5, 0x1c, 0xbf, 0x83, 0xab, 0x9e, 0xee, 0xf7, 0x05, 0x9b, 0x2e, 0xbf, 0x30, 0xf6, 0xb6, 0x8c, 0xf8, 0x03, 0x1c, 0x75, 0xc9, 0x3f, 0xe4, 0xe9, 0x6c, 0x05, 0x88, 0xbd, 0x1d, 0x7d, 0x6a, 0x0f,
0xa9, 0xdd, 0x50, 0xde, 0xd3, 0x9d, 0x75, 0xa9, 0x24, 0x82, 0xff, 0xb5, 0xe3, 0x89, 0x6a, 0x87, 0x95, 0xfb, 0x7c, 0x6f, 0x5c, 0x36, 0x14, 0xc2, 0x63, 0x6d, 0x4b, 0x51, 0xcd, 0x30, 0xbd, 0x13,
0xe9, 0x82, 0xf0, 0xfc, 0xdd, 0x2f, 0x48, 0xcc, 0xcf, 0x70, 0xac, 0x5b, 0x18, 0xfd, 0x7d, 0xe7, 0xae, 0xb7, 0xff, 0x80, 0xc4, 0xfc, 0x02, 0xc7, 0xba, 0x92, 0xd1, 0xab, 0x5a, 0x23, 0xf7, 0xc5,
0xc7, 0x7b, 0x76, 0xcf, 0x1b, 0x12, 0x36, 0x84, 0x63, 0xdd, 0xdf, 0x1a, 0xac, 0xd1, 0xfa, 0x86, 0x1d, 0x27, 0x24, 0x6c, 0x00, 0xc7, 0xba, 0xcc, 0x35, 0x58, 0xe3, 0x06, 0x18, 0xa6, 0x79, 0x01,
0x6d, 0x5e, 0x40, 0x43, 0xb1, 0x1e, 0x3e, 0x31, 0xaa, 0x59, 0xfa, 0xcb, 0xeb, 0xed, 0x2a, 0x4b, 0x0d, 0x45, 0x81, 0xf8, 0xcc, 0xd8, 0xcd, 0x4a, 0x66, 0x6e, 0x6f, 0x5f, 0x58, 0x72, 0xba, 0x80,
0x4e, 0x17, 0xd0, 0x88, 0x77, 0xa0, 0xc5, 0xf7, 0xa3, 0x19, 0x6c, 0xf5, 0xe3, 0xb0, 0xfc, 0xdd, 0x46, 0xb4, 0x07, 0x2d, 0xba, 0x1b, 0xcd, 0xa0, 0xae, 0x9f, 0x87, 0xc5, 0x5f, 0xe7, 0xf5, 0xff,
0xbc, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0xae, 0x59, 0x98, 0xf2, 0x9b, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x29, 0x03, 0xe3, 0x22, 0xa9, 0x06, 0x00, 0x00,
} }

View File

@ -78,16 +78,16 @@ func (_m *Manager) GetBackupItemActions() ([]velero.BackupItemAction, error) {
return r0, r1 return r0, r1
} }
// GetBlockStore provides a mock function with given fields: name // GetVolumeSnapshotter provides a mock function with given fields: name
func (_m *Manager) GetBlockStore(name string) (velero.BlockStore, error) { func (_m *Manager) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error) {
ret := _m.Called(name) ret := _m.Called(name)
var r0 velero.BlockStore var r0 velero.VolumeSnapshotter
if rf, ok := ret.Get(0).(func(string) velero.BlockStore); ok { if rf, ok := ret.Get(0).(func(string) velero.VolumeSnapshotter); ok {
r0 = rf(name) r0 = rf(name)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(velero.BlockStore) r0 = ret.Get(0).(velero.VolumeSnapshotter)
} }
} }

View File

@ -61,7 +61,7 @@ message SetVolumeIDResponse {
bytes persistentVolume = 1; bytes persistentVolume = 1;
} }
service BlockStore { service VolumeSnapshotter {
rpc Init(InitRequest) returns (Empty); rpc Init(InitRequest) returns (Empty);
rpc CreateVolumeFromSnapshot(CreateVolumeRequest) returns (CreateVolumeResponse); rpc CreateVolumeFromSnapshot(CreateVolumeRequest) returns (CreateVolumeResponse);
rpc GetVolumeInfo(GetVolumeInfoRequest) returns (GetVolumeInfoResponse); rpc GetVolumeInfo(GetVolumeInfoRequest) returns (GetVolumeInfoResponse);

View File

@ -1,5 +1,5 @@
/* /*
Copyright 2017 the Velero contributors. Copyright 2017, 2019 the Velero contributors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -20,15 +20,16 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
) )
// BlockStore exposes basic block-storage operations required // VolumeSnapshotter defines the operations needed by Velero to
// by Velero. // take snapshots of persistent volumes during backup, and to restore
type BlockStore interface { // persistent volumes from snapshots during restore.
// Init prepares the BlockStore for usage using the provided map of type VolumeSnapshotter interface {
// configuration key-value pairs. It returns an error if the BlockStore // Init prepares the VolumeSnapshotter for usage using the provided map of
// configuration key-value pairs. It returns an error if the VolumeSnapshotter
// cannot be initialized from the provided config. // cannot be initialized from the provided config.
Init(config map[string]string) error Init(config map[string]string) error
// CreateVolumeFromSnapshot creates a new block volume in the specified // CreateVolumeFromSnapshot creates a new volume in the specified
// availability zone, initialized from the provided snapshot, // availability zone, initialized from the provided snapshot,
// and with the specified type and IOPS (if using provisioned IOPS). // and with the specified type and IOPS (if using provisioned IOPS).
CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error)
@ -40,10 +41,10 @@ type BlockStore interface {
SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)
// GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for // GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for
// the specified block volume in the given availability zone. // the specified volume in the given availability zone.
GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)
// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided // CreateSnapshot creates a snapshot of the specified volume, and applies the provided
// set of tags to the snapshot. // set of tags to the snapshot.
CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error)

View File

@ -38,7 +38,7 @@ type pvRestorer struct {
snapshotVolumes *bool snapshotVolumes *bool
restorePVs *bool restorePVs *bool
volumeSnapshots []*volume.Snapshot volumeSnapshots []*volume.Snapshot
blockStoreGetter BlockStoreGetter volumeSnapshotterGetter VolumeSnapshotterGetter
snapshotLocationLister listers.VolumeSnapshotLocationLister snapshotLocationLister listers.VolumeSnapshotLocationLister
} }
@ -83,23 +83,23 @@ func (r *pvRestorer) executePVAction(obj *unstructured.Unstructured) (*unstructu
return obj, nil return obj, nil
} }
blockStore, err := r.blockStoreGetter.GetBlockStore(snapshotInfo.location.Spec.Provider) volumeSnapshotter, err := r.volumeSnapshotterGetter.GetVolumeSnapshotter(snapshotInfo.location.Spec.Provider)
if err != nil { if err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)
} }
if err := blockStore.Init(snapshotInfo.location.Spec.Config); err != nil { if err := volumeSnapshotter.Init(snapshotInfo.location.Spec.Config); err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)
} }
volumeID, err := blockStore.CreateVolumeFromSnapshot(snapshotInfo.providerSnapshotID, snapshotInfo.volumeType, snapshotInfo.volumeAZ, snapshotInfo.volumeIOPS) volumeID, err := volumeSnapshotter.CreateVolumeFromSnapshot(snapshotInfo.providerSnapshotID, snapshotInfo.volumeType, snapshotInfo.volumeAZ, snapshotInfo.volumeIOPS)
if err != nil { if err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)
} }
log.WithField("providerSnapshotID", snapshotInfo.providerSnapshotID).Info("successfully restored persistent volume from snapshot") log.WithField("providerSnapshotID", snapshotInfo.providerSnapshotID).Info("successfully restored persistent volume from snapshot")
updated1, err := blockStore.SetVolumeID(obj, volumeID) updated1, err := volumeSnapshotter.SetVolumeID(obj, volumeID)
if err != nil { if err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)
} }

View File

@ -229,9 +229,9 @@ func TestExecutePVAction_SnapshotRestores(t *testing.T) {
for _, tc := range tests { for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
var ( var (
blockStore = new(cloudprovidermocks.BlockStore) volumeSnapshotter = new(cloudprovidermocks.VolumeSnapshotter)
blockStoreGetter = providerToBlockStoreMap(map[string]velero.BlockStore{ volumeSnapshotterGetter = providerToVolumeSnapshotterMap(map[string]velero.VolumeSnapshotter{
tc.expectedProvider: blockStore, tc.expectedProvider: volumeSnapshotter,
}) })
locationsInformer = informers.NewSharedInformerFactory(fake.NewSimpleClientset(), 0).Velero().V1().VolumeSnapshotLocations() locationsInformer = informers.NewSharedInformerFactory(fake.NewSimpleClientset(), 0).Velero().V1().VolumeSnapshotLocations()
) )
@ -245,26 +245,26 @@ func TestExecutePVAction_SnapshotRestores(t *testing.T) {
backup: tc.backup, backup: tc.backup,
volumeSnapshots: tc.volumeSnapshots, volumeSnapshots: tc.volumeSnapshots,
snapshotLocationLister: locationsInformer.Lister(), snapshotLocationLister: locationsInformer.Lister(),
blockStoreGetter: blockStoreGetter, volumeSnapshotterGetter: volumeSnapshotterGetter,
} }
blockStore.On("Init", mock.Anything).Return(nil) volumeSnapshotter.On("Init", mock.Anything).Return(nil)
blockStore.On("CreateVolumeFromSnapshot", tc.expectedSnapshotID, tc.expectedVolumeType, tc.expectedVolumeAZ, tc.expectedVolumeIOPS).Return("volume-1", nil) volumeSnapshotter.On("CreateVolumeFromSnapshot", tc.expectedSnapshotID, tc.expectedVolumeType, tc.expectedVolumeAZ, tc.expectedVolumeIOPS).Return("volume-1", nil)
blockStore.On("SetVolumeID", tc.obj, "volume-1").Return(tc.obj, nil) volumeSnapshotter.On("SetVolumeID", tc.obj, "volume-1").Return(tc.obj, nil)
_, err := r.executePVAction(tc.obj) _, err := r.executePVAction(tc.obj)
assert.NoError(t, err) assert.NoError(t, err)
blockStore.AssertExpectations(t) volumeSnapshotter.AssertExpectations(t)
}) })
} }
} }
type providerToBlockStoreMap map[string]velero.BlockStore type providerToVolumeSnapshotterMap map[string]velero.VolumeSnapshotter
func (g providerToBlockStoreMap) GetBlockStore(provider string) (velero.BlockStore, error) { func (g providerToVolumeSnapshotterMap) GetVolumeSnapshotter(provider string) (velero.VolumeSnapshotter, error) {
if bs, ok := g[provider]; !ok { if bs, ok := g[provider]; !ok {
return nil, errors.New("block store not found for provider") return nil, errors.New("volume snapshotter not found for provider")
} else { } else {
return bs, nil return bs, nil
} }

View File

@ -56,8 +56,8 @@ import (
"github.com/heptio/velero/pkg/volume" "github.com/heptio/velero/pkg/volume"
) )
type BlockStoreGetter interface { type VolumeSnapshotterGetter interface {
GetBlockStore(name string) (velero.BlockStore, error) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error)
} }
// Restorer knows how to restore a backup. // Restorer knows how to restore a backup.
@ -70,7 +70,7 @@ type Restorer interface {
backupReader io.Reader, backupReader io.Reader,
actions []velero.RestoreItemAction, actions []velero.RestoreItemAction,
snapshotLocationLister listers.VolumeSnapshotLocationLister, snapshotLocationLister listers.VolumeSnapshotLocationLister,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) (api.RestoreResult, api.RestoreResult) ) (api.RestoreResult, api.RestoreResult)
} }
@ -180,7 +180,7 @@ func (kr *kubernetesRestorer) Restore(
backupReader io.Reader, backupReader io.Reader,
actions []velero.RestoreItemAction, actions []velero.RestoreItemAction,
snapshotLocationLister listers.VolumeSnapshotLocationLister, snapshotLocationLister listers.VolumeSnapshotLocationLister,
blockStoreGetter BlockStoreGetter, volumeSnapshotterGetter VolumeSnapshotterGetter,
) (api.RestoreResult, api.RestoreResult) { ) (api.RestoreResult, api.RestoreResult) {
// metav1.LabelSelectorAsSelector converts a nil LabelSelector to a // metav1.LabelSelectorAsSelector converts a nil LabelSelector to a
// Nothing Selector, i.e. a selector that matches nothing. We want // Nothing Selector, i.e. a selector that matches nothing. We want
@ -235,7 +235,7 @@ func (kr *kubernetesRestorer) Restore(
snapshotVolumes: backup.Spec.SnapshotVolumes, snapshotVolumes: backup.Spec.SnapshotVolumes,
restorePVs: restore.Spec.RestorePVs, restorePVs: restore.Spec.RestorePVs,
volumeSnapshots: volumeSnapshots, volumeSnapshots: volumeSnapshots,
blockStoreGetter: blockStoreGetter, volumeSnapshotterGetter: volumeSnapshotterGetter,
snapshotLocationLister: snapshotLocationLister, snapshotLocationLister: snapshotLocationLister,
} }
@ -250,7 +250,7 @@ func (kr *kubernetesRestorer) Restore(
fileSystem: kr.fileSystem, fileSystem: kr.fileSystem,
namespaceClient: kr.namespaceClient, namespaceClient: kr.namespaceClient,
actions: resolvedActions, actions: resolvedActions,
blockStoreGetter: blockStoreGetter, volumeSnapshotterGetter: volumeSnapshotterGetter,
resticRestorer: resticRestorer, resticRestorer: resticRestorer,
pvsToProvision: sets.NewString(), pvsToProvision: sets.NewString(),
pvRestorer: pvRestorer, pvRestorer: pvRestorer,
@ -337,7 +337,7 @@ type context struct {
fileSystem filesystem.Interface fileSystem filesystem.Interface
namespaceClient corev1.NamespaceInterface namespaceClient corev1.NamespaceInterface
actions []resolvedAction actions []resolvedAction
blockStoreGetter BlockStoreGetter volumeSnapshotterGetter VolumeSnapshotterGetter
resticRestorer restic.Restorer resticRestorer restic.Restorer
globalWaitGroup velerosync.ErrorGroup globalWaitGroup velerosync.ErrorGroup
pvsToProvision sets.String pvsToProvision sets.String

View File

@ -646,7 +646,7 @@ func TestRestoreResourceForNamespace(t *testing.T) {
log: velerotest.NewLogger(), log: velerotest.NewLogger(),
pvRestorer: &pvRestorer{ pvRestorer: &pvRestorer{
logger: logging.DefaultLogger(logrus.DebugLevel), logger: logging.DefaultLogger(logrus.DebugLevel),
blockStoreGetter: &fakeBlockStoreGetter{ volumeSnapshotterGetter: &fakeVolumeSnapshotterGetter{
volumeMap: map[api.VolumeBackupInfo]string{{SnapshotID: "snap-1"}: "volume-1"}, volumeMap: map[api.VolumeBackupInfo]string{{SnapshotID: "snap-1"}: "volume-1"},
volumeID: "volume-1", volumeID: "volume-1",
}, },
@ -1799,20 +1799,20 @@ type fakeAction struct {
resource string resource string
} }
type fakeBlockStoreGetter struct { type fakeVolumeSnapshotterGetter struct {
fakeBlockStore *velerotest.FakeBlockStore fakeVolumeSnapshotter *velerotest.FakeVolumeSnapshotter
volumeMap map[api.VolumeBackupInfo]string volumeMap map[api.VolumeBackupInfo]string
volumeID string volumeID string
} }
func (r *fakeBlockStoreGetter) GetBlockStore(provider string) (velero.BlockStore, error) { func (r *fakeVolumeSnapshotterGetter) GetVolumeSnapshotter(provider string) (velero.VolumeSnapshotter, error) {
if r.fakeBlockStore == nil { if r.fakeVolumeSnapshotter == nil {
r.fakeBlockStore = &velerotest.FakeBlockStore{ r.fakeVolumeSnapshotter = &velerotest.FakeVolumeSnapshotter{
RestorableVolumes: r.volumeMap, RestorableVolumes: r.volumeMap,
VolumeID: r.volumeID, VolumeID: r.volumeID,
} }
} }
return r.fakeBlockStore, nil return r.fakeVolumeSnapshotter, nil
} }
func newFakeAction(resource string) *fakeAction { func newFakeAction(resource string) *fakeAction {

View File

@ -25,7 +25,7 @@ import (
api "github.com/heptio/velero/pkg/apis/velero/v1" api "github.com/heptio/velero/pkg/apis/velero/v1"
) )
type FakeBlockStore struct { type FakeVolumeSnapshotter struct {
// SnapshotID->VolumeID // SnapshotID->VolumeID
SnapshotsTaken sets.String SnapshotsTaken sets.String
@ -41,11 +41,11 @@ type FakeBlockStore struct {
Error error Error error
} }
func (bs *FakeBlockStore) Init(config map[string]string) error { func (bs *FakeVolumeSnapshotter) Init(config map[string]string) error {
return nil return nil
} }
func (bs *FakeBlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) { func (bs *FakeVolumeSnapshotter) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
if bs.Error != nil { if bs.Error != nil {
return "", bs.Error return "", bs.Error
} }
@ -62,7 +62,7 @@ func (bs *FakeBlockStore) CreateSnapshot(volumeID, volumeAZ string, tags map[str
return bs.SnapshottableVolumes[volumeID].SnapshotID, nil return bs.SnapshottableVolumes[volumeID].SnapshotID, nil
} }
func (bs *FakeBlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error) { func (bs *FakeVolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (string, error) {
if bs.Error != nil { if bs.Error != nil {
return "", bs.Error return "", bs.Error
} }
@ -77,7 +77,7 @@ func (bs *FakeBlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volum
return bs.RestorableVolumes[key], nil return bs.RestorableVolumes[key], nil
} }
func (bs *FakeBlockStore) DeleteSnapshot(snapshotID string) error { func (bs *FakeVolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
if bs.Error != nil { if bs.Error != nil {
return bs.Error return bs.Error
} }
@ -91,7 +91,7 @@ func (bs *FakeBlockStore) DeleteSnapshot(snapshotID string) error {
return nil return nil
} }
func (bs *FakeBlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) { func (bs *FakeVolumeSnapshotter) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
if bs.Error != nil { if bs.Error != nil {
return "", nil, bs.Error return "", nil, bs.Error
} }
@ -103,11 +103,11 @@ func (bs *FakeBlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int
} }
} }
func (bs *FakeBlockStore) GetVolumeID(pv runtime.Unstructured) (string, error) { func (bs *FakeVolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error) {
return bs.VolumeID, nil return bs.VolumeID, nil
} }
func (bs *FakeBlockStore) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) { func (bs *FakeVolumeSnapshotter) SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error) {
bs.VolumeIDSet = volumeID bs.VolumeIDSet = volumeID
return pv, bs.Error return pv, bs.Error
} }