Set default backup TTL

Set default backup TTL to 30 days when TTL
is not provided in the backup yaml configuration.

Updates #138

Signed-off-by: Rohan Vora <vorar@vmware.com>
This commit is contained in:
Rohan Vora
2019-04-04 14:59:13 -07:00
parent a519547efc
commit 4beb8aab3c
5 changed files with 78 additions and 4 deletions

View File

@@ -83,11 +83,15 @@ const (
defaultClientBurst int = 30
defaultProfilerAddress = "localhost:6060"
// the default TTL for a backup
defaultBackupTTL = 30 * 24 * time.Hour
)
type serverConfig struct {
pluginDir, metricsAddress, defaultBackupLocation string
backupSyncPeriod, podVolumeOperationTimeout, resourceTerminatingTimeout time.Duration
defaultBackupTTL time.Duration
restoreResourcePriorities []string
defaultVolumeSnapshotLocations map[string]string
restoreOnly bool
@@ -106,6 +110,7 @@ func NewCommand() *cobra.Command {
defaultBackupLocation: "default",
defaultVolumeSnapshotLocations: make(map[string]string),
backupSyncPeriod: defaultBackupSyncPeriod,
defaultBackupTTL: defaultBackupTTL,
podVolumeOperationTimeout: defaultPodVolumeOperationTimeout,
restoreResourcePriorities: defaultRestorePriorities,
clientQPS: defaultClientQPS,
@@ -171,6 +176,7 @@ func NewCommand() *cobra.Command {
command.Flags().IntVar(&config.clientBurst, "client-burst", config.clientBurst, "maximum number of requests by the server to the Kubernetes API in a short period of time")
command.Flags().StringVar(&config.profilerAddress, "profiler-address", config.profilerAddress, "the address to expose the pprof profiler")
command.Flags().DurationVar(&config.resourceTerminatingTimeout, "terminating-resource-timeout", config.resourceTerminatingTimeout, "how long to wait on persistent volumes and namespaces to terminate during a restore before timing out")
command.Flags().DurationVar(&config.defaultBackupTTL, "default-backup-ttl", config.defaultBackupTTL, "how long to wait by default before backups can be garbage collected")
return command
}
@@ -565,6 +571,7 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
backupTracker,
s.sharedInformerFactory.Velero().V1().BackupStorageLocations(),
s.config.defaultBackupLocation,
s.config.defaultBackupTTL,
s.sharedInformerFactory.Velero().V1().VolumeSnapshotLocations(),
defaultVolumeSnapshotLocations,
s.metrics,