autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Fix LRO PATCH and simplification

Open amarzavery opened this issue 10 years ago • 6 comments

This PR https://github.com/Azure/autorest/pull/875 fixed LRO PATCH in node.js and also simplified it. Similar changes need to be made in C#, Java, Ruby, Python so that every language is consistent.

amarzavery avatar Apr 30 '16 01:04 amarzavery

Thanks for opening this. I'm working on the C# changes

tbombach avatar May 03 '16 18:05 tbombach

@amarzavery - are you able to clarify how PATCH operations were fixed? I'm having trouble finding it amongst the refactor changes in the PR diff....

annatisch avatar May 04 '16 18:05 annatisch

@annatisch - sure.

Previously implemented long running PATCH was incorrectly giving preference to provisioning state value.

For a PATCH, the resource has to be successfully created as a prerequisite. Hence, its provisioning state will always be succeeded. We were checking that and would return without polling.

The right thing to do for a PATCH operation is to look for Azure Async Operation Header and Location Header in the initial response. If they are present then we should poll (get) on the link provided in those headers until a terminal state is reached.

We were doing this kind of polling for long running POST and DELETE. Hence, we modified the logic for PATCH to not look for provisioning state and do the right thing.

As a part of this modification we realized that everything can be simplified into one method named getLongRunningOperationStatus() (by checking the initial method and the statuscode) rather than having the previous two methods (getPutOrPatch.., getPostOrDelete..). Hence this was reduced to one.

We still kept the old methods for backwards compatibility. These methods internally call the new method.

Hope this helps :).

amarzavery avatar May 05 '16 01:05 amarzavery

Removing Ruby Label as the Fix is in.

vishrutshah avatar May 12 '16 20:05 vishrutshah

@amarzavery, thanks so much - that helped lots!! I think I've finally got this resolved for Python - I'd appreciate it if you could take a quick glance over my latest PR.

annatisch avatar May 24 '16 17:05 annatisch

(Not for Java runtime GA as this won't be a breaking change. Will fix it later.)

jianghaolu avatar Oct 14 '16 22:10 jianghaolu