error if restic repo identifier can't be determined

Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
Steve Kriss
2019-08-08 15:06:49 -06:00
parent 00882c2de4
commit 8b6c505817
3 changed files with 90 additions and 22 deletions

View File

@@ -152,9 +152,21 @@ func (c *resticRepositoryController) initializeRepo(req *v1.ResticRepository, lo
return c.patchResticRepository(req, repoNotReady(err.Error()))
}
repoIdentifier, err := restic.GetRepoIdentifier(loc, req.Spec.VolumeNamespace)
if err != nil {
return c.patchResticRepository(req, func(r *v1.ResticRepository) {
r.Status.Message = err.Error()
r.Status.Phase = v1.ResticRepositoryPhaseNotReady
if r.Spec.MaintenanceFrequency.Duration <= 0 {
r.Spec.MaintenanceFrequency = metav1.Duration{Duration: restic.DefaultMaintenanceFrequency}
}
})
}
// defaulting - if the patch fails, return an error so the item is returned to the queue
if err := c.patchResticRepository(req, func(r *v1.ResticRepository) {
r.Spec.ResticIdentifier = restic.GetRepoIdentifier(loc, r.Spec.VolumeNamespace)
r.Spec.ResticIdentifier = repoIdentifier
if r.Spec.MaintenanceFrequency.Duration <= 0 {
r.Spec.MaintenanceFrequency = metav1.Duration{Duration: restic.DefaultMaintenanceFrequency}
@@ -236,6 +248,11 @@ func dueForMaintenance(req *v1.ResticRepository, now time.Time) bool {
}
func (c *resticRepositoryController) checkNotReadyRepo(req *v1.ResticRepository, log logrus.FieldLogger) error {
// no identifier: can't possibly be ready, so just return
if req.Spec.ResticIdentifier == "" {
return nil
}
log.Info("Checking restic repository for readiness")
// we need to ensure it (first check, if check fails, attempt to init)