ansible-collections / azure

Development area for Azure Collections
https://galaxy.ansible.com/azure/azcollection
GNU General Public License v3.0
238 stars 317 forks source link

galleryimageversion: Fix occasional crash in create_update_resource #1584

Open jeremycline opened 4 weeks ago

jeremycline commented 4 weeks ago
SUMMARY

self.get_resource() returns a response object if the request didn't raise an exception, otherwise it returns False. This causes an occasional crash with "TypeError: 'bool' object is not subscriptable" in the polling loop which expects the response to always be subscriptable.

While polling, if a request fails, just keep the old request and loop again.

ISSUE TYPE
COMPONENT NAME

azure_rm_galleryimageversion

Fred-sun commented 4 weeks ago

@jeremycline You can't make such changes here, either to create or update the resource, and if there is a problem with getting it, you should either get it again, or abort the fetch, and throw an exception instead of printing the previously retrieved information (old_response). Thank you!

jeremycline commented 4 weeks ago

Hi, thanks for taking a look!

I'm not sure I follow, is the concern here it could potentially loop forever if the resource can never be fetched again after it gets to the polling loop? Given the prior code caught all exceptions and returned false instead of raising them made me thing that was the desired state.

Fred-sun commented 4 weeks ago

@jeremycline There has been no problem of infinite loop since this module was put into use. In order to avoid this problem, we can do such a setting, each loop wait 30 seconds, loop 10, if still can not get, throw an exception. Thank you!