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

restore: Use warning when Create IsAlreadyExist and Get error #7004

Merged

Conversation

kaovilai
Copy link
Contributor

@kaovilai kaovilai commented Oct 23, 2023

Signed-off-by: Tiger Kaovilai tkaovila@redhat.com

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #6952

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.

@kaovilai kaovilai force-pushed the warnOnCreateAlreadyExistsGetError branch from 00fabac to 4295eec Compare October 23, 2023 17:30
@kaovilai kaovilai marked this pull request as ready for review October 23, 2023 17:30
sseago
sseago previously approved these changes Oct 23, 2023
@kaovilai
Copy link
Contributor Author

whoops changelog in wrong location

@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Merging #7004 (54ecf94) into main (107c558) will decrease coverage by 0.02%.
Report is 29 commits behind head on main.
The diff coverage is 75.00%.

@@            Coverage Diff             @@
##             main    #7004      +/-   ##
==========================================
- Coverage   61.05%   61.03%   -0.02%     
==========================================
  Files         251      252       +1     
  Lines       26846    26899      +53     
==========================================
+ Hits        16390    16418      +28     
- Misses       9303     9319      +16     
- Partials     1153     1162       +9     
Files Coverage Δ
pkg/restore/restore.go 65.75% <75.00%> (-0.19%) ⬇️

... and 14 files with indirect coverage changes

sseago
sseago previously approved these changes Oct 23, 2023
Copy link
Contributor

@weshayutin weshayutin left a comment

Choose a reason for hiding this comment

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

Thanks @kaovilai

@@ -1534,8 +1534,8 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
fromCluster, err = resourceClient.Get(name, metav1.GetOptions{})
}
if err != nil && isAlreadyExistsError {
ctx.log.Errorf("Error retrieving in-cluster version of %s: %v", kube.NamespaceAndName(obj), err)
errs.Add(namespace, err)
ctx.log.Warnf("Unable to retrieve in-cluster version of %s: %v, object won't have restore labels", kube.NamespaceAndName(obj), err)
Copy link
Contributor

@reasonerjt reasonerjt Oct 30, 2023

Choose a reason for hiding this comment

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

Another impact is ExistingPolicy will be skipped for this resource, is this expected?

After this change the behavior is not as described as in the comment in line1527-1530, please also update the comments.

Additionally, you should also log that the restore of the object is skipped, though we can't determine if the in cluster resource is same or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@reasonerjt Existing resource policy is already skipped in the current code where we error out, but yes I think the warning should probably mention that explicitly here. We can't apply the existing resource policy if we can't Get the resource. Note, also, that when we can Get the resource, we don't error out if the patch fails due to immutable fields, etc., we warn, so I think that's ok here that we skip it, but the warning should mention it.

Copy link
Contributor

@reasonerjt reasonerjt left a comment

Choose a reason for hiding this comment

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

Please make sure the behavior described in the comment remains accurate after the code change.

@kaovilai kaovilai marked this pull request as draft October 30, 2023 18:05
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
@kaovilai kaovilai force-pushed the warnOnCreateAlreadyExistsGetError branch from 1178598 to 54ecf94 Compare October 31, 2023 01:12
@kaovilai kaovilai marked this pull request as ready for review October 31, 2023 01:12
@kaovilai
Copy link
Contributor Author

will cherry-pick to 1.11 and 1.12 once merged

Copy link
Contributor

@reasonerjt reasonerjt left a comment

Choose a reason for hiding this comment

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

lgtm

@sseago sseago merged commit 10245b0 into vmware-tanzu:main Nov 2, 2023
26 of 27 checks passed
kaovilai added a commit to kaovilai/velero that referenced this pull request Nov 2, 2023
kaovilai added a commit to kaovilai/velero that referenced this pull request Nov 2, 2023
kaovilai added a commit to kaovilai/velero that referenced this pull request Nov 2, 2023
kaovilai added a commit to kaovilai/velero that referenced this pull request Nov 2, 2023
ywk253100 added a commit that referenced this pull request Nov 3, 2023
…ror-release-1.11

release-1.11: restore: Use warning when Create IsAlreadyExist and Get error (#7004)
Lyndon-Li added a commit that referenced this pull request Nov 6, 2023
…ror-release-1.12

release-1.12: restore: Use warning when Create IsAlreadyExist and Get error (#7004)
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.

On restore, object can fail to create from AlreadyExists and fail to Get with IsNotFound without retry
5 participants