Add labels to scheduled snapshot descrbing the schedule
@@ -27,6 +27,13 @@ const (
nameTimeSuffixFormat string = "2006-01-02-150405"
validateCRDInterval time.Duration = 5 * time.Second
validateCRDTimeout time.Duration = 1 * time.Minute
+
+ // SnapshotScheduleNameLabel Label used to specify the name of schedule that
+ // created the snapshot
+ SnapshotScheduleNameLabel = "stork.libopenstorage.org/snapshotScheduleName"
+ // SnapshotSchedulePolicyTypeLabel Label used to specify the type of the
+ // policy that triggered the snapshot
+ SnapshotSchedulePolicyTypeLabel = "stork.libopenstorage.org/snapshotSchedulePolicyType"
)
// SnapshotScheduleController reconciles VolumeSnapshotSchedule objects
@@ -255,6 +262,12 @@ func (s *SnapshotScheduleController) startVolumeSnapshot(snapshotSchedule *stork
},
Spec: snapshotSchedule.Spec.Template.Spec,
}
+ if snapshot.Metadata.Labels == nil {
+ snapshot.Metadata.Labels = make(map[string]string)
+ }
+ snapshot.Metadata.Labels[SnapshotScheduleNameLabel] = snapshotSchedule.Name
+ snapshot.Metadata.Labels[SnapshotSchedulePolicyTypeLabel] = string(policyType)
+
log.VolumeSnapshotScheduleLog(snapshotSchedule).Infof("Starting snapshot %v", snapshotName)
// If reclaim policy is set to Delete, this will delete the snapshots
// created by this snapshotschedule when the schedule object is deleted
