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

use old namespace in resource modifier #6724

Merged

Conversation

27149chen
Copy link
Contributor

@27149chen 27149chen commented Aug 31, 2023

Please add a summary of your change

Use old(origin) namespace in resource modifier conditions in case namespace may change during restore

Does your change fix a particular issue?

Fixes #(issue)

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

@27149chen
Copy link
Contributor Author

@anshulahuja98 PTAL

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #6724 (e2cd5f6) into main (2348099) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##             main    #6724   +/-   ##
=======================================
  Coverage   60.45%   60.45%           
=======================================
  Files         242      242           
  Lines       26029    26031    +2     
=======================================
+ Hits        15736    15738    +2     
  Misses       9187     9187           
  Partials     1106     1106           
Files Changed Coverage Δ
pkg/restore/restore.go 64.39% <0.00%> (+0.04%) ⬆️

📢 Have feedback on the report? Share it here.

for _, err := range errList {
errs.Add(namespace, err)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I personally feel it's better if we do changes with the new namespace, (resource modifier filter having new namespace). Since this will lead to less confusion IMO. And also easier for the end user to debug any issues in resourcemodifier setup.

Otherwise think of the scenario where the original namespace is already there in the cluster and wishes to restore to a diff namespace, IMO the filters should target the new namespace for clarity.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can also document this behaviour in docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I think the goal of resource modifier is to modify an object from old to new, so there is a mapping in resource modifier config(an old part and a new part). To me, name, namespace, label and old value in given path belong to the old part, and new value is the new part. If I want to restore an object with resource modifier, I will first write rules according the origin object and pass it to velero to perform the restore. I might later change my mind and want to change the namespace or not, the rules should remain unchanged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

so namespace is just part of the change which happens if you see.

There are the other RestoreItemAction plugins which can change the YAMLs based on various rules. Even there could be RIA to change the namespace based on certain rules.

In the design doc the approach we took was to modify just before creation and after all RIA / modifications are applied.

Our docs line could indicate that both namespace mapping and RIA would have run before Resourcemodifier is applied.

I think of RIA and namespace mapping together, either we do resourcemodifier before both or after both

In between ismore confusing IMO.

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 prefer to do resourcemodifier before both

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sseago I agree with you that a RIA should never change namespace, here is a bad example: vmware-tanzu/velero-plugin-for-csi#82

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some reasons for using old namespace:

  1. resource modifier is to modify an object from old to new, old object is more clear since new object can be changed.
  2. resource modifier is a config (ConfigMap), and may be a large one, it should be reusable when some restore options are changed, like namespace mapping

Copy link
Collaborator

Choose a reason for hiding this comment

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

@27149chen I think your second reason is the biggest reason to stick with the old namespace. Logically, namespace mapping is one of the last things to do -- first we change what we restore, then we change where we restore it to. And yes, you might have one backup that you're using as a template for restoring to different namespaces. Basically for any given backup, the old namespace will be valid for every restore that's made from it, but the new namespace may not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@27149chen So the CSI example seems like a bit of a special case. It's not arbitrarily changing namespace outside of the NS mapping -- if it were to do that, I suspect that it would break things. Instead, it's actually using the NS mapping and changing it here (same change as velero would eventually change without it), but the reason for it is that the namespace is then used to find the matching VolumeSnapshot resource, so it needs to use the new namespace here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@27149chen can you update the website docs and resource modifier design docs with this callout for changes done before NS mapping?
Post that we can get this checked in. Since overall folks are inline with your proposal of using old namespace, I agree with further comments and the majority.

Signed-off-by: lou <alex1988@outlook.com>
Signed-off-by: lou <alex1988@outlook.com>
Signed-off-by: lou <alex1988@outlook.com>
@27149chen
Copy link
Contributor Author

@anshulahuja98 docs updated

Signed-off-by: lou <alex1988@outlook.com>
@anshulahuja98 anshulahuja98 merged commit 246831d into vmware-tanzu:main Sep 8, 2023
23 of 24 checks passed
ywk253100 pushed a commit to ywk253100/velero that referenced this pull request Sep 8, 2023
* use old namespace in resource modifier

Signed-off-by: lou <alex1988@outlook.com>

* add changelog

Signed-off-by: lou <alex1988@outlook.com>

* update docs

Signed-off-by: lou <alex1988@outlook.com>

* updated after review

Signed-off-by: lou <alex1988@outlook.com>

---------

Signed-off-by: lou <alex1988@outlook.com>
anshulahuja98 pushed a commit to anshulahuja98/velero that referenced this pull request Sep 8, 2023
* use old namespace in resource modifier

Signed-off-by: lou <alex1988@outlook.com>

* add changelog

Signed-off-by: lou <alex1988@outlook.com>

* update docs

Signed-off-by: lou <alex1988@outlook.com>

* updated after review

Signed-off-by: lou <alex1988@outlook.com>

---------

Signed-off-by: lou <alex1988@outlook.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
ywk253100 pushed a commit to anshulahuja98/velero that referenced this pull request Sep 11, 2023
* use old namespace in resource modifier

Signed-off-by: lou <alex1988@outlook.com>

* add changelog

Signed-off-by: lou <alex1988@outlook.com>

* update docs

Signed-off-by: lou <alex1988@outlook.com>

* updated after review

Signed-off-by: lou <alex1988@outlook.com>

---------

Signed-off-by: lou <alex1988@outlook.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
anshulahuja98 pushed a commit to anshulahuja98/velero that referenced this pull request Sep 11, 2023
* use old namespace in resource modifier

Signed-off-by: lou <alex1988@outlook.com>

* add changelog

Signed-off-by: lou <alex1988@outlook.com>

* update docs

Signed-off-by: lou <alex1988@outlook.com>

* updated after review

Signed-off-by: lou <alex1988@outlook.com>

---------

Signed-off-by: lou <alex1988@outlook.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
ywk253100 pushed a commit that referenced this pull request Sep 12, 2023
* use old namespace in resource modifier



* add changelog



* update docs



* updated after review



---------

Signed-off-by: lou <alex1988@outlook.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Co-authored-by: Guang Jiong Lou <7991675+27149chen@users.noreply.github.com>
Co-authored-by: Daniel Jiang <jiangd@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants