Check future regardless of error in async helpers and return VM result for existing VM#1837
Conversation
| } | ||
| scope.SetLongRunningOperationState(future) | ||
| return nil, azure.WithTransientError(azure.NewOperationNotDoneError(future), retryAfter(sdkFuture)) | ||
| if sdkFuture != nil { |
There was a problem hiding this comment.
@karuppiah7890 please take a look. I believe this addresses your comment in #1684 (comment). I think it makes sense to not require an error (that way this will work whether an error is returned or not). However, I still think we shouldn't silence the error returned by WaitForCompletionRef in the clients since eventually it might return a different error besides context deadline exceeded.
| if !ok { | ||
| if params == nil { | ||
| // nothing to do here. | ||
| return existingVM, nil, nil |
There was a problem hiding this comment.
can we move this to line 86 and invoke spec.Parameters() can be only for new vms? wdyt?
There was a problem hiding this comment.
in this specific VM service we technically could because we never want to update existing VMs but this pattern works best for all services in general: we pass in the existing resource to spec.Parameters(existing) and that function determines if the resource needs to be created or updated based on the existing resource. For example, for NSGs we update the group the security rules are missing. IMO it's best to use the same pattern throughout all services so it's easier to refactor them later to have even more code in common.
d7a2ab4 to
cfd085a
Compare
|
/hold need to investigate why e2e tests are failing |
cfd085a to
8a4b357
Compare
|
/hold cancel |
|
/retest |
|
/assign @shysank @Jont828 @karuppiah7890 |
|
@CecileRobertMichon: GitHub didn't allow me to assign the following users: Jont828, karuppiah7890. Note that only kubernetes-sigs members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
| var existingVM interface{} | ||
|
|
||
| if existing, err := ac.Get(ctx, spec.ResourceGroupName(), spec.ResourceName()); err != nil && !azure.ResourceNotFound(err) { | ||
| return nil, nil, errors.Wrapf(err, "failed to get virtual machine %s in %s", spec.ResourceName(), spec.ResourceGroupName()) |
There was a problem hiding this comment.
shouldn't we handle errors that are not ResourceNotFound?
There was a problem hiding this comment.
if it's a ResourceNotFound error, that means the VM doesn't exist, so we don't set existingVM. It's not an error we want to return, it's an expected error whenever we create the resource for the first time.
There was a problem hiding this comment.
oh yeah, this used to be in a different form in virtualmachines.go. Perhaps I should be more in sync with the new code, but alas the code itself is not in sync anymore.
| if !ok { | ||
| if params == nil { | ||
| // nothing to do here. | ||
| return existingVM, nil, nil |
There was a problem hiding this comment.
can we move this to line 86 and invoke spec.Parameters() can be only for new vms? wdyt?
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: devigned The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
What this PR does / why we need it: Small followups on #1697 and comments in #1684
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
TODOs:
Release note: