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:
- **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
- **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 {
// Backup takes a backup using the specification in the api.Backup and writes backup and log data
// 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.
@ -209,13 +209,13 @@ func getResourceHook(hookSpec api.BackupResourceHookSpec, discoveryHelper discov
return h, nil
}
type BlockStoreGetter interface {
GetBlockStore(name string) (velero.BlockStore, error)
type VolumeSnapshotterGetter interface {
GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error)
}
// 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.
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)
defer gzippedData.Close()
@ -280,7 +280,7 @@ func (kb *kubernetesBackupper) Backup(logger logrus.FieldLogger, backupRequest *
tw,
resticBackupper,
newPVCSnapshotTracker(),
blockStoreGetter,
volumeSnapshotterGetter,
)
var errs []error

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ type itemBackupperFactory interface {
discoveryHelper discovery.Helper,
resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter,
volumeSnapshotterGetter VolumeSnapshotterGetter,
) ItemBackupper
}
@ -67,17 +67,17 @@ func (f *defaultItemBackupperFactory) newItemBackupper(
discoveryHelper discovery.Helper,
resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter,
volumeSnapshotterGetter VolumeSnapshotterGetter,
) ItemBackupper {
ib := &defaultItemBackupper{
backupRequest: backupRequest,
backedUpItems: backedUpItems,
tarWriter: tarWriter,
dynamicFactory: dynamicFactory,
discoveryHelper: discoveryHelper,
resticBackupper: resticBackupper,
resticSnapshotTracker: resticSnapshotTracker,
blockStoreGetter: blockStoreGetter,
backupRequest: backupRequest,
backedUpItems: backedUpItems,
tarWriter: tarWriter,
dynamicFactory: dynamicFactory,
discoveryHelper: discoveryHelper,
resticBackupper: resticBackupper,
resticSnapshotTracker: resticSnapshotTracker,
volumeSnapshotterGetter: volumeSnapshotterGetter,
itemHookHandler: &defaultItemHookHandler{
podCommandExecutor: podCommandExecutor,
@ -95,18 +95,18 @@ type ItemBackupper interface {
}
type defaultItemBackupper struct {
backupRequest *Request
backedUpItems map[itemKey]struct{}
tarWriter tarWriter
dynamicFactory client.DynamicFactory
discoveryHelper discovery.Helper
resticBackupper restic.Backupper
resticSnapshotTracker *pvcSnapshotTracker
blockStoreGetter BlockStoreGetter
backupRequest *Request
backedUpItems map[itemKey]struct{}
tarWriter tarWriter
dynamicFactory client.DynamicFactory
discoveryHelper discovery.Helper
resticBackupper restic.Backupper
resticSnapshotTracker *pvcSnapshotTracker
volumeSnapshotterGetter VolumeSnapshotterGetter
itemHookHandler itemHookHandler
additionalItemBackupper ItemBackupper
snapshotLocationBlockStores map[string]velero.BlockStore
itemHookHandler itemHookHandler
additionalItemBackupper ItemBackupper
snapshotLocationVolumeSnapshotters map[string]velero.VolumeSnapshotter
}
// 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
}
// 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.
func (ib *defaultItemBackupper) blockStore(snapshotLocation *api.VolumeSnapshotLocation) (velero.BlockStore, error) {
if bs, ok := ib.snapshotLocationBlockStores[snapshotLocation.Name]; ok {
func (ib *defaultItemBackupper) volumeSnapshotter(snapshotLocation *api.VolumeSnapshotLocation) (velero.VolumeSnapshotter, error) {
if bs, ok := ib.snapshotLocationVolumeSnapshotters[snapshotLocation.Name]; ok {
return bs, nil
}
bs, err := ib.blockStoreGetter.GetBlockStore(snapshotLocation.Spec.Provider)
bs, err := ib.volumeSnapshotterGetter.GetVolumeSnapshotter(snapshotLocation.Spec.Provider)
if err != nil {
return nil, err
}
@ -359,10 +359,10 @@ func (ib *defaultItemBackupper) blockStore(snapshotLocation *api.VolumeSnapshotL
return nil, err
}
if ib.snapshotLocationBlockStores == nil {
ib.snapshotLocationBlockStores = make(map[string]velero.BlockStore)
if ib.snapshotLocationVolumeSnapshotters == nil {
ib.snapshotLocationVolumeSnapshotters = make(map[string]velero.VolumeSnapshotter)
}
ib.snapshotLocationBlockStores[snapshotLocation.Name] = bs
ib.snapshotLocationVolumeSnapshotters[snapshotLocation.Name] = bs
return bs, nil
}
@ -405,15 +405,15 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
var (
volumeID, location string
blockStore velero.BlockStore
volumeSnapshotter velero.VolumeSnapshotter
)
for _, snapshotLocation := range ib.backupRequest.SnapshotLocations {
log := log.WithField("volumeSnapshotLocation", snapshotLocation.Name)
bs, err := ib.blockStore(snapshotLocation)
bs, err := ib.volumeSnapshotter(snapshotLocation)
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
}
@ -422,17 +422,17 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
continue
}
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
}
log.Infof("Got volume ID for persistent volume")
blockStore = bs
volumeSnapshotter = bs
location = snapshotLocation.Name
break
}
if blockStore == nil {
if volumeSnapshotter == nil {
log.Info("PersistentVolume is not a supported volume type for snapshots, skipping.")
return nil
}
@ -445,7 +445,7 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
}
log.Info("Getting volume information")
volumeType, iops, err := blockStore.GetVolumeInfo(volumeID, pvFailureDomainZone)
volumeType, iops, err := volumeSnapshotter.GetVolumeInfo(volumeID, pvFailureDomainZone)
if err != nil {
log.WithError(err).Error("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)
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 {
log.WithError(err).Error("error creating snapshot")
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"),
},
{
name: "takePVSnapshot is not invoked for PVs when blockStore == nil",
name: "takePVSnapshot is not invoked for PVs when volumeSnapshotter == nil",
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"}}}`,
expectError: false,
@ -293,7 +293,7 @@ func TestBackupItemNoSkips(t *testing.T) {
groupResource: "persistentvolumes",
},
{
name: "takePVSnapshot is invoked for PVs when blockStore != nil",
name: "takePVSnapshot is invoked for PVs when volumeSnapshotter != nil",
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"}}}`,
expectError: false,
@ -312,7 +312,7 @@ func TestBackupItemNoSkips(t *testing.T) {
expectExcluded: false,
expectedTarHeaderName: "resources/persistentvolumes/cluster/mypv.json",
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.
snapshottableVolumes: map[string]v1.VolumeBackupInfo{},
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)
blockStoreGetter := &blockStoreGetter{}
volumeSnapshotterGetter := &volumeSnapshotterGetter{}
b := (&defaultItemBackupperFactory{}).newItemBackupper(
backup,
@ -424,18 +424,18 @@ func TestBackupItemNoSkips(t *testing.T) {
discoveryHelper,
nil, // restic backupper
newPVCSnapshotTracker(),
blockStoreGetter,
volumeSnapshotterGetter,
).(*defaultItemBackupper)
var blockStore *velerotest.FakeBlockStore
var volumeSnapshotter *velerotest.FakeVolumeSnapshotter
if test.snapshottableVolumes != nil {
blockStore = &velerotest.FakeBlockStore{
volumeSnapshotter = &velerotest.FakeVolumeSnapshotter{
SnapshottableVolumes: test.snapshottableVolumes,
VolumeID: "vol-abc123",
Error: test.snapshotError,
}
blockStoreGetter.blockStore = blockStore
volumeSnapshotterGetter.volumeSnapshotter = volumeSnapshotter
}
if test.trackedPVCs != nil {
@ -523,7 +523,7 @@ func TestBackupItemNoSkips(t *testing.T) {
}
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 {
@ -547,13 +547,13 @@ func TestBackupItemNoSkips(t *testing.T) {
}
}
type blockStoreGetter struct {
blockStore velero.BlockStore
type volumeSnapshotterGetter struct {
volumeSnapshotter velero.VolumeSnapshotter
}
func (b *blockStoreGetter) GetBlockStore(name string) (velero.BlockStore, error) {
if b.blockStore != nil {
return b.blockStore, nil
func (b *volumeSnapshotterGetter) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error) {
if b.volumeSnapshotter != nil {
return b.volumeSnapshotter, nil
}
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,
VolumeID: test.expectedVolumeID,
}
@ -797,7 +797,7 @@ func TestTakePVSnapshot(t *testing.T) {
Backup: backup,
SnapshotLocations: []*v1.VolumeSnapshotLocation{new(v1.VolumeSnapshotLocation)},
},
blockStoreGetter: &blockStoreGetter{blockStore: blockStore},
volumeSnapshotterGetter: &volumeSnapshotterGetter{volumeSnapshotter: volumeSnapshotter},
}
pv, err := velerotest.GetAsMap(test.pv)
@ -823,13 +823,13 @@ func TestTakePVSnapshot(t *testing.T) {
}
// 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 {
require.Len(t, ib.backupRequest.VolumeSnapshots, 1)
snapshot := ib.backupRequest.VolumeSnapshots[0]
snapshotID, _ := blockStore.SnapshotsTaken.PopAny()
snapshotID, _ := volumeSnapshotter.SnapshotsTaken.PopAny()
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].Iops, snapshot.Spec.VolumeIOPS)

View File

@ -46,7 +46,7 @@ type resourceBackupperFactory interface {
tarWriter tarWriter,
resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter,
volumeSnapshotterGetter VolumeSnapshotterGetter,
) resourceBackupper
}
@ -63,20 +63,20 @@ func (f *defaultResourceBackupperFactory) newResourceBackupper(
tarWriter tarWriter,
resticBackupper restic.Backupper,
resticSnapshotTracker *pvcSnapshotTracker,
blockStoreGetter BlockStoreGetter,
volumeSnapshotterGetter VolumeSnapshotterGetter,
) resourceBackupper {
return &defaultResourceBackupper{
log: log,
backupRequest: backupRequest,
dynamicFactory: dynamicFactory,
discoveryHelper: discoveryHelper,
backedUpItems: backedUpItems,
cohabitatingResources: cohabitatingResources,
podCommandExecutor: podCommandExecutor,
tarWriter: tarWriter,
resticBackupper: resticBackupper,
resticSnapshotTracker: resticSnapshotTracker,
blockStoreGetter: blockStoreGetter,
log: log,
backupRequest: backupRequest,
dynamicFactory: dynamicFactory,
discoveryHelper: discoveryHelper,
backedUpItems: backedUpItems,
cohabitatingResources: cohabitatingResources,
podCommandExecutor: podCommandExecutor,
tarWriter: tarWriter,
resticBackupper: resticBackupper,
resticSnapshotTracker: resticSnapshotTracker,
volumeSnapshotterGetter: volumeSnapshotterGetter,
itemBackupperFactory: &defaultItemBackupperFactory{},
}
@ -87,18 +87,18 @@ type resourceBackupper interface {
}
type defaultResourceBackupper struct {
log logrus.FieldLogger
backupRequest *Request
dynamicFactory client.DynamicFactory
discoveryHelper discovery.Helper
backedUpItems map[itemKey]struct{}
cohabitatingResources map[string]*cohabitatingResource
podCommandExecutor podexec.PodCommandExecutor
tarWriter tarWriter
resticBackupper restic.Backupper
resticSnapshotTracker *pvcSnapshotTracker
itemBackupperFactory itemBackupperFactory
blockStoreGetter BlockStoreGetter
log logrus.FieldLogger
backupRequest *Request
dynamicFactory client.DynamicFactory
discoveryHelper discovery.Helper
backedUpItems map[itemKey]struct{}
cohabitatingResources map[string]*cohabitatingResource
podCommandExecutor podexec.PodCommandExecutor
tarWriter tarWriter
resticBackupper restic.Backupper
resticSnapshotTracker *pvcSnapshotTracker
itemBackupperFactory itemBackupperFactory
volumeSnapshotterGetter VolumeSnapshotterGetter
}
// backupResource backs up all the objects for a given group-version-resource.
@ -169,7 +169,7 @@ func (rb *defaultResourceBackupper) backupResource(
rb.discoveryHelper,
rb.resticBackupper,
rb.resticSnapshotTracker,
rb.blockStoreGetter,
rb.volumeSnapshotterGetter,
)
namespacesToList := getNamespacesToList(rb.backupRequest.NamespaceIncludesExcludes)

View File

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

View File

@ -41,7 +41,7 @@ const regionKey = "region"
// from snapshot.
var iopsVolumeTypes = sets.NewString("io1")
type BlockStore struct {
type VolumeSnapshotter struct {
log logrus.FieldLogger
ec2 *ec2.EC2
}
@ -59,11 +59,11 @@ func getSession(config *aws.Config) (*session.Session, error) {
return sess, nil
}
func NewBlockStore(logger logrus.FieldLogger) *BlockStore {
return &BlockStore{log: logger}
func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
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]
if region == "" {
return errors.Errorf("missing %s in aws configuration", regionKey)
@ -81,7 +81,7 @@ func (b *BlockStore) Init(config map[string]string) error {
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
snapReq := &ec2.DescribeSnapshotsInput{
SnapshotIds: []*string{&snapshotID},
@ -123,7 +123,7 @@ func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ s
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)
if err != nil {
return "", nil, err
@ -145,7 +145,7 @@ func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, e
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{
VolumeIds: []*string{&volumeID},
}
@ -161,7 +161,7 @@ func (b *BlockStore) describeVolume(volumeID string) (*ec2.Volume, error) {
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
volumeInfo, err := b.describeVolume(volumeID)
if err != nil {
@ -233,7 +233,7 @@ func ec2Tag(key, val string) *ec2.Tag {
return &ec2.Tag{Key: &key, Value: &val}
}
func (b *BlockStore) DeleteSnapshot(snapshotID string) error {
func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
req := &ec2.DeleteSnapshotInput{
SnapshotId: &snapshotID,
}
@ -255,7 +255,7 @@ func (b *BlockStore) DeleteSnapshot(snapshotID string) error {
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)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
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
}
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)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return nil, errors.WithStack(err)

View File

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

View File

@ -45,7 +45,7 @@ const (
disksResource = "disks"
)
type BlockStore struct {
type VolumeSnapshotter struct {
log logrus.FieldLogger
disks *disk.DisksClient
snaps *disk.SnapshotsClient
@ -65,11 +65,11 @@ func (si *snapshotIdentifier) String() string {
return getComputeResourceName(si.subscription, si.resourceGroup, snapshotsResource, si.name)
}
func NewBlockStore(logger logrus.FieldLogger) *BlockStore {
return &BlockStore{log: logger}
func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
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
envVars, err := getRequiredValues(os.Getenv, tenantIDEnvVar, clientIDEnvVar, clientSecretEnvVar, subscriptionIDEnvVar, resourceGroupEnvVar)
if err != nil {
@ -122,7 +122,7 @@ func (b *BlockStore) Init(config map[string]string) error {
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)
if err != nil {
return "", err
@ -168,7 +168,7 @@ func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ s
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)
if err != nil {
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
}
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
diskInfo, err := b.disks.Get(context.TODO(), b.disksResourceGroup, volumeID)
if err != nil {
@ -259,7 +259,7 @@ func stringPtr(s string) *string {
return &s
}
func (b *BlockStore) DeleteSnapshot(snapshotID string) error {
func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
snapshotInfo, err := b.parseSnapshotName(snapshotID)
if err != nil {
return err
@ -303,11 +303,11 @@ var snapshotURIRegexp = regexp.MustCompile(
// 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
// 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
// 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 {
// legacy format - name only (not fully-qualified)
case !strings.Contains(name, "/"):
@ -357,7 +357,7 @@ func parseFullSnapshotName(name string) (*snapshotIdentifier, error) {
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)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return "", errors.WithStack(err)
@ -374,7 +374,7 @@ func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, e
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)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return nil, errors.WithStack(err)

View File

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

View File

@ -40,17 +40,17 @@ const (
zoneSeparator = "__"
)
type BlockStore struct {
type VolumeSnapshotter struct {
gce *compute.Service
project string
log logrus.FieldLogger
}
func NewBlockStore(logger logrus.FieldLogger) *BlockStore {
return &BlockStore{log: logger}
func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
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()
if err != nil {
return err
@ -125,7 +125,7 @@ func parseRegion(volumeAZ string) (string, error) {
}
// 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)
var zoneURLs []string
for _, z := range zones {
@ -140,7 +140,7 @@ func (b *BlockStore) getZoneURLs(volumeAZ string) ([]string, error) {
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
res, err := b.gce.Snapshots.Get(b.project, snapshotID).Do()
if err != nil {
@ -185,7 +185,7 @@ func (b *BlockStore) CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ s
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 (
res *compute.Disk
err error
@ -209,7 +209,7 @@ func (b *BlockStore) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, e
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
// long
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()
if err != nil {
return "", errors.WithStack(err)
@ -251,7 +251,7 @@ func (b *BlockStore) createSnapshot(snapshotName, volumeID, volumeAZ string, tag
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()
if err != nil {
return "", errors.WithStack(err)
@ -304,7 +304,7 @@ func getSnapshotTags(veleroTags map[string]string, diskDescription string, log l
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()
// 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
}
func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) {
func (b *VolumeSnapshotter) GetVolumeID(unstructuredPV runtime.Unstructured) (string, error) {
pv := new(v1.PersistentVolume)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return "", errors.WithStack(err)
@ -336,7 +336,7 @@ func (b *BlockStore) GetVolumeID(unstructuredPV runtime.Unstructured) (string, e
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)
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredPV.UnstructuredContent(), pv); err != nil {
return nil, errors.WithStack(err)

View File

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

View File

@ -20,13 +20,13 @@ package mocks
import mock "github.com/stretchr/testify/mock"
import runtime "k8s.io/apimachinery/pkg/runtime"
// BlockStore is an autogenerated mock type for the BlockStore type
type BlockStore struct {
// VolumeSnapshotter is an autogenerated mock type for the VolumeSnapshotter type
type VolumeSnapshotter struct {
mock.Mock
}
// 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)
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
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)
var r0 string
@ -68,7 +68,7 @@ func (_m *BlockStore) CreateVolumeFromSnapshot(snapshotID string, volumeType str
}
// 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)
var r0 error
@ -82,7 +82,7 @@ func (_m *BlockStore) DeleteSnapshot(snapshotID string) error {
}
// 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)
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
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)
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
func (_m *BlockStore) Init(config map[string]string) error {
func (_m *VolumeSnapshotter) Init(config map[string]string) error {
ret := _m.Called(config)
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
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)
var r0 runtime.Unstructured

View File

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

View File

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

View File

@ -254,12 +254,12 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e
} 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())
} 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 {
errs = append(errs, err.Error())
} else {
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())
}
}
@ -270,21 +270,21 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e
if snapshots, err := backupStore.GetBackupVolumeSnapshots(backup.Name); err != nil {
errs = append(errs, errors.Wrap(err, "error getting backup's volume snapshots").Error())
} else {
blockStores := make(map[string]velero.BlockStore)
volumeSnapshotters := make(map[string]velero.VolumeSnapshotter)
for _, snapshot := range snapshots {
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 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())
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())
}
}
@ -361,26 +361,26 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e
return nil
}
func blockStoreForSnapshotLocation(
func volumeSnapshotterForSnapshotLocation(
namespace, snapshotLocationName string,
snapshotLocationLister listers.VolumeSnapshotLocationLister,
pluginManager clientmgmt.Manager,
) (velero.BlockStore, error) {
) (velero.VolumeSnapshotter, error) {
snapshotLocation, err := snapshotLocationLister.VolumeSnapshotLocations(namespace).Get(snapshotLocationName)
if err != nil {
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 {
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 {
return nil, errors.Wrapf(err, "error initializing block store for volume snapshot location %s", snapshotLocationName)
if err = volumeSnapshotter.Init(snapshotLocation.Spec.Config); err != nil {
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) {

View File

@ -111,29 +111,29 @@ func TestBackupDeletionControllerProcessQueueItem(t *testing.T) {
}
type backupDeletionControllerTestData struct {
client *fake.Clientset
sharedInformers informers.SharedInformerFactory
blockStore *velerotest.FakeBlockStore
backupStore *persistencemocks.BackupStore
controller *backupDeletionController
req *v1.DeleteBackupRequest
client *fake.Clientset
sharedInformers informers.SharedInformerFactory
volumeSnapshotter *velerotest.FakeVolumeSnapshotter
backupStore *persistencemocks.BackupStore
controller *backupDeletionController
req *v1.DeleteBackupRequest
}
func setupBackupDeletionControllerTest(objects ...runtime.Object) *backupDeletionControllerTestData {
var (
client = fake.NewSimpleClientset(objects...)
sharedInformers = informers.NewSharedInformerFactory(client, 0)
blockStore = &velerotest.FakeBlockStore{SnapshotsTaken: sets.NewString()}
pluginManager = &pluginmocks.Manager{}
backupStore = &persistencemocks.BackupStore{}
req = pkgbackup.NewDeleteBackupRequest("foo", "uid")
client = fake.NewSimpleClientset(objects...)
sharedInformers = informers.NewSharedInformerFactory(client, 0)
volumeSnapshotter = &velerotest.FakeVolumeSnapshotter{SnapshotsTaken: sets.NewString()}
pluginManager = &pluginmocks.Manager{}
backupStore = &persistencemocks.BackupStore{}
req = pkgbackup.NewDeleteBackupRequest("foo", "uid")
)
data := &backupDeletionControllerTestData{
client: client,
sharedInformers: sharedInformers,
blockStore: blockStore,
backupStore: backupStore,
client: client,
sharedInformers: sharedInformers,
volumeSnapshotter: volumeSnapshotter,
backupStore: backupStore,
controller: NewBackupDeletionController(
velerotest.NewLogger(),
sharedInformers.Velero().V1().DeleteBackupRequests(),
@ -376,7 +376,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
td.client.PrependReactor("get", "backups", func(action core.Action) (bool, runtime.Object, error) {
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) {
return true, td.req, nil
@ -387,7 +387,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
})
pluginManager := &pluginmocks.Manager{}
pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil)
pluginManager.On("GetVolumeSnapshotter", "provider-1").Return(td.volumeSnapshotter, nil)
pluginManager.On("CleanupClients")
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())
// 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) {
@ -504,7 +504,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
td.client.PrependReactor("get", "backups", func(action core.Action) (bool, runtime.Object, error) {
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) {
return true, td.req, nil
@ -526,7 +526,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
}
pluginManager := &pluginmocks.Manager{}
pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil)
pluginManager.On("GetVolumeSnapshotter", "provider-1").Return(td.volumeSnapshotter, nil)
pluginManager.On("CleanupClients")
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())
// 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,
actions []velero.RestoreItemAction,
snapshotLocationLister listers.VolumeSnapshotLocationLister,
blockStoreGetter restore.BlockStoreGetter,
volumeSnapshotterGetter restore.VolumeSnapshotterGetter,
) (api.RestoreResult, api.RestoreResult) {
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},
Plugins: map[string]hcplugin.Plugin{
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.PluginKindPluginLister): &framework.PluginListerPlugin{},
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).
func (b *clientBuilder) client() *hcplugin.Client {
return hcplugin.NewClient(b.clientConfig())

View File

@ -53,7 +53,7 @@ func TestClientConfig(t *testing.T) {
AllowedProtocols: []hcplugin.Protocol{hcplugin.ProtocolGRPC},
Plugins: map[string]hcplugin.Plugin{
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.PluginKindPluginLister): &framework.PluginListerPlugin{},
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(name string) (velero.ObjectStore, error)
// GetBlockStore returns the BlockStore plugin for name.
GetBlockStore(name string) (velero.BlockStore, error)
// GetVolumeSnapshotter returns the VolumeSnapshotter plugin for name.
GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error)
// GetBackupItemActions returns all backup item action plugins.
GetBackupItemActions() ([]velero.BackupItemAction, error)
@ -134,14 +134,14 @@ func (m *manager) GetObjectStore(name string) (velero.ObjectStore, error) {
return r, nil
}
// GetBlockStore returns a restartableBlockStore for name.
func (m *manager) GetBlockStore(name string) (velero.BlockStore, error) {
restartableProcess, err := m.getRestartableProcess(framework.PluginKindBlockStore, name)
// GetVolumeSnapshotter returns a restartableVolumeSnapshotter for name.
func (m *manager) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error) {
restartableProcess, err := m.getRestartableProcess(framework.PluginKindVolumeSnapshotter, name)
if err != nil {
return nil, err
}
r := newRestartableBlockStore(name, restartableProcess)
r := newRestartableVolumeSnapshotter(name, restartableProcess)
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,
framework.PluginKindBlockStore,
framework.PluginKindVolumeSnapshotter,
"aws",
func(m Manager, name string) (interface{}, error) {
return m.GetBlockStore(name)
return m.GetVolumeSnapshotter(name)
},
func(name string, sharedPluginProcess RestartableProcess) interface{} {
return &restartableBlockStore{
key: kindAndName{kind: framework.PluginKindBlockStore, name: name},
return &restartableVolumeSnapshotter{
key: kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name},
sharedPluginProcess: sharedPluginProcess,
}
},

View File

@ -24,20 +24,20 @@ import (
"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
// 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.
type restartableBlockStore struct {
type restartableVolumeSnapshotter struct {
key kindAndName
sharedPluginProcess RestartableProcess
config map[string]string
}
// newRestartableBlockStore returns a new restartableBlockStore.
func newRestartableBlockStore(name string, sharedPluginProcess RestartableProcess) *restartableBlockStore {
key := kindAndName{kind: framework.PluginKindBlockStore, name: name}
r := &restartableBlockStore{
// newRestartableVolumeSnapshotter returns a new restartableVolumeSnapshotter.
func newRestartableVolumeSnapshotter(name string, sharedPluginProcess RestartableProcess) *restartableVolumeSnapshotter {
key := kindAndName{kind: framework.PluginKindVolumeSnapshotter, name: name}
r := &restartableVolumeSnapshotter{
key: key,
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().
func (r *restartableBlockStore) reinitialize(dispensed interface{}) error {
blockStore, ok := dispensed.(velero.BlockStore)
func (r *restartableVolumeSnapshotter) reinitialize(dispensed interface{}) error {
volumeSnapshotter, ok := dispensed.(velero.VolumeSnapshotter)
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.
func (r *restartableBlockStore) getBlockStore() (velero.BlockStore, error) {
func (r *restartableVolumeSnapshotter) getVolumeSnapshotter() (velero.VolumeSnapshotter, error) {
plugin, err := r.sharedPluginProcess.getByKindAndName(r.key)
if err != nil {
return nil, err
}
blockStore, ok := plugin.(velero.BlockStore)
volumeSnapshotter, ok := plugin.(velero.VolumeSnapshotter)
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.
func (r *restartableBlockStore) getDelegate() (velero.BlockStore, error) {
// getDelegate restarts the plugin process (if needed) and returns the volume snapshotter for this restartableVolumeSnapshotter.
func (r *restartableVolumeSnapshotter) getDelegate() (velero.VolumeSnapshotter, error) {
if err := r.sharedPluginProcess.resetIfNeeded(); err != nil {
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.
func (r *restartableBlockStore) Init(config map[string]string) error {
func (r *restartableVolumeSnapshotter) Init(config map[string]string) error {
if r.config != nil {
return errors.Errorf("already initialized")
}
// Not using getDelegate() to avoid possible infinite recursion
delegate, err := r.getBlockStore()
delegate, err := r.getVolumeSnapshotter()
if err != nil {
return err
}
@ -100,14 +100,14 @@ func (r *restartableBlockStore) Init(config map[string]string) error {
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
// call it using a specific BlockStore.
func (r *restartableBlockStore) init(blockStore velero.BlockStore, config map[string]string) error {
return blockStore.Init(config)
// 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 VolumeSnapshotter.
func (r *restartableVolumeSnapshotter) init(volumeSnapshotter velero.VolumeSnapshotter, config map[string]string) error {
return volumeSnapshotter.Init(config)
}
// 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()
if err != nil {
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.
func (r *restartableBlockStore) GetVolumeID(pv runtime.Unstructured) (string, error) {
func (r *restartableVolumeSnapshotter) GetVolumeID(pv runtime.Unstructured) (string, error) {
delegate, err := r.getDelegate()
if err != nil {
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.
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()
if err != nil {
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.
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()
if err != nil {
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.
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()
if err != nil {
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.
func (r *restartableBlockStore) DeleteSnapshot(snapshotID string) error {
func (r *restartableVolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
delegate, err := r.getDelegate()
if err != nil {
return err

View File

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

View File

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

View File

@ -33,8 +33,8 @@ const (
// PluginKindObjectStore represents an object store plugin.
PluginKindObjectStore PluginKind = "ObjectStore"
// PluginKindBlockStore represents a block store plugin.
PluginKindBlockStore PluginKind = "BlockStore"
// PluginKindVolumeSnapshotter represents a volume snapshotter plugin.
PluginKindVolumeSnapshotter PluginKind = "VolumeSnapshotter"
// PluginKindBackupItemAction represents a backup item action plugin.
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).
var allPluginKinds = sets.NewString(
PluginKindObjectStore.String(),
PluginKindBlockStore.String(),
PluginKindVolumeSnapshotter.String(),
PluginKindBackupItemAction.String(),
PluginKindRestoreItemAction.String(),
)

View File

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

View File

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

View File

@ -54,11 +54,11 @@ type Server interface {
// RegisterBackupItemActions registers multiple backup item actions.
RegisterBackupItemActions(map[string]HandlerInitializer) Server
// RegisterBlockStore registers a block store.
RegisterBlockStore(name string, initializer HandlerInitializer) Server
// RegisterVolumeSnapshotter registers a volume snapshotter.
RegisterVolumeSnapshotter(name string, initializer HandlerInitializer) Server
// RegisterBlockStores registers multiple block stores.
RegisterBlockStores(map[string]HandlerInitializer) Server
// RegisterVolumeSnapshotters registers multiple volume snapshotters.
RegisterVolumeSnapshotters(map[string]HandlerInitializer) Server
// RegisterObjectStore registers an object store.
RegisterObjectStore(name string, initializer HandlerInitializer) Server
@ -82,7 +82,7 @@ type server struct {
logLevelFlag *logging.LevelFlag
flagSet *pflag.FlagSet
backupItemAction *BackupItemActionPlugin
blockStore *BlockStorePlugin
volumeSnapshotter *VolumeSnapshotterPlugin
objectStore *ObjectStorePlugin
restoreItemAction *RestoreItemActionPlugin
}
@ -95,7 +95,7 @@ func NewServer() Server {
log: log,
logLevelFlag: logging.LogLevelFlag(log.Level),
backupItemAction: NewBackupItemActionPlugin(serverLogger(log)),
blockStore: NewBlockStorePlugin(serverLogger(log)),
volumeSnapshotter: NewVolumeSnapshotterPlugin(serverLogger(log)),
objectStore: NewObjectStorePlugin(serverLogger(log)),
restoreItemAction: NewRestoreItemActionPlugin(serverLogger(log)),
}
@ -120,14 +120,14 @@ func (s *server) RegisterBackupItemActions(m map[string]HandlerInitializer) Serv
return s
}
func (s *server) RegisterBlockStore(name string, initializer HandlerInitializer) Server {
s.blockStore.register(name, initializer)
func (s *server) RegisterVolumeSnapshotter(name string, initializer HandlerInitializer) Server {
s.volumeSnapshotter.register(name, initializer)
return s
}
func (s *server) RegisterBlockStores(m map[string]HandlerInitializer) Server {
func (s *server) RegisterVolumeSnapshotters(m map[string]HandlerInitializer) Server {
for name := range m {
s.RegisterBlockStore(name, m[name])
s.RegisterVolumeSnapshotter(name, m[name])
}
return s
}
@ -181,7 +181,7 @@ func (s *server) Serve() {
var pluginIdentifiers []PluginIdentifier
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, PluginKindRestoreItemAction, s.restoreItemAction)...)
@ -191,7 +191,7 @@ func (s *server) Serve() {
HandshakeConfig: Handshake,
Plugins: map[string]plugin.Plugin{
string(PluginKindBackupItemAction): s.backupItemAction,
string(PluginKindBlockStore): s.blockStore,
string(PluginKindVolumeSnapshotter): s.volumeSnapshotter,
string(PluginKindObjectStore): s.objectStore,
string(PluginKindPluginLister): NewPluginListerPlugin(pluginLister),
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
// (ObjectStore, BlockStore, BackupItemAction, RestoreItemAction).
// (ObjectStore, VolumeSnapshotter, BackupItemAction, RestoreItemAction).
type HandlerInitializer func(logger logrus.FieldLogger) (interface{}, error)
// 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"
)
// BlockStorePlugin is an implementation of go-plugin's Plugin
// interface with support for gRPC for the cloudprovider/BlockStore
// VolumeSnapshotterPlugin is an implementation of go-plugin's Plugin
// interface with support for gRPC for the cloudprovider/VolumeSnapshotter
// interface.
type BlockStorePlugin struct {
type VolumeSnapshotterPlugin struct {
plugin.NetRPCUnsupportedPlugin
*pluginBase
}
// GRPCClient returns a BlockStore gRPC client.
func (p *BlockStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
return newClientDispenser(p.clientLogger, clientConn, newBlockStoreGRPCClient), nil
// GRPCClient returns a VolumeSnapshotter gRPC client.
func (p *VolumeSnapshotterPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
return newClientDispenser(p.clientLogger, clientConn, newVolumeSnapshotterGRPCClient), nil
}
// GRPCServer registers a BlockStore gRPC server.
func (p *BlockStorePlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
proto.RegisterBlockStoreServer(server, &BlockStoreGRPCServer{mux: p.serverMux})
// GRPCServer registers a VolumeSnapshotter gRPC server.
func (p *VolumeSnapshotterPlugin) GRPCServer(_ *plugin.GRPCBroker, server *grpc.Server) error {
proto.RegisterVolumeSnapshotterServer(server, &VolumeSnapshotterGRPCServer{mux: p.serverMux})
return nil
}

View File

@ -28,31 +28,31 @@ import (
proto "github.com/heptio/velero/pkg/plugin/generated"
)
// NewBlockStorePlugin constructs a BlockStorePlugin.
func NewBlockStorePlugin(options ...PluginOption) *BlockStorePlugin {
return &BlockStorePlugin{
// NewVolumeSnapshotterPlugin constructs a VolumeSnapshotterPlugin.
func NewVolumeSnapshotterPlugin(options ...PluginOption) *VolumeSnapshotterPlugin {
return &VolumeSnapshotterPlugin{
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.
type BlockStoreGRPCClient struct {
type VolumeSnapshotterGRPCClient struct {
*clientBase
grpcClient proto.BlockStoreClient
grpcClient proto.VolumeSnapshotterClient
}
func newBlockStoreGRPCClient(base *clientBase, clientConn *grpc.ClientConn) interface{} {
return &BlockStoreGRPCClient{
func newVolumeSnapshotterGRPCClient(base *clientBase, clientConn *grpc.ClientConn) interface{} {
return &VolumeSnapshotterGRPCClient{
clientBase: base,
grpcClient: proto.NewBlockStoreClient(clientConn),
grpcClient: proto.NewVolumeSnapshotterClient(clientConn),
}
}
// Init prepares the BlockStore for usage using the provided map of
// 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.
func (c *BlockStoreGRPCClient) Init(config map[string]string) error {
func (c *VolumeSnapshotterGRPCClient) Init(config map[string]string) error {
req := &proto.InitRequest{
Plugin: c.plugin,
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,
// 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{
Plugin: c.plugin,
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
// volume.
func (c *BlockStoreGRPCClient) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
func (c *VolumeSnapshotterGRPCClient) GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error) {
req := &proto.GetVolumeInfoRequest{
Plugin: c.plugin,
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
// 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{
Plugin: c.plugin,
VolumeID: volumeID,
@ -130,7 +130,7 @@ func (c *BlockStoreGRPCClient) CreateSnapshot(volumeID, volumeAZ string, tags ma
}
// DeleteSnapshot deletes the specified volume snapshot.
func (c *BlockStoreGRPCClient) DeleteSnapshot(snapshotID string) error {
func (c *VolumeSnapshotterGRPCClient) DeleteSnapshot(snapshotID string) error {
req := &proto.DeleteSnapshotRequest{
Plugin: c.plugin,
SnapshotID: snapshotID,
@ -143,7 +143,7 @@ func (c *BlockStoreGRPCClient) DeleteSnapshot(snapshotID string) error {
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())
if err != nil {
return "", errors.WithStack(err)
@ -162,7 +162,7 @@ func (c *BlockStoreGRPCClient) GetVolumeID(pv runtime.Unstructured) (string, err
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())
if err != nil {
return nil, errors.WithStack(err)

View File

@ -27,30 +27,30 @@ import (
"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.
type BlockStoreGRPCServer struct {
type VolumeSnapshotterGRPCServer struct {
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)
if err != nil {
return nil, err
}
blockStore, ok := impl.(velero.BlockStore)
volumeSnapshotter, ok := impl.(velero.VolumeSnapshotter)
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
// 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.
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() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil {
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,
// 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() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil {
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
// 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() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil {
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
// 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() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr
@ -153,7 +153,7 @@ func (s *BlockStoreGRPCServer) CreateSnapshot(ctx context.Context, req *proto.Cr
}
// 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() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr
@ -172,7 +172,7 @@ func (s *BlockStoreGRPCServer) DeleteSnapshot(ctx context.Context, req *proto.De
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() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr
@ -198,7 +198,7 @@ func (s *BlockStoreGRPCServer) GetVolumeID(ctx context.Context, req *proto.GetVo
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() {
if recoveredErr := handlePanic(recover()); recoveredErr != nil {
err = recoveredErr

View File

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

View File

@ -27,7 +27,7 @@ type PutObjectRequest struct {
func (m *PutObjectRequest) Reset() { *m = PutObjectRequest{} }
func (m *PutObjectRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -66,7 +66,7 @@ type GetObjectRequest struct {
func (m *GetObjectRequest) Reset() { *m = GetObjectRequest{} }
func (m *GetObjectRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -96,7 +96,7 @@ type Bytes struct {
func (m *Bytes) Reset() { *m = Bytes{} }
func (m *Bytes) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -115,7 +115,7 @@ type ListCommonPrefixesRequest struct {
func (m *ListCommonPrefixesRequest) Reset() { *m = ListCommonPrefixesRequest{} }
func (m *ListCommonPrefixesRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -152,7 +152,7 @@ type ListCommonPrefixesResponse struct {
func (m *ListCommonPrefixesResponse) Reset() { *m = ListCommonPrefixesResponse{} }
func (m *ListCommonPrefixesResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -170,7 +170,7 @@ type ListObjectsRequest struct {
func (m *ListObjectsRequest) Reset() { *m = ListObjectsRequest{} }
func (m *ListObjectsRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -200,7 +200,7 @@ type ListObjectsResponse struct {
func (m *ListObjectsResponse) Reset() { *m = ListObjectsResponse{} }
func (m *ListObjectsResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -218,7 +218,7 @@ type DeleteObjectRequest struct {
func (m *DeleteObjectRequest) Reset() { *m = DeleteObjectRequest{} }
func (m *DeleteObjectRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -251,7 +251,7 @@ type CreateSignedURLRequest struct {
func (m *CreateSignedURLRequest) Reset() { *m = CreateSignedURLRequest{} }
func (m *CreateSignedURLRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -288,7 +288,7 @@ type CreateSignedURLResponse struct {
func (m *CreateSignedURLResponse) Reset() { *m = CreateSignedURLResponse{} }
func (m *CreateSignedURLResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -642,9 +642,9 @@ var _ObjectStore_serviceDesc = grpc.ServiceDesc{
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
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,

View File

@ -26,7 +26,7 @@ type PluginIdentifier struct {
func (m *PluginIdentifier) Reset() { *m = PluginIdentifier{} }
func (m *PluginIdentifier) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -56,7 +56,7 @@ type ListPluginsResponse struct {
func (m *ListPluginsResponse) Reset() { *m = ListPluginsResponse{} }
func (m *ListPluginsResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -142,9 +142,9 @@ var _PluginLister_serviceDesc = grpc.ServiceDesc{
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
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,

View File

@ -27,7 +27,7 @@ type RestoreExecuteRequest struct {
func (m *RestoreExecuteRequest) Reset() { *m = RestoreExecuteRequest{} }
func (m *RestoreExecuteRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -65,7 +65,7 @@ type RestoreExecuteResponse struct {
func (m *RestoreExecuteResponse) Reset() { *m = RestoreExecuteResponse{} }
func (m *RestoreExecuteResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -191,9 +191,9 @@ var _RestoreItemAction_serviceDesc = grpc.ServiceDesc{
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
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,

View File

@ -18,7 +18,7 @@ type Empty struct {
func (m *Empty) Reset() { *m = Empty{} }
func (m *Empty) String() string { return proto.CompactTextString(m) }
func (*Empty) ProtoMessage() {}
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor5, []int{0} }
func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor4, []int{0} }
type InitRequest struct {
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) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -51,7 +51,7 @@ type AppliesToRequest struct {
func (m *AppliesToRequest) Reset() { *m = AppliesToRequest{} }
func (m *AppliesToRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -71,7 +71,7 @@ type AppliesToResponse struct {
func (m *AppliesToResponse) Reset() { *m = AppliesToResponse{} }
func (m *AppliesToResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -115,7 +115,7 @@ type Stack struct {
func (m *Stack) Reset() { *m = Stack{} }
func (m *Stack) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -133,7 +133,7 @@ type StackFrame struct {
func (m *StackFrame) Reset() { *m = StackFrame{} }
func (m *StackFrame) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -165,9 +165,9 @@ func init() {
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
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,

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: BlockStore.proto
// source: VolumeSnapshotter.proto
package generated
@ -28,7 +28,7 @@ type CreateVolumeRequest struct {
func (m *CreateVolumeRequest) Reset() { *m = CreateVolumeRequest{} }
func (m *CreateVolumeRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -72,7 +72,7 @@ type CreateVolumeResponse struct {
func (m *CreateVolumeResponse) Reset() { *m = CreateVolumeResponse{} }
func (m *CreateVolumeResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -90,7 +90,7 @@ type GetVolumeInfoRequest struct {
func (m *GetVolumeInfoRequest) Reset() { *m = GetVolumeInfoRequest{} }
func (m *GetVolumeInfoRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -121,7 +121,7 @@ type GetVolumeInfoResponse struct {
func (m *GetVolumeInfoResponse) Reset() { *m = GetVolumeInfoResponse{} }
func (m *GetVolumeInfoResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -147,7 +147,7 @@ type CreateSnapshotRequest struct {
func (m *CreateSnapshotRequest) Reset() { *m = CreateSnapshotRequest{} }
func (m *CreateSnapshotRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -184,7 +184,7 @@ type CreateSnapshotResponse struct {
func (m *CreateSnapshotResponse) Reset() { *m = CreateSnapshotResponse{} }
func (m *CreateSnapshotResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -201,7 +201,7 @@ type DeleteSnapshotRequest struct {
func (m *DeleteSnapshotRequest) Reset() { *m = DeleteSnapshotRequest{} }
func (m *DeleteSnapshotRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -225,7 +225,7 @@ type GetVolumeIDRequest struct {
func (m *GetVolumeIDRequest) Reset() { *m = GetVolumeIDRequest{} }
func (m *GetVolumeIDRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -248,7 +248,7 @@ type GetVolumeIDResponse struct {
func (m *GetVolumeIDResponse) Reset() { *m = GetVolumeIDResponse{} }
func (m *GetVolumeIDResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -266,7 +266,7 @@ type SetVolumeIDRequest struct {
func (m *SetVolumeIDRequest) Reset() { *m = SetVolumeIDRequest{} }
func (m *SetVolumeIDRequest) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -296,7 +296,7 @@ type SetVolumeIDResponse struct {
func (m *SetVolumeIDResponse) Reset() { *m = SetVolumeIDResponse{} }
func (m *SetVolumeIDResponse) String() string { return proto.CompactTextString(m) }
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 {
if m != nil {
@ -327,9 +327,9 @@ var _ grpc.ClientConn
// is compatible with the grpc package it is being compiled against.
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)
CreateVolumeFromSnapshot(ctx context.Context, in *CreateVolumeRequest, opts ...grpc.CallOption) (*CreateVolumeResponse, 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)
}
type blockStoreClient struct {
type volumeSnapshotterClient struct {
cc *grpc.ClientConn
}
func NewBlockStoreClient(cc *grpc.ClientConn) BlockStoreClient {
return &blockStoreClient{cc}
func NewVolumeSnapshotterClient(cc *grpc.ClientConn) VolumeSnapshotterClient {
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)
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 {
return nil, err
}
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)
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 {
return nil, err
}
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)
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 {
return nil, err
}
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)
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 {
return nil, err
}
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)
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 {
return nil, err
}
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)
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 {
return nil, err
}
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)
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 {
return nil, err
}
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)
CreateVolumeFromSnapshot(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error)
GetVolumeInfo(context.Context, *GetVolumeInfoRequest) (*GetVolumeInfoResponse, error)
@ -422,208 +422,208 @@ type BlockStoreServer interface {
SetVolumeID(context.Context, *SetVolumeIDRequest) (*SetVolumeIDResponse, error)
}
func RegisterBlockStoreServer(s *grpc.Server, srv BlockStoreServer) {
s.RegisterService(&_BlockStore_serviceDesc, srv)
func RegisterVolumeSnapshotterServer(s *grpc.Server, srv VolumeSnapshotterServer) {
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BlockStoreServer).Init(ctx, in)
return srv.(VolumeSnapshotterServer).Init(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/generated.BlockStore/Init",
FullMethod: "/generated.VolumeSnapshotter/Init",
}
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)
}
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BlockStoreServer).CreateVolumeFromSnapshot(ctx, in)
return srv.(VolumeSnapshotterServer).CreateVolumeFromSnapshot(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/generated.BlockStore/CreateVolumeFromSnapshot",
FullMethod: "/generated.VolumeSnapshotter/CreateVolumeFromSnapshot",
}
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)
}
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BlockStoreServer).GetVolumeInfo(ctx, in)
return srv.(VolumeSnapshotterServer).GetVolumeInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/generated.BlockStore/GetVolumeInfo",
FullMethod: "/generated.VolumeSnapshotter/GetVolumeInfo",
}
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)
}
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BlockStoreServer).CreateSnapshot(ctx, in)
return srv.(VolumeSnapshotterServer).CreateSnapshot(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/generated.BlockStore/CreateSnapshot",
FullMethod: "/generated.VolumeSnapshotter/CreateSnapshot",
}
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)
}
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BlockStoreServer).DeleteSnapshot(ctx, in)
return srv.(VolumeSnapshotterServer).DeleteSnapshot(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/generated.BlockStore/DeleteSnapshot",
FullMethod: "/generated.VolumeSnapshotter/DeleteSnapshot",
}
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)
}
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BlockStoreServer).GetVolumeID(ctx, in)
return srv.(VolumeSnapshotterServer).GetVolumeID(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/generated.BlockStore/GetVolumeID",
FullMethod: "/generated.VolumeSnapshotter/GetVolumeID",
}
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)
}
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)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BlockStoreServer).SetVolumeID(ctx, in)
return srv.(VolumeSnapshotterServer).SetVolumeID(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/generated.BlockStore/SetVolumeID",
FullMethod: "/generated.VolumeSnapshotter/SetVolumeID",
}
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)
}
var _BlockStore_serviceDesc = grpc.ServiceDesc{
ServiceName: "generated.BlockStore",
HandlerType: (*BlockStoreServer)(nil),
var _VolumeSnapshotter_serviceDesc = grpc.ServiceDesc{
ServiceName: "generated.VolumeSnapshotter",
HandlerType: (*VolumeSnapshotterServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Init",
Handler: _BlockStore_Init_Handler,
Handler: _VolumeSnapshotter_Init_Handler,
},
{
MethodName: "CreateVolumeFromSnapshot",
Handler: _BlockStore_CreateVolumeFromSnapshot_Handler,
Handler: _VolumeSnapshotter_CreateVolumeFromSnapshot_Handler,
},
{
MethodName: "GetVolumeInfo",
Handler: _BlockStore_GetVolumeInfo_Handler,
Handler: _VolumeSnapshotter_GetVolumeInfo_Handler,
},
{
MethodName: "CreateSnapshot",
Handler: _BlockStore_CreateSnapshot_Handler,
Handler: _VolumeSnapshotter_CreateSnapshot_Handler,
},
{
MethodName: "DeleteSnapshot",
Handler: _BlockStore_DeleteSnapshot_Handler,
Handler: _VolumeSnapshotter_DeleteSnapshot_Handler,
},
{
MethodName: "GetVolumeID",
Handler: _BlockStore_GetVolumeID_Handler,
Handler: _VolumeSnapshotter_GetVolumeID_Handler,
},
{
MethodName: "SetVolumeID",
Handler: _BlockStore_SetVolumeID_Handler,
Handler: _VolumeSnapshotter_SetVolumeID_Handler,
},
},
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{
// 527 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xd3, 0x4e,
0x10, 0x95, 0x63, 0xb7, 0xfa, 0x65, 0xd2, 0x5f, 0x15, 0x4d, 0xfe, 0xc8, 0xb2, 0x44, 0x30, 0x3e,
0x45, 0x3d, 0x44, 0x10, 0x0e, 0x54, 0x1c, 0x90, 0x0a, 0x2e, 0x28, 0xa2, 0x12, 0x92, 0x5d, 0x10,
0x82, 0x93, 0xa1, 0xd3, 0x34, 0xaa, 0xe3, 0x35, 0xde, 0x4d, 0xa5, 0x7c, 0x18, 0xee, 0x7c, 0x2c,
0x3e, 0x0a, 0x8a, 0xbd, 0x49, 0x76, 0x93, 0x4d, 0xd3, 0x4b, 0x6f, 0x9e, 0x19, 0xcf, 0x9b, 0xf7,
0xc6, 0x6f, 0xd7, 0xd0, 0x7c, 0x9b, 0xb2, 0x9f, 0xb7, 0xb1, 0x60, 0x05, 0x0d, 0xf2, 0x82, 0x09,
0x86, 0xf5, 0x31, 0x65, 0x54, 0x24, 0x82, 0xae, 0xbc, 0xa3, 0xf8, 0x26, 0x29, 0xe8, 0xaa, 0x2a,
0x04, 0xbf, 0x2d, 0x68, 0xbd, 0x2b, 0x28, 0x11, 0xf4, 0x85, 0xa5, 0xb3, 0x29, 0x45, 0xf4, 0x6b,
0x46, 0x5c, 0x60, 0x17, 0x0e, 0xf3, 0x74, 0x36, 0x9e, 0x64, 0xae, 0xe5, 0x5b, 0xfd, 0x7a, 0x24,
0x23, 0xec, 0x01, 0xf0, 0x2c, 0xc9, 0xf9, 0x0d, 0x13, 0xa3, 0xd0, 0xad, 0x95, 0x35, 0x25, 0xb3,
0xa8, 0xdf, 0x95, 0x40, 0x97, 0xf3, 0x9c, 0x5c, 0xbb, 0xaa, 0xaf, 0x33, 0xe8, 0xc1, 0x7f, 0x55,
0x74, 0xf6, 0xcd, 0x75, 0xca, 0xea, 0x2a, 0x46, 0x04, 0x67, 0xc2, 0x72, 0xee, 0x1e, 0xf8, 0x56,
0xdf, 0x8e, 0xca, 0xe7, 0x60, 0x08, 0x6d, 0x9d, 0x1e, 0xcf, 0x59, 0xc6, 0x15, 0x9c, 0x51, 0x28,
0x19, 0xae, 0xe2, 0xe0, 0x1a, 0xda, 0x1f, 0x48, 0x54, 0x0d, 0xa3, 0xec, 0x9a, 0xed, 0xd3, 0xa4,
0x62, 0xd5, 0x74, 0x2c, 0x8d, 0xaf, 0xad, 0xf3, 0x0d, 0x3e, 0x42, 0x67, 0x63, 0x8e, 0x24, 0xa7,
0x2f, 0xc1, 0xda, 0x5a, 0xc2, 0x52, 0x68, 0x4d, 0x11, 0xfa, 0xd7, 0x82, 0x4e, 0xa5, 0x34, 0x96,
0xdb, 0x7c, 0x24, 0xda, 0xf8, 0x06, 0x1c, 0x91, 0x8c, 0xb9, 0xeb, 0xf8, 0x76, 0xbf, 0x31, 0x3c,
0x19, 0xac, 0xac, 0x31, 0x30, 0xce, 0x1f, 0x5c, 0x26, 0x63, 0x7e, 0x9e, 0x89, 0x62, 0x1e, 0x95,
0x7d, 0xde, 0x2b, 0xa8, 0xaf, 0x52, 0xd8, 0x04, 0xfb, 0x96, 0xe6, 0x92, 0xd9, 0xe2, 0x11, 0xdb,
0x70, 0x70, 0x97, 0xa4, 0x33, 0x92, 0x9c, 0xaa, 0xe0, 0x75, 0xed, 0xd4, 0x0a, 0x4e, 0xa1, 0xbb,
0x39, 0x61, 0xbd, 0x30, 0xc5, 0x55, 0xd6, 0xa6, 0xab, 0x82, 0x4f, 0xd0, 0x09, 0x29, 0xa5, 0x87,
0xef, 0x66, 0x8f, 0x4d, 0x83, 0xaf, 0x80, 0xeb, 0x4f, 0x17, 0xee, 0x43, 0x3b, 0x81, 0x66, 0x4e,
0x05, 0x9f, 0x70, 0x41, 0x99, 0x6c, 0x2a, 0x31, 0x8f, 0xa2, 0xad, 0x7c, 0xf0, 0x02, 0x5a, 0x1a,
0xf2, 0x03, 0xfc, 0x2a, 0x00, 0xe3, 0x47, 0x21, 0xa3, 0x4d, 0xb5, 0x37, 0xa6, 0x9e, 0x41, 0x2b,
0x36, 0x10, 0x35, 0xc1, 0x5b, 0x66, 0xf8, 0xe1, 0x1f, 0x07, 0x60, 0x7d, 0xd5, 0xe0, 0x73, 0x70,
0x46, 0xd9, 0x44, 0x60, 0x57, 0xb1, 0xd4, 0x22, 0x21, 0x15, 0x79, 0x4d, 0x25, 0x7f, 0x3e, 0xcd,
0xc5, 0x1c, 0xbf, 0x83, 0xab, 0x9e, 0xee, 0xf7, 0x05, 0x9b, 0x2e, 0xbf, 0x30, 0xf6, 0xb6, 0x8c,
0xa9, 0xdd, 0x50, 0xde, 0xd3, 0x9d, 0x75, 0xa9, 0x24, 0x82, 0xff, 0xb5, 0xe3, 0x89, 0x6a, 0x87,
0xe9, 0x82, 0xf0, 0xfc, 0xdd, 0x2f, 0x48, 0xcc, 0xcf, 0x70, 0xac, 0x5b, 0x18, 0xfd, 0x7d, 0xe7,
0xc7, 0x7b, 0x76, 0xcf, 0x1b, 0x12, 0x36, 0x84, 0x63, 0xdd, 0xdf, 0x1a, 0xac, 0xd1, 0xfa, 0x86,
0x6d, 0x5e, 0x40, 0x43, 0xb1, 0x1e, 0x3e, 0x31, 0xaa, 0x59, 0xfa, 0xcb, 0xeb, 0xed, 0x2a, 0x4b,
0x4e, 0x17, 0xd0, 0x88, 0x77, 0xa0, 0xc5, 0xf7, 0xa3, 0x19, 0x6c, 0xf5, 0xe3, 0xb0, 0xfc, 0xdd,
0xbc, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0xae, 0x59, 0x98, 0xf2, 0x9b, 0x06, 0x00, 0x00,
var fileDescriptor5 = []byte{
// 525 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xd3, 0x40,
0x10, 0xd6, 0xc6, 0x6e, 0x45, 0x26, 0xa5, 0x0a, 0x93, 0x1f, 0x2c, 0x4b, 0x04, 0xe3, 0x53, 0xd4,
0x43, 0x04, 0xe1, 0x40, 0xc5, 0x01, 0xa9, 0xc2, 0x05, 0x45, 0x54, 0x42, 0xb2, 0x0b, 0x42, 0x70,
0x32, 0xea, 0x34, 0x8d, 0x48, 0x6c, 0xe3, 0xdd, 0x54, 0xca, 0xc3, 0xf0, 0x0c, 0xbc, 0x12, 0x8f,
0x82, 0x62, 0x6f, 0x92, 0xdd, 0x64, 0x53, 0xf7, 0xd2, 0x9b, 0x67, 0x66, 0xe7, 0x9b, 0x6f, 0x66,
0xbf, 0x59, 0xc3, 0xd3, 0xaf, 0xe9, 0x74, 0x3e, 0xa3, 0x28, 0x89, 0x33, 0x7e, 0x93, 0x0a, 0x41,
0xf9, 0x20, 0xcb, 0x53, 0x91, 0x62, 0x7d, 0x4c, 0x09, 0xe5, 0xb1, 0xa0, 0x2b, 0xf7, 0x28, 0xba,
0x89, 0x73, 0xba, 0x2a, 0x03, 0xfe, 0x1f, 0x06, 0xad, 0xf7, 0x39, 0xc5, 0x82, 0xca, 0xd4, 0x90,
0x7e, 0xcf, 0x89, 0x0b, 0xec, 0xc2, 0x61, 0x36, 0x9d, 0x8f, 0x27, 0x89, 0xc3, 0x3c, 0xd6, 0xaf,
0x87, 0xd2, 0xc2, 0x1e, 0x00, 0x97, 0xe8, 0xa3, 0xc0, 0xa9, 0x15, 0x31, 0xc5, 0xb3, 0x8c, 0xdf,
0x16, 0x40, 0x97, 0x8b, 0x8c, 0x1c, 0xab, 0x8c, 0x6f, 0x3c, 0xe8, 0xc2, 0xa3, 0xd2, 0x3a, 0xfb,
0xee, 0xd8, 0x45, 0x74, 0x6d, 0x23, 0x82, 0x3d, 0x49, 0x33, 0xee, 0x1c, 0x78, 0xac, 0x6f, 0x85,
0xc5, 0xb7, 0x3f, 0x84, 0xb6, 0x4e, 0x8f, 0x67, 0x69, 0xc2, 0x15, 0x9c, 0x51, 0x20, 0x19, 0xae,
0x6d, 0xff, 0x1a, 0xda, 0x1f, 0x49, 0x94, 0x09, 0xa3, 0xe4, 0x3a, 0xad, 0xea, 0x49, 0xc5, 0xaa,
0xe9, 0x58, 0x1a, 0x5f, 0x4b, 0xe7, 0xeb, 0x7f, 0x82, 0xce, 0x56, 0x1d, 0x49, 0x4e, 0x1f, 0x02,
0xdb, 0x19, 0xc2, 0xaa, 0xd1, 0x9a, 0xd2, 0xe8, 0x3f, 0x06, 0x9d, 0xb2, 0xd3, 0xd5, 0xed, 0x3d,
0x10, 0x6d, 0x7c, 0x07, 0xb6, 0x88, 0xc7, 0xdc, 0xb1, 0x3d, 0xab, 0xdf, 0x18, 0x9e, 0x0c, 0xd6,
0xd2, 0x18, 0x18, 0xeb, 0x0f, 0x2e, 0xe3, 0x31, 0x3f, 0x4f, 0x44, 0xbe, 0x08, 0x8b, 0x3c, 0xf7,
0x0d, 0xd4, 0xd7, 0x2e, 0x6c, 0x82, 0xf5, 0x8b, 0x16, 0x92, 0xd9, 0xf2, 0x13, 0xdb, 0x70, 0x70,
0x1b, 0x4f, 0xe7, 0x24, 0x39, 0x95, 0xc6, 0xdb, 0xda, 0x29, 0xf3, 0x4f, 0xa1, 0xbb, 0x5d, 0x61,
0x33, 0x30, 0x45, 0x55, 0x6c, 0x5b, 0x55, 0xfe, 0x67, 0xe8, 0x04, 0x34, 0xa5, 0xfb, 0xcf, 0xa6,
0x42, 0xa6, 0xfe, 0x37, 0xc0, 0xcd, 0xd5, 0x05, 0x55, 0x68, 0x27, 0xd0, 0xcc, 0x28, 0xe7, 0x13,
0x2e, 0x28, 0x91, 0x49, 0x05, 0xe6, 0x51, 0xb8, 0xe3, 0xf7, 0x5f, 0x41, 0x4b, 0x43, 0xbe, 0x87,
0x5e, 0x05, 0x60, 0xf4, 0x20, 0x64, 0xb4, 0xaa, 0xd6, 0x56, 0xd5, 0x33, 0x68, 0x45, 0x06, 0xa2,
0x26, 0x78, 0x66, 0x86, 0x1f, 0xfe, 0xb5, 0xe1, 0xc9, 0xce, 0x8b, 0x83, 0x2f, 0xc1, 0x1e, 0x25,
0x13, 0x81, 0x5d, 0x45, 0x59, 0x4b, 0x87, 0x6c, 0xcc, 0x6d, 0x2a, 0xfe, 0xf3, 0x59, 0x26, 0x16,
0xf8, 0x03, 0x1c, 0x75, 0xc9, 0x3f, 0xe4, 0xe9, 0x6c, 0x05, 0x88, 0xbd, 0x1d, 0x7d, 0x6a, 0x0f,
0x95, 0xfb, 0x7c, 0x6f, 0x5c, 0x36, 0x14, 0xc2, 0x63, 0x6d, 0x4b, 0x51, 0xcd, 0x30, 0xbd, 0x13,
0xae, 0xb7, 0xff, 0x80, 0xc4, 0xfc, 0x02, 0xc7, 0xba, 0x92, 0xd1, 0xab, 0x5a, 0x23, 0xf7, 0xc5,
0x1d, 0x27, 0x24, 0x6c, 0x00, 0xc7, 0xba, 0xcc, 0x35, 0x58, 0xe3, 0x06, 0x18, 0xa6, 0x79, 0x01,
0x0d, 0x45, 0x81, 0xf8, 0xcc, 0xd8, 0xcd, 0x4a, 0x66, 0x6e, 0x6f, 0x5f, 0x58, 0x72, 0xba, 0x80,
0x46, 0xb4, 0x07, 0x2d, 0xba, 0x1b, 0xcd, 0xa0, 0xae, 0x9f, 0x87, 0xc5, 0x5f, 0xe7, 0xf5, 0xff,
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
}
// GetBlockStore provides a mock function with given fields: name
func (_m *Manager) GetBlockStore(name string) (velero.BlockStore, error) {
// GetVolumeSnapshotter provides a mock function with given fields: name
func (_m *Manager) GetVolumeSnapshotter(name string) (velero.VolumeSnapshotter, error) {
ret := _m.Called(name)
var r0 velero.BlockStore
if rf, ok := ret.Get(0).(func(string) velero.BlockStore); ok {
var r0 velero.VolumeSnapshotter
if rf, ok := ret.Get(0).(func(string) velero.VolumeSnapshotter); ok {
r0 = rf(name)
} else {
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;
}
service BlockStore {
service VolumeSnapshotter {
rpc Init(InitRequest) returns (Empty);
rpc CreateVolumeFromSnapshot(CreateVolumeRequest) returns (CreateVolumeResponse);
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");
you may not use this file except in compliance with the License.
@ -20,15 +20,16 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)
// BlockStore exposes basic block-storage operations required
// by Velero.
type BlockStore interface {
// Init prepares the BlockStore for usage using the provided map of
// configuration key-value pairs. It returns an error if the BlockStore
// VolumeSnapshotter defines the operations needed by Velero to
// take snapshots of persistent volumes during backup, and to restore
// persistent volumes from snapshots during restore.
type VolumeSnapshotter interface {
// 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.
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,
// and with the specified type and IOPS (if using provisioned IOPS).
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)
// 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)
// 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.
CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error)

View File

@ -33,13 +33,13 @@ type PVRestorer interface {
}
type pvRestorer struct {
logger logrus.FieldLogger
backup *api.Backup
snapshotVolumes *bool
restorePVs *bool
volumeSnapshots []*volume.Snapshot
blockStoreGetter BlockStoreGetter
snapshotLocationLister listers.VolumeSnapshotLocationLister
logger logrus.FieldLogger
backup *api.Backup
snapshotVolumes *bool
restorePVs *bool
volumeSnapshots []*volume.Snapshot
volumeSnapshotterGetter VolumeSnapshotterGetter
snapshotLocationLister listers.VolumeSnapshotLocationLister
}
func (r *pvRestorer) executePVAction(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
@ -83,23 +83,23 @@ func (r *pvRestorer) executePVAction(obj *unstructured.Unstructured) (*unstructu
return obj, nil
}
blockStore, err := r.blockStoreGetter.GetBlockStore(snapshotInfo.location.Spec.Provider)
volumeSnapshotter, err := r.volumeSnapshotterGetter.GetVolumeSnapshotter(snapshotInfo.location.Spec.Provider)
if err != nil {
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)
}
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 {
return nil, errors.WithStack(err)
}
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 {
return nil, errors.WithStack(err)
}

View File

@ -229,9 +229,9 @@ func TestExecutePVAction_SnapshotRestores(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
var (
blockStore = new(cloudprovidermocks.BlockStore)
blockStoreGetter = providerToBlockStoreMap(map[string]velero.BlockStore{
tc.expectedProvider: blockStore,
volumeSnapshotter = new(cloudprovidermocks.VolumeSnapshotter)
volumeSnapshotterGetter = providerToVolumeSnapshotterMap(map[string]velero.VolumeSnapshotter{
tc.expectedProvider: volumeSnapshotter,
})
locationsInformer = informers.NewSharedInformerFactory(fake.NewSimpleClientset(), 0).Velero().V1().VolumeSnapshotLocations()
)
@ -241,30 +241,30 @@ func TestExecutePVAction_SnapshotRestores(t *testing.T) {
}
r := &pvRestorer{
logger: velerotest.NewLogger(),
backup: tc.backup,
volumeSnapshots: tc.volumeSnapshots,
snapshotLocationLister: locationsInformer.Lister(),
blockStoreGetter: blockStoreGetter,
logger: velerotest.NewLogger(),
backup: tc.backup,
volumeSnapshots: tc.volumeSnapshots,
snapshotLocationLister: locationsInformer.Lister(),
volumeSnapshotterGetter: volumeSnapshotterGetter,
}
blockStore.On("Init", mock.Anything).Return(nil)
blockStore.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("Init", mock.Anything).Return(nil)
volumeSnapshotter.On("CreateVolumeFromSnapshot", tc.expectedSnapshotID, tc.expectedVolumeType, tc.expectedVolumeAZ, tc.expectedVolumeIOPS).Return("volume-1", nil)
volumeSnapshotter.On("SetVolumeID", tc.obj, "volume-1").Return(tc.obj, nil)
_, err := r.executePVAction(tc.obj)
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 {
return nil, errors.New("block store not found for provider")
return nil, errors.New("volume snapshotter not found for provider")
} else {
return bs, nil
}

View File

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

View File

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

View File

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