diff --git a/pkg/apis/velero/v1/backup.go b/pkg/apis/velero/v1/backup.go index 1ec566f39..36c3e198f 100644 --- a/pkg/apis/velero/v1/backup.go +++ b/pkg/apis/velero/v1/backup.go @@ -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. @@ -193,27 +193,6 @@ type BackupStatus struct { VolumeSnapshotsCompleted int `json:"volumeSnapshotsCompleted"` } -// VolumeBackupInfo captures the required information about -// a PersistentVolume at backup time to be able to restore -// it later. -type VolumeBackupInfo struct { - // SnapshotID is the ID of the snapshot taken in the cloud - // provider API of this volume. - SnapshotID string `json:"snapshotID"` - - // Type is the type of the disk/volume in the cloud provider - // API. - Type string `json:"type"` - - // AvailabilityZone is the where the volume is provisioned - // in the cloud provider. - AvailabilityZone string `json:"availabilityZone,omitempty"` - - // Iops is the optional value of provisioned IOPS for the - // disk/volume in the cloud provider API. - Iops *int64 `json:"iops,omitempty"` -} - // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/velero/v1/zz_generated.deepcopy.go b/pkg/apis/velero/v1/zz_generated.deepcopy.go index 04b2064fe..7a29f0204 100644 --- a/pkg/apis/velero/v1/zz_generated.deepcopy.go +++ b/pkg/apis/velero/v1/zz_generated.deepcopy.go @@ -1261,27 +1261,6 @@ func (in *StorageType) DeepCopy() *StorageType { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VolumeBackupInfo) DeepCopyInto(out *VolumeBackupInfo) { - *out = *in - if in.Iops != nil { - in, out := &in.Iops, &out.Iops - *out = new(int64) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeBackupInfo. -func (in *VolumeBackupInfo) DeepCopy() *VolumeBackupInfo { - if in == nil { - return nil - } - out := new(VolumeBackupInfo) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeSnapshotLocation) DeepCopyInto(out *VolumeSnapshotLocation) { *out = *in diff --git a/pkg/backup/item_backupper_test.go b/pkg/backup/item_backupper_test.go index 5c4844634..945bc9ed6 100644 --- a/pkg/backup/item_backupper_test.go +++ b/pkg/backup/item_backupper_test.go @@ -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. @@ -169,7 +169,7 @@ func TestBackupItemNoSkips(t *testing.T) { customActionAdditionalItemIdentifiers []velero.ResourceIdentifier customActionAdditionalItems []runtime.Unstructured groupResource string - snapshottableVolumes map[string]v1.VolumeBackupInfo + snapshottableVolumes map[string]velerotest.VolumeBackupInfo snapshotError error additionalItemError error trackedPVCs sets.String @@ -300,7 +300,7 @@ func TestBackupItemNoSkips(t *testing.T) { expectExcluded: false, expectedTarHeaderName: "resources/persistentvolumes/cluster/mypv.json", groupResource: "persistentvolumes", - snapshottableVolumes: map[string]v1.VolumeBackupInfo{ + snapshottableVolumes: map[string]velerotest.VolumeBackupInfo{ "vol-abc123": {SnapshotID: "snapshot-1", AvailabilityZone: "us-east-1c"}, }, }, @@ -314,7 +314,7 @@ func TestBackupItemNoSkips(t *testing.T) { groupResource: "persistentvolumes", // empty snapshottableVolumes causes a volumeSnapshotter to be created, but no // snapshots are expected to be taken. - snapshottableVolumes: map[string]v1.VolumeBackupInfo{}, + snapshottableVolumes: map[string]velerotest.VolumeBackupInfo{}, trackedPVCs: sets.NewString(key("pvc-ns", "pvc"), key("another-pvc-ns", "another-pvc")), }, { @@ -325,7 +325,7 @@ func TestBackupItemNoSkips(t *testing.T) { expectExcluded: false, expectedTarHeaderName: "resources/persistentvolumes/cluster/mypv.json", groupResource: "persistentvolumes", - snapshottableVolumes: map[string]v1.VolumeBackupInfo{ + snapshottableVolumes: map[string]velerotest.VolumeBackupInfo{ "vol-abc123": {SnapshotID: "snapshot-1", AvailabilityZone: "us-east-1c"}, }, trackedPVCs: sets.NewString(key("another-pvc-ns", "another-pvc")), @@ -336,7 +336,7 @@ func TestBackupItemNoSkips(t *testing.T) { 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: true, groupResource: "persistentvolumes", - snapshottableVolumes: map[string]v1.VolumeBackupInfo{ + snapshottableVolumes: map[string]velerotest.VolumeBackupInfo{ "vol-abc123": {SnapshotID: "snapshot-1", AvailabilityZone: "us-east-1c"}, }, snapshotError: fmt.Errorf("failure"), @@ -716,7 +716,7 @@ func TestTakePVSnapshot(t *testing.T) { expectError bool expectedVolumeID string expectedSnapshotsTaken int - volumeInfo map[string]v1.VolumeBackupInfo + volumeInfo map[string]velerotest.VolumeBackupInfo }{ { name: "snapshot disabled", @@ -737,7 +737,7 @@ func TestTakePVSnapshot(t *testing.T) { expectedSnapshotsTaken: 1, expectedVolumeID: "vol-abc123", ttl: 5 * time.Minute, - volumeInfo: map[string]v1.VolumeBackupInfo{ + volumeInfo: map[string]velerotest.VolumeBackupInfo{ "vol-abc123": {Type: "gp", SnapshotID: "snap-1", AvailabilityZone: "us-east-1c"}, }, }, @@ -749,7 +749,7 @@ func TestTakePVSnapshot(t *testing.T) { expectedSnapshotsTaken: 1, expectedVolumeID: "vol-abc123", ttl: 5 * time.Minute, - volumeInfo: map[string]v1.VolumeBackupInfo{ + volumeInfo: map[string]velerotest.VolumeBackupInfo{ "vol-abc123": {Type: "io1", Iops: &iops, SnapshotID: "snap-1", AvailabilityZone: "us-east-1c"}, }, }, @@ -768,7 +768,7 @@ func TestTakePVSnapshot(t *testing.T) { expectedSnapshotsTaken: 1, expectedVolumeID: "vol-abc123", ttl: 5 * time.Minute, - volumeInfo: map[string]v1.VolumeBackupInfo{ + volumeInfo: map[string]velerotest.VolumeBackupInfo{ "vol-abc123": {Type: "gp", SnapshotID: "snap-1"}, }, }, diff --git a/pkg/restore/restore_test.go b/pkg/restore/restore_test.go index ff0adcfda..13a3bfefe 100644 --- a/pkg/restore/restore_test.go +++ b/pkg/restore/restore_test.go @@ -654,7 +654,7 @@ func TestRestoreResourceForNamespace(t *testing.T) { pvRestorer: &pvRestorer{ logger: logging.DefaultLogger(logrus.DebugLevel), volumeSnapshotterGetter: &fakeVolumeSnapshotterGetter{ - volumeMap: map[api.VolumeBackupInfo]string{{SnapshotID: "snap-1"}: "volume-1"}, + volumeMap: map[velerotest.VolumeBackupInfo]string{{SnapshotID: "snap-1"}: "volume-1"}, volumeID: "volume-1", }, snapshotLocationLister: snapshotLocationLister, @@ -1786,7 +1786,7 @@ type fakeAction struct { type fakeVolumeSnapshotterGetter struct { fakeVolumeSnapshotter *velerotest.FakeVolumeSnapshotter - volumeMap map[api.VolumeBackupInfo]string + volumeMap map[velerotest.VolumeBackupInfo]string volumeID string } diff --git a/pkg/util/test/fake_volume_snapshotter.go b/pkg/util/test/fake_volume_snapshotter.go index 9b1c58f0f..1a9166943 100644 --- a/pkg/util/test/fake_volume_snapshotter.go +++ b/pkg/util/test/fake_volume_snapshotter.go @@ -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. @@ -21,19 +21,24 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/sets" - - api "github.com/heptio/velero/pkg/apis/velero/v1" ) +type VolumeBackupInfo struct { + SnapshotID string + Type string + Iops *int64 + AvailabilityZone string +} + type FakeVolumeSnapshotter struct { // SnapshotID->VolumeID SnapshotsTaken sets.String // VolumeID -> (SnapshotID, Type, Iops) - SnapshottableVolumes map[string]api.VolumeBackupInfo + SnapshottableVolumes map[string]VolumeBackupInfo // VolumeBackupInfo -> VolumeID - RestorableVolumes map[api.VolumeBackupInfo]string + RestorableVolumes map[VolumeBackupInfo]string VolumeID string VolumeIDSet string @@ -67,7 +72,7 @@ func (bs *FakeVolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType return "", bs.Error } - key := api.VolumeBackupInfo{ + key := VolumeBackupInfo{ SnapshotID: snapshotID, Type: volumeType, Iops: iops,