add useful Ark tags to snapshots
Signed-off-by: Steve Kriss <steve@heptio.com>pull/341/head
parent
df985bca74
commit
a05ae1a7cf
|
@ -310,8 +310,13 @@ func (ib *defaultItemBackupper) takePVSnapshot(pv runtime.Unstructured, backup *
|
||||||
|
|
||||||
log = log.WithField("volumeID", volumeID)
|
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")
|
log.Info("Snapshotting PersistentVolume")
|
||||||
snapshotID, err := ib.snapshotService.CreateSnapshot(volumeID, pvFailureDomainZone)
|
snapshotID, err := ib.snapshotService.CreateSnapshot(volumeID, pvFailureDomainZone, tags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// log+error on purpose - log goes to the per-backup log file, error goes to the backup
|
// log+error on purpose - log goes to the per-backup log file, error goes to the backup
|
||||||
log.WithError(err).Error("error creating snapshot")
|
log.WithError(err).Error("error creating snapshot")
|
||||||
|
|
|
@ -29,7 +29,7 @@ type SnapshotService interface {
|
||||||
// CreateSnapshot triggers a snapshot for the specified cloud volume and tags it with metadata.
|
// 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
|
// it returns the cloud snapshot ID, or an error if a problem is encountered triggering the snapshot via
|
||||||
// the cloud API.
|
// 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
|
// 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
|
// snapshot and volume characteristics. Returns the cloud volume ID, or an error if a problem is
|
||||||
|
@ -53,8 +53,6 @@ type SnapshotService interface {
|
||||||
const (
|
const (
|
||||||
volumeCreateWaitTimeout = 30 * time.Second
|
volumeCreateWaitTimeout = 30 * time.Second
|
||||||
volumeCreatePollInterval = 1 * time.Second
|
volumeCreatePollInterval = 1 * time.Second
|
||||||
snapshotTagKey = "tag-key"
|
|
||||||
snapshotTagVal = "ark-snapshot"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type snapshotService struct {
|
type snapshotService struct {
|
||||||
|
@ -94,11 +92,7 @@ func (sr *snapshotService) CreateVolumeFromSnapshot(snapshotID string, volumeTyp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sr *snapshotService) CreateSnapshot(volumeID, volumeAZ string) (string, error) {
|
func (sr *snapshotService) CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (string, error) {
|
||||||
tags := map[string]string{
|
|
||||||
snapshotTagKey: snapshotTagVal,
|
|
||||||
}
|
|
||||||
|
|
||||||
return sr.blockStore.CreateSnapshot(volumeID, volumeAZ, tags)
|
return sr.blockStore.CreateSnapshot(volumeID, volumeAZ, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ type FakeSnapshotService struct {
|
||||||
VolumeIDSet string
|
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 {
|
if _, exists := s.SnapshottableVolumes[volumeID]; !exists {
|
||||||
return "", errors.New("snapshottable volume not found")
|
return "", errors.New("snapshottable volume not found")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue