Skip to content

[ServiceBus] Creating resources with mgmt randomly results in ResourceExistsError #16645

@swathipil

Description

@swathipil
  • Package Name: [azure-servicebus]
  • Package Version: 7.0.2
  • Operating System: Windows
  • Python Version: 3.9

Describe the bug
When creating resources by running the mgmt_*.py samples, they randomly fail with the following error: azure.core.exceptions.ResourceExistsError: Operation returned an invalid status 'Conflict'. This happens both locally and in the test pipeline. For example, if we were running a sample multiple times in rapid succession or in parallel that created a topic named demo_topic in the same resource group and SB namespace, it is possible that one sample would try to create a demo_topic before the other sample could delete the demo_topic that it created.

To ensure this was not happening, for each resource being created, a UUID was added to the name to ensure that multiple resources with the same name were not being created at the same time before they could be deleted. This results in the same error randomly, even when the resource does not already exist.

To Reproduce
Steps to reproduce the behavior:

  1. Run any of the samples named mgmt_*.py (and add env variables as needed). Like mgmt_rule.py
  2. This will randomly result in the error.

Expected behavior
I expect the sample to create and delete the resource using the ServiceBusAdministrationClient without the ResourceExistsError each time it is run.

Screenshots
Sample Error Log:

-- List Rules
Rule Name: $Default
Rule Name: sb_mgmt_rule18ba42ea-215e-43b6-a958-bc66d10ecc1e    
Rule Name: sb_mgmt_rule88d8ab79-b463-4337-8d81-264b120c0342    
Rule Name: sb_mgmt_rule8e1c13a5-ac73-411c-b7a3-03160ce13814    
                                                               
-- Create Rule
Creating rule sb_mgmt_rulea8e2fce7-c833-4e27-9de8-b2bbf4a4ab4c.
Traceback (most recent call last):
  File "C:\Users\swathip\Documents\forks\azure-sdk-for-python\sdk\servicebus\azure-servicebus\samples\sync_samples\mgmt_rule.py", line 63, in <module>   
    create_rule(servicebus_mgmt_client)
  File "C:\Users\swathip\Documents\forks\azure-sdk-for-python\sdk\servicebus\azure-servicebus\samples\sync_samples\mgmt_rule.py", line 33, in create_rule
    servicebus_mgmt_client.create_rule(TOPIC_NAME, SUBSCRIPTION_NAME, RULE_NAME)
  File "C:\Users\swathip\Documents\env39\lib\site-packages\azure\servicebus\management\_management_client.py", line 1045, in create_rule
    entry_ele = self._impl.rule.put(
  File "C:\Users\swathip\Documents\env39\lib\site-packages\azure\servicebus\management\_generated\operations\_rule_operations.py", line 188, in put      
    map_error(status_code=response.status_code, response=response, error_map=error_map)
  File "c:\users\swathip\documents\forks\azure-sdk-for-python\sdk\core\azure-core\azure\core\exceptions.py", line 102, in map_error
    raise error
azure.core.exceptions.ResourceExistsError: Operation returned an invalid status 'Conflict'

Additional context
Since these samples randomly fail in the test pipeline due to this error, they have been added to the IGNORED_SAMPLES section of test_run_samples.py. After fixing the bug, these samples should be removed from IGNORED_SAMPLES.

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.MessagingMessaging crewService Bus

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions