-
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
Ignore missing path error in conditional match #7410
Conversation
Signed-off-by: Sean Blong <[email protected]>
Valid suggestion |
Signed-off-by: Sean Blong <[email protected]>
You bet! The test I added is a little nonsensical as It's checking for a subattribute of a label, but testing before/after change shows that it accurately reports on |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7410 +/- ##
=======================================
Coverage 61.64% 61.64%
=======================================
Files 262 262
Lines 28477 28477
=======================================
Hits 17556 17556
Misses 9689 9689
Partials 1232 1232 ☔ View full report in Codecov by Sentry. |
Hi @seanblong, sorry for the late reply. Basically with your change - all path missing errors are swallowed and not logged. An alternative to achieve what you wish is by using a test patch. Let me know if that sounds reasonable? |
No problem at all. I actually went the route of Let me better illustrate this using two of our test variables. The first having a list of volumeMounts and the second being a more vanilla Nginx image. This acts as a good example where we may want a generic velero/internal/resourcemodifiers/resource_modifiers_test.go Lines 1062 to 1083 in d45b313
velero/internal/resourcemodifiers/resource_modifiers_test.go Lines 1050 to 1060 in d45b313
Today the following will work on the former, but not the latter. In the case of the latter it will throw an error:
In order to get this rule to work with resourceModifierRules:
- conditions:
groupResource: pods
patches:
- operation: test
path: "/spec/containers/0/volumeMounts"
value: "[{\"mountPath\": \"/fake1\", \"name\": \"vol1\"},{\"mountPath\": \"/fake2\", \"name\": \"vol2\"}]"
- operation: replace
path: "/spec/containers/0/volumeMounts/0/name"
value: "vol1" This requires a complicated - operation: test
path: "/spec/containers/0/volumeMounts/0/name"
value: "name" Alternative workarounds would be to make much more specific |
@seanblong I think I understand now. This looks good to me. |
Thank you for contributing to Velero!
Please add a summary of your change
For Resource Modifiers, don't treat unmatched paths as an error (
ErrMissing
) instead treat them the same way as anErrTestFailed
response.This is particularly useful when we want to match on paths should they exist, such as the following example where I'm looking to remove a particular affinity rule.
I've tested this locally and with a deployed container image. All statefulsets containing this particular path have it removed and all statefulset without it are filtered out, without creating an error message and allowing the restore to finish with a
Completed
status.Does your change fix a particular issue?
Fixes #(issue)
N/A
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.