-
Notifications
You must be signed in to change notification settings - Fork 3k
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
{RDBMS} Fix "Message: The subscription '00000000-0000-0000-0000-000000000000' could not be found." test error by waiting for Long Running Operations #17185
Conversation
Another good example for troubleshooting and drill to the end:) |
We can use a simple demo to show VCR.py is not thread-safe: import vcr
import requests
import logging
import threading
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s\t%(name)s\t%(thread)d\t%(threadName)s\t%(message)s")
def thread_function():
inner_response = requests.get('https://httpbin.org/get')
print(inner_response.status_code)
with vcr.use_cassette('recordings.yaml'):
new_thread = threading.Thread(target=thread_function)
new_thread.start()
response = requests.get('https://httpbin.org/get')
print(response.status_code)
new_thread.join() Even there is only one entry in the recording, the script will succeed, with one request going to the recording, one request going to the internet. This is because VCR.py has a Detail: kevin1024/vcrpy#295, kevin1024/vcrpy#212 |
The change caused 3 test failures
because
|
@DaeunYim for aware |
@@ -176,7 +176,7 @@ def _create_vnet_subnet_delegation(nw_client, resource_group, vnet_name, subnet_ | |||
location=location, | |||
address_space=AddressSpace( | |||
address_prefixes=[ | |||
vnet_address_pref]))) | |||
vnet_address_pref]))).result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another solution proposed by @zhoxing-ms is to supply polling=False
to nw_client.virtual_networks.begin_create_or_update
so that LROPoller
is created with NoPolling
:
if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs)
elif polling is False: polling_method = NoPolling()
This stops SDK from polling the result. The Virtual Network creation will then be superseded/canceled by Subnet creation.
Pros
- This is faster as it doesn't care about the result of Virtual Network creation.
Cons
- This leaves the result of Virtual Network creation unchecked. If the Virtual Network creation actually fails, the error will be reported at
azure-cli/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_virtual_network.py
Lines 188 to 189 in 95d3346
return nw_client.subnets.begin_create_or_update(resource_group, vnet_name, subnet_name, subnet_result).result()
making troubleshooting difficult. - This depends on the service's ability to allow one operation to be superseded by another. In many other services like Storage, this is not always the case - we can't create a container before Storage Account creation finished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Please merge and let me continue working based on this change. Thanks a lot, Jiashuo and team!
Symptom
RDBMS tests frequently fail (like in #17127):
https://dev.azure.com/azure-sdk/public/_build/results?buildId=759999&view=logs&j=74095127-2a27-5370-37ed-15a4193f243f&t=5cf5f89a-09fb-583c-72e4-4e4427c89fb1&l=167520
Cause
When
virtual_networks.begin_create_or_update
is not waited,requests
will be called by theLROPoller
thread andMainThread
at the same time. As VCR.py is not designed to be thread-safe (kevin1024/vcrpy#213 (comment)), some request will bypass VCR and reach to internet:As
00000000-0000-0000-0000-000000000000
is not a valid subscription ID, this error is triggered.Repro
Replace
azure-cli/.azure-pipelines/templates/automation_test.yml
Lines 16 to 20 in 5df0938
with
so that
test_mysql_flexible_server_vnet_mgmt_supplied_subnet_id_in_different_rg
is endlessly retried until failure.The debug logs shows execution details:
Notice that
LROPoller
hadn't finished yet andMainThread
already started a new request.