Skip to content
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

Merged
merged 4 commits into from
Sep 6, 2017
Merged

Allows explicit include/exclude of namespaces on restores #59

merged 4 commits into from
Sep 6, 2017

Conversation

jrnt30
Copy link
Contributor

@jrnt30 jrnt30 commented Aug 28, 2017

Fixes #22

  • Introduces similar Include/Exclude declaration on the Restore
    resource and cli flags
  • Removed the Namespace attribute
  • Fixed a few small issues with the backup validation

Signed-off-by: Justin Nauman justin.r.nauman@gmail.com

@heptibot
Copy link

Can one of the admins verify this patch?

@ncdc
Copy link
Contributor

ncdc commented Aug 29, 2017

ok to test

Copy link
Member

@skriss skriss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, @jrnt30! I'd like to get @ncdc's opinion on whether it's worth retaining support for the Namespaces field/flag at all -- we are still in alpha so some breaking changes are to be expected at this stage. In the meantime, I reviewed and added a few minor comments.

IncludedNamespaces []string `json:"includedNamespaces"`

// ExcludedNamespaces contains a list of namespaces that are not
// included in the backup.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace "backup" with "restore"

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)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace "backup" with "restore"

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")
Copy link
Member

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.")
}

Copy link
Member

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

@@ -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.")
Copy link
Member

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."

@jrnt30
Copy link
Contributor Author

jrnt30 commented Aug 30, 2017

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.

@jrnt30
Copy link
Contributor Author

jrnt30 commented Aug 31, 2017

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.

@jrnt30 jrnt30 changed the title Allows explicit include/exclude of namespaces on restores WIP: Allows explicit include/exclude of namespaces on restores Aug 31, 2017
@ncdc
Copy link
Contributor

ncdc commented Sep 5, 2017

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?

@skriss
Copy link
Member

skriss commented Sep 5, 2017

Works for me.

@ncdc
Copy link
Contributor

ncdc commented Sep 5, 2017

@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>
@jrnt30 jrnt30 changed the title WIP: Allows explicit include/exclude of namespaces on restores Allows explicit include/exclude of namespaces on restores Sep 5, 2017
- 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrnt30 thanks for catching!

@skriss
Copy link
Member

skriss commented Sep 6, 2017

updates LGTM, thanks @jrnt30 !

@skriss
Copy link
Member

skriss commented Sep 6, 2017

@ncdc pls review/merge if you approve.

@ncdc ncdc added this to the v0.4.0 milestone Sep 6, 2017
@ncdc ncdc merged commit 305e7fc into vmware-tanzu:master Sep 6, 2017
dymurray pushed a commit to dymurray/velero that referenced this pull request Jun 24, 2020
Update Dockerfile.ubi to use pinned restic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants