add useful Ark tags to snapshots

Signed-off-by: Steve Kriss <steve@heptio.com>
pull/341/head
Steve Kriss 2018-03-02 14:04:06 -08:00
parent df985bca74
commit a05ae1a7cf
3 changed files with 9 additions and 10 deletions

View File

@ -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")

View File

@ -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)
}

View File

@ -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")
}