-
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
Add support for ResourceModifier (AKA Json Substitutions) in restore flow #6452
Add support for ResourceModifier (AKA Json Substitutions) in restore flow #6452
Conversation
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Codecov Report
@@ Coverage Diff @@
## main #6452 +/- ##
==========================================
+ Coverage 60.13% 60.28% +0.15%
==========================================
Files 236 238 +2
Lines 25090 25256 +166
==========================================
+ Hits 15088 15226 +138
- Misses 8957 8976 +19
- Partials 1045 1054 +9
|
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
First, the Github action checks cannot pass. I think this is related to the restore format change. Second, please correct me if I made misunderstood, this is the generic resource policy field, https://github.com/vmware-tanzu/velero/blob/main/pkg/apis/velero/v1/backup_types.go#L167 |
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
|
Would be adding E2E tests as part of separate PR. |
return nil | ||
} | ||
if r.Conditions.ResourceNameRegex != "" { | ||
match, _ := regexp.MatchString(r.Conditions.ResourceNameRegex, obj.GetName()) |
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.
Handle error
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.
when match comes false, an error will come
I don't see additional use in handling this error
since we just need to rely on the "match" value
Logging it on the other hand might just bloat logs since match will be called for each resource which matches NS/ GroupKind filters.
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.
Could you explain more about when match comes false, an error will come
? When the match is false, the current code returns nil directly.
There is a case that the regex provided may contain syntax errors, if we don't handle such kinds of errors, users don't know about that and the restore may completed but with unexpected resources restored.
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.
I understand your concern, validated what you explained with a POC.
Have updated the PR with the fix for handling and also added test case for it.
if err != nil { | ||
return fmt.Errorf("error in marshaling object %s", err.Error()) | ||
} | ||
modifiedObjBytes, err := jsonPatch.Apply(objBytes) |
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.
Seems an error is returned if no path matches the test
operation. Correct me if I'm wrong.
So that means if users set the test
patch, they must make sure it matches, or the restore will fail.
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.
the restore will not fail
just that particular patch would fail and restore will go on as it is.
For example there are 5 PVCs which match the "conditions"
but only 1 PVC which satisfies the "test" operator. Only that PVC will be patched and all the others will get skipped in some sense.
The logs will show that, but there won't be any hard failure.
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.
Yes, the error is shown in the logs, but won't the restore be marked as partially failed? Is this the expected behavior?
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.
Handled the "test operator related errors separately to avoid partial failure states based on your feedback. Updated code with test case.
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
@anshulahuja98 Please also add some more unit test cases. We have one task in the 1.12 timeframe to improve the unit test coverage to be >60%. |
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Sure will do. |
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
@sseago / @blackpiglet can you please review this PR. |
@anshulahuja98 looks like there's a conflict to resolve in this now |
Signed-off-by: Anshul Ahuja <anshul.ahu@gmail.com>
c8f970a
Fixed the merge conflict @sseago |
Thank you for contributing to Velero!
Please add a summary of your change
Does your change fix a particular issue?
Fixes #5809
Design: #5880
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.