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

Fix edge cases for already exists resources #5239

Merged

Conversation

shubham-pampattiwar
Copy link
Collaborator

Signed-off-by: Shubham Pampattiwar spampatt@redhat.com

Thank you for contributing to Velero!

Does your change fix a particular issue?

Fixes #5223

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.

@codecov-commenter
Copy link

Codecov Report

Merging #5239 (d71f726) into main (082d680) will decrease coverage by 0.03%.
The diff coverage is 38.09%.

@@            Coverage Diff             @@
##             main    #5239      +/-   ##
==========================================
- Coverage   41.43%   41.39%   -0.04%     
==========================================
  Files         231      231              
  Lines       19666    19679      +13     
==========================================
- Hits         8149     8147       -2     
- Misses      10923    10936      +13     
- Partials      594      596       +2     
Impacted Files Coverage Δ
pkg/restore/restore.go 63.89% <38.09%> (-0.74%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@kaovilai
Copy link
Contributor

kaovilai commented Aug 24, 2022

I have an alternative approach to this PR at openshift#188 fyi which put most of the logic behind isAlreadyExistsError function instead.

@reasonerjt reasonerjt requested review from Lyndon-Li and removed request for dsu-igeek August 26, 2022 08:50
if fromCluster == nil {
fromCluster, err = resourceClient.Get(name, metav1.GetOptions{})
if err != nil {
ctx.log.Infof("Error retrieving cluster version of %s: %v", kube.NamespaceAndName(obj), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is copied from existing code, but seems it's more consistent (e.g with the code in line 1247 ) if we merge this err into errors.
We may also wanna change the log level.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@reasonerjt Hmm. I'm not sure, but yeah, you may be right. So this would be a change in behavior for situations not otherwise modified by this PR. So the scenario we're talking about is that the Create failed due to the object already existing, but now when we do a Get call (to determine whether the in-cluster object is different from the from-backup object), the Get call fails. Ordinarily this shouldn't happen. Off the top of my head, possible causes are:

  1. Something outside of Velero just created this resource at almost the same time as Velero tried to restore and we're in a race scenario where a second Create fails due to an already existing object but the API server isn't yet finding it via Get.
  2. A bug or malfunction in the APIServer

We're currently flagging this as a restore warning. If we want to stick with that, then we should probably change the log level from Info to Warn.

The other possibility is we bump this up to a restore error and the log level to Error as well.

@shubham-pampattiwar what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@reasonerjt @sseago I agree with changing the log level to error and adding this error to errors (as the next piece of workflow depends on the object fetched from the cluster)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, updated the PR.

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

add changelog file

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

update changelog filename

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

change log level and error type

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.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.

Fix Edge cases for already exists resources
5 participants