-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows explicit include/exclude of namespaces on restores #59
Allows explicit include/exclude of namespaces on restores #59
Conversation
Can one of the admins verify this patch? |
ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/apis/ark/v1/restore.go
Outdated
IncludedNamespaces []string `json:"includedNamespaces"` | ||
|
||
// ExcludedNamespaces contains a list of namespaces that are not | ||
// included in the backup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace "backup" with "restore"
pkg/cmd/cli/restore/create.go
Outdated
NamespaceMappings: flag.NewMap().WithEntryDelimiter(",").WithKeyValueDelimiter(":"), | ||
RestoreVolumes: flag.NewOptionalBool(nil), | ||
} | ||
} | ||
|
||
func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) { | ||
flags.Var(&o.Labels, "labels", "labels to apply to the restore") | ||
flags.Var(&o.Namespaces, "namespaces", "comma-separated list of namespaces to restore") | ||
flags.Var(&o.IncludeNamespaces, "include-namespaces", "namespaces to include in the backup (use '*' for all namespaces)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace "backup" with "restore"
pkg/cmd/cli/restore/create.go
Outdated
flags.Var(&o.Labels, "labels", "labels to apply to the restore") | ||
flags.Var(&o.Namespaces, "namespaces", "comma-separated list of namespaces to restore") | ||
flags.Var(&o.IncludeNamespaces, "include-namespaces", "namespaces to include in the backup (use '*' for all namespaces)") | ||
flags.Var(&o.ExcludeNamespaces, "exclude-namespaces", "namespaces to exclude from the backup") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace "backup" with "restore"
@@ -278,6 +285,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.") | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should validate the the included/excluded namespaces are a valid set of includes/excludes. See backup controller
pkg/controller/restore_controller.go
Outdated
@@ -278,6 +285,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.") | |||
} | |||
|
|||
if len(itm.Spec.Namespaces) > 0 && len(itm.Spec.IncludedNamespaces) > 0 { | |||
validationErrors = append(validationErrors, "Namespace and ItemNamespaces can not both be defined on the backup spec.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Namespaces and IncludedNamespaces cannot both be defined on the restore spec."
Thanks for the feedback, I was curious about that as well. The one thing that I hadn't initially thought of is that anyone that has Ark installed then would need to upgrade. I have seen project, specifically Helm, that have a tight coupling with Server vs. Client version. While it's somewhat frustrating at times, I do see how it would significantly reduce the complexity over time until the API reaches a point of stability. |
So having a bit more time to look at this properly my tests are failing due to some of the complexities around the handling of the migration of Namespace and the new namespace validation piece. I will wait to hear if we need to support the retro attribute and if not just rework this a bit. Also as a note, the Jenkins auth doesn't allow viewing of the job currently even with the Github OAuth authorized. |
I'm fine removing the old flag. We'll make sure to include the required UX change in the release notes/changelog. Everyone ok with that? |
Works for me. |
@jrnt30 please go ahead and remove the old flag - thanks! |
- Introduces similar Include/Exclude declaration on the Restore resource and cli flags - Kept support for legacy Namespaces attribute until it could be deprecating. Defining both IncludeNamespaces and Namespaces results in a validation error and the Restore will not be processed (shouldn't be able to occur) Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
- Adding in additional test to ensure *Namespaces attributes don't directly conflict logically with one another - Additional PR changes around naming/typos Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
- Per discussion, there is no reason to deal with the complexity of backwards compatibility with the Namespace attribute on the Restore domain. - Also noticed there was an error on the validation of the BackupController where the message would actually just be the index of the error and not the contents of the message itself. Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
- Per discussion, there is no reason to deal with the complexity of backwards compatibility with the Namespace attribute on the Restore domain. - Also noticed there was an error on the validation of the BackupController where the message would actually just be the index of the error and not the contents of the message itself. Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
@@ -292,11 +292,11 @@ func cloneBackup(in interface{}) (*api.Backup, error) { | |||
func (controller *backupController) getValidationErrors(itm *api.Backup) []string { | |||
var validationErrors []string | |||
|
|||
for err := range collections.ValidateIncludesExcludes(itm.Spec.IncludedResources, itm.Spec.ExcludedResources) { | |||
for _, err := range collections.ValidateIncludesExcludes(itm.Spec.IncludedResources, itm.Spec.ExcludedResources) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrnt30 thanks for catching!
updates LGTM, thanks @jrnt30 ! |
@ncdc pls review/merge if you approve. |
Update Dockerfile.ubi to use pinned restic
Fixes #22
resource and cli flags
Signed-off-by: Justin Nauman justin.r.nauman@gmail.com