diff --git a/pkg/backup/item_backupper.go b/pkg/backup/item_backupper.go index d914b7411..0648081bf 100644 --- a/pkg/backup/item_backupper.go +++ b/pkg/backup/item_backupper.go @@ -310,8 +310,13 @@ func (ib *defaultItemBackupper) takePVSnapshot(pv runtime.Unstructured, backup * log = log.WithField("volumeID", volumeID) + tags := map[string]string{ + "ark.heptio.com/backup": backup.Name, + "ark.heptio.com/pv": metadata.GetName(), + } + log.Info("Snapshotting PersistentVolume") - snapshotID, err := ib.snapshotService.CreateSnapshot(volumeID, pvFailureDomainZone) + snapshotID, err := ib.snapshotService.CreateSnapshot(volumeID, pvFailureDomainZone, tags) if err != nil { // log+error on purpose - log goes to the per-backup log file, error goes to the backup log.WithError(err).Error("error creating snapshot") diff --git a/pkg/cloudprovider/snapshot_service.go b/pkg/cloudprovider/snapshot_service.go index 1e124f1fb..9ad886442 100644 --- a/pkg/cloudprovider/snapshot_service.go +++ b/pkg/cloudprovider/snapshot_service.go @@ -29,7 +29,7 @@ type SnapshotService interface { // CreateSnapshot triggers a snapshot for the specified cloud volume and tags it with metadata. // it returns the cloud snapshot ID, or an error if a problem is encountered triggering the snapshot via // the cloud API. - CreateSnapshot(volumeID, volumeAZ string) (string, error) + CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) // CreateVolumeFromSnapshot triggers a restore operation to create a new cloud volume from the specified // snapshot and volume characteristics. Returns the cloud volume ID, or an error if a problem is @@ -53,8 +53,6 @@ type SnapshotService interface { const ( volumeCreateWaitTimeout = 30 * time.Second volumeCreatePollInterval = 1 * time.Second - snapshotTagKey = "tag-key" - snapshotTagVal = "ark-snapshot" ) type snapshotService struct { @@ -94,11 +92,7 @@ func (sr *snapshotService) CreateVolumeFromSnapshot(snapshotID string, volumeTyp } } -func (sr *snapshotService) CreateSnapshot(volumeID, volumeAZ string) (string, error) { - tags := map[string]string{ - snapshotTagKey: snapshotTagVal, - } - +func (sr *snapshotService) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) { return sr.blockStore.CreateSnapshot(volumeID, volumeAZ, tags) } diff --git a/pkg/util/test/fake_snapshot_service.go b/pkg/util/test/fake_snapshot_service.go index 089e47b76..f5ffaaff7 100644 --- a/pkg/util/test/fake_snapshot_service.go +++ b/pkg/util/test/fake_snapshot_service.go @@ -39,7 +39,7 @@ type FakeSnapshotService struct { VolumeIDSet string } -func (s *FakeSnapshotService) CreateSnapshot(volumeID, volumeAZ string) (string, error) { +func (s *FakeSnapshotService) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) { if _, exists := s.SnapshottableVolumes[volumeID]; !exists { return "", errors.New("snapshottable volume not found") }