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

Excluding nodes from restoration #99

Merged
merged 1 commit into from
Oct 6, 2017
Merged

Excluding nodes from restoration #99

merged 1 commit into from
Oct 6, 2017

Conversation

jrnt30
Copy link
Contributor

@jrnt30 jrnt30 commented Sep 19, 2017

Fixes #71

  • Introduced a blacklist of resources that are non-restorable. The
    goal being that the backup can still include these resources for
    logging/auditing purposes but they are explicitly added to
    ExcludedResources in the RestorController's "defaulting" logic
    to ensure that if someone were to explicitly ask for Node that
    they would be expressly denied.

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

@ncdc
Copy link
Contributor

ncdc commented Sep 19, 2017

@jrnt30 we need to be able to restore some endpoints: those that are managed by a user. Those are services that don't have a selector specified.

@ncdc
Copy link
Contributor

ncdc commented Sep 19, 2017

Also FYI the GitHub "fixes" notation requires each issue to have "fixes" in front of it.

@jrnt30
Copy link
Contributor Author

jrnt30 commented Sep 19, 2017

Thanks for the clarification. I'll throw this in WIP and see if I can use what I have going or if it needs to be significantly refactored for endpoints. If so I will probably just remove the endpoint support for now.

@jrnt30 jrnt30 changed the title Excluding nodes and endpoints from restoration WIP: Excluding nodes and endpoints from restoration Sep 19, 2017
@jrnt30 jrnt30 changed the title WIP: Excluding nodes and endpoints from restoration Excluding nodes and endpoints from restoration Sep 25, 2017
@@ -229,6 +234,13 @@ func (controller *restoreController) processRestore(key string) error {
restore.Spec.IncludedResources = []string{"*"}
}

curIncludes := sets.NewString(restore.Spec.ExcludedResources...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call this excludedResources or something other than *Includes? 😄

@ncdc
Copy link
Contributor

ncdc commented Sep 26, 2017

Generally LGTM. Just the 1 comment on variable naming. @skriss any other comments?

@@ -284,6 +296,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 errs := collections.ValidateIncludesExcludes(itm.Spec.IncludedResources, nonRestorableResources); len(errs) > 0 {
Copy link
Member

@skriss skriss Sep 26, 2017

Choose a reason for hiding this comment

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

This could be misleading if the error returned from ValidateIncludesExcludes is due to something other than nodes being explicitly included. Maybe rather than calling ValidateIncludesExcludes for this, just check if anything in the nonRestorable list is in IncludedResources? Otherwise LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thank you.

@skriss skriss changed the title Excluding nodes and endpoints from restoration Excluding nodes from restoration Sep 26, 2017
)

// NonRestorableResources is a blacklist for the restoration process. Any resources
Copy link
Contributor

Choose a reason for hiding this comment

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

Leading lowercase n

Copy link
Contributor

Choose a reason for hiding this comment

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

I am tempted to suggest moving this logic from the controller into pkg/restore. That way, anyone using Ark as a library would benefit from it. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jrnt30 bump

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try and take a look on the train on that work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at this closer again, I suppose I related the blacklist of resources similarly to the setting of a default as we do with the IncludedResources and IncludedNamespaces.

If we push this down to the pkg/restore I don't think as cleanly segregates the validation logic being exposed to the client either.

Were you thinking that we put this in the kubernetesRestorer.Restore directly or simply a utility function checking these things? I'm afraid I may be missing part of your thought process here (it may be simply that you are proposing a larger refactor than I am considering looking at the type signature here).

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's say that someone decides to pull in github.com/heptio/ark/pkg/... to use Ark as a library (we already know of at least one project interested in doing so). If the logic to exclude nodes is only in the controller, then anyone using the library directly and not using the controller would end up restoring nodes unless they also write logic to exclude them.

The more I think about this, given that the other defaulting logic is in the controllers, I think it's fine to include this here for now in the controller. We may decide to move more logic "down" in the future, but I don't think that possibility needs to hold up this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood, thanks. I do think having that more centralized may be beneficial in those cases.

Out of curiosity, is the project you are referring to public?

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -284,6 +296,13 @@ 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.")
}

excludedResources := sets.NewString(itm.Spec.IncludedResources...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename var to includedResources

@ncdc
Copy link
Contributor

ncdc commented Oct 4, 2017

@jrnt30 squash please & I'll merge

@ncdc
Copy link
Contributor

ncdc commented Oct 5, 2017

@jrnt30 sorry, decided to get logrus in first. Mind rebasing?

- Introduced a blacklist of resources that are non-restorable.  The
goal being that the backup can still include these resources for
logging/auditing purposes but they are explicitly added to
ExcludedResources in the RestorController's "defaulting" logic
to ensure that if someone were to explicitly ask for nodes
that they would be expressly denied.

Signed-off-by: Justin Nauman <justin.r.nauman@gmail.com>
@jrnt30
Copy link
Contributor Author

jrnt30 commented Oct 6, 2017

No problem, that was a big one for sure. Should be good now.

@ncdc ncdc self-assigned this Oct 6, 2017
@ncdc ncdc added this to the v0.5.0 milestone Oct 6, 2017
@ncdc ncdc merged commit 9f9908f into vmware-tanzu:master Oct 6, 2017
jmontleon pushed a commit to jmontleon/velero that referenced this pull request Jul 7, 2021
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.

3 participants