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 poller for some resources #54853

Merged
merged 1 commit into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/ansible/modules/cloud/azure/azure_rm_rediscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@

try:
from msrestazure.azure_exceptions import CloudError
from msrest.polling import LROPoller
from msrestazure.azure_operation import AzureOperationPoller
from msrest.serialization import Model
from azure.mgmt.redis import RedisManagementClient
Expand Down Expand Up @@ -561,7 +562,7 @@ def create_rediscache(self):
response = self._client.redis.create(resource_group_name=self.resource_group,
name=self.name,
parameters=params)
if isinstance(response, AzureOperationPoller):
if isinstance(response, LROPoller) or isinstance(response, AzureOperationPoller):
Copy link
Contributor

Choose a reason for hiding this comment

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

why there will be 2 returned response? is it caused by sdk version difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AzureOperationPoller is older versions of Python SDK< while LROPoller is in newer versions.
In some cases.
Some operations may return poller randomly (depending on some circumstances), so sometimes upgrading package version may leave poller issue undetected by CI.
Then it may manifest itself randomly in the future.
So it's better to be safe and be prepared.

response = self.get_poller_result(response)

except CloudError as exc:
Expand Down Expand Up @@ -597,7 +598,7 @@ def update_rediscache(self):
response = self._client.redis.update(resource_group_name=self.resource_group,
name=self.name,
parameters=params)
if isinstance(response, AzureOperationPoller):
if isinstance(response, LROPoller) or isinstance(response, AzureOperationPoller):
response = self.get_poller_result(response)

except CloudError as exc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@

try:
from msrestazure.azure_exceptions import CloudError
from msrest.polling import LROPoller
from msrestazure.azure_operation import AzureOperationPoller
from msrest.serialization import Model
from azure.mgmt.redis import RedisManagementClient
Expand Down Expand Up @@ -258,7 +259,7 @@ def create_or_update(self):
rule_name=self.name,
start_ip=self.start_ip_address,
end_ip=self.end_ip_address)
if isinstance(response, AzureOperationPoller):
if isinstance(response, LROPoller) or isinstance(response, AzureOperationPoller):
response = self.get_poller_result(response)

except CloudError as exc:
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/azure/azure_rm_roledefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def create_update_roledefinition(self):
response = self._client.role_definitions.create_or_update(role_definition_id=self.role['name'] if self.role else str(uuid.uuid4()),
scope=self.scope,
role_definition=role_definition)
if isinstance(response, AzureOperationPoller):
if isinstance(response, LROPoller) or isinstance(response, AzureOperationPoller):
response = self.get_poller_result(response)

except CloudError as exc:
Expand Down