Change restic prune default interval to 7d and make user-configurable (#1864)

* change restic prune default interval to 7d, add server flag for it

Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
Steve Kriss
2019-09-10 11:58:42 -07:00
committed by KubeKween
parent 26e06dae53
commit 6623e1f273
7 changed files with 135 additions and 93 deletions
+21 -12
View File
@@ -41,10 +41,11 @@ import (
type resticRepositoryController struct {
*genericController
resticRepositoryClient velerov1client.ResticRepositoriesGetter
resticRepositoryLister listers.ResticRepositoryLister
backupLocationLister listers.BackupStorageLocationLister
repositoryManager restic.RepositoryManager
resticRepositoryClient velerov1client.ResticRepositoriesGetter
resticRepositoryLister listers.ResticRepositoryLister
backupLocationLister listers.BackupStorageLocationLister
repositoryManager restic.RepositoryManager
defaultMaintenanceFrequency time.Duration
clock clock.Clock
}
@@ -56,14 +57,22 @@ func NewResticRepositoryController(
resticRepositoryClient velerov1client.ResticRepositoriesGetter,
backupLocationInformer informers.BackupStorageLocationInformer,
repositoryManager restic.RepositoryManager,
defaultMaintenanceFrequency time.Duration,
) Interface {
c := &resticRepositoryController{
genericController: newGenericController("restic-repository", logger),
resticRepositoryClient: resticRepositoryClient,
resticRepositoryLister: resticRepositoryInformer.Lister(),
backupLocationLister: backupLocationInformer.Lister(),
repositoryManager: repositoryManager,
clock: &clock.RealClock{},
genericController: newGenericController("restic-repository", logger),
resticRepositoryClient: resticRepositoryClient,
resticRepositoryLister: resticRepositoryInformer.Lister(),
backupLocationLister: backupLocationInformer.Lister(),
repositoryManager: repositoryManager,
defaultMaintenanceFrequency: defaultMaintenanceFrequency,
clock: &clock.RealClock{},
}
if c.defaultMaintenanceFrequency <= 0 {
logger.Infof("Invalid default restic maintenance frequency, setting to %v", restic.DefaultMaintenanceFrequency)
c.defaultMaintenanceFrequency = restic.DefaultMaintenanceFrequency
}
c.syncHandler = c.processQueueItem
@@ -159,7 +168,7 @@ func (c *resticRepositoryController) initializeRepo(req *v1.ResticRepository, lo
r.Status.Phase = v1.ResticRepositoryPhaseNotReady
if r.Spec.MaintenanceFrequency.Duration <= 0 {
r.Spec.MaintenanceFrequency = metav1.Duration{Duration: restic.DefaultMaintenanceFrequency}
r.Spec.MaintenanceFrequency = metav1.Duration{Duration: c.defaultMaintenanceFrequency}
}
})
}
@@ -169,7 +178,7 @@ func (c *resticRepositoryController) initializeRepo(req *v1.ResticRepository, lo
r.Spec.ResticIdentifier = repoIdentifier
if r.Spec.MaintenanceFrequency.Duration <= 0 {
r.Spec.MaintenanceFrequency = metav1.Duration{Duration: restic.DefaultMaintenanceFrequency}
r.Spec.MaintenanceFrequency = metav1.Duration{Duration: c.defaultMaintenanceFrequency}
}
}); err != nil {
return err