Merge pull request #59 from jrnt30/explicit-includes-excludes-restore

Allows explicit include/exclude of namespaces on restores
This commit is contained in:
Andy Goldstein
2017-09-06 11:21:24 -04:00
committed by GitHub
11 changed files with 122 additions and 58 deletions
+9 -4
View File
@@ -40,6 +40,7 @@ import (
informers "github.com/heptio/ark/pkg/generated/informers/externalversions/ark/v1"
listers "github.com/heptio/ark/pkg/generated/listers/ark/v1"
"github.com/heptio/ark/pkg/restore"
"github.com/heptio/ark/pkg/util/collections"
)
type restoreController struct {
@@ -220,6 +221,10 @@ func (controller *restoreController) processRestore(key string) error {
return err
}
if len(restore.Spec.IncludedNamespaces) == 0 {
restore.Spec.IncludedNamespaces = []string{"*"}
}
// validation
if restore.Status.ValidationErrors = controller.getValidationErrors(restore); len(restore.Status.ValidationErrors) > 0 {
restore.Status.Phase = api.RestorePhaseFailedValidation
@@ -227,10 +232,6 @@ func (controller *restoreController) processRestore(key string) error {
restore.Status.Phase = api.RestorePhaseInProgress
}
if len(restore.Spec.Namespaces) == 0 {
restore.Spec.Namespaces = []string{"*"}
}
// update status
updatedRestore, err := controller.restoreClient.Restores(ns).Update(restore)
if err != nil {
@@ -279,6 +280,10 @@ func (controller *restoreController) getValidationErrors(itm *api.Restore) []str
validationErrors = append(validationErrors, "BackupName must be non-empty and correspond to the name of a backup in object storage.")
}
for _, err := range collections.ValidateIncludesExcludes(itm.Spec.IncludedNamespaces, itm.Spec.ExcludedNamespaces) {
validationErrors = append(validationErrors, fmt.Sprintf("Invalid included/excluded namespace lists: %v", err))
}
if !controller.pvProviderExists && itm.Spec.RestorePVs != nil && *itm.Spec.RestorePVs {
validationErrors = append(validationErrors, "Server is not configured for PV snapshot restores")
}