Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.98k forks source link

Traceback produced for backend failure #4816

Closed rjschwei closed 6 years ago

rjschwei commented 7 years ago

When there are backend issues the az tool generates a traceback on the command line rather than a proper error message.

Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Storage/storageAccounts?api-version=2017-06-01 (Caused by ResponseError('too many 500 error responses',))
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/requests/adapters.py", line 370, in send
    timeout=timeout
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 648, in urlopen
    release_conn=release_conn, **response_kw)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 648, in urlopen
    release_conn=release_conn, **response_kw)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 648, in urlopen
    release_conn=release_conn, **response_kw)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 641, in urlopen
    retries = retries.increment(method, url, response=response, _pool=self)
  File "/usr/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 271, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/xxx/yyy/providers/Microsoft.Storage/storageAccounts?api-version=2017-06-01 (Caused by ResponseError('too many 500 error responses',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/msrest/service_client.py", line 189, in send
    **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/adapters.py", line 422, in send
    raise RetryError(e, request=request)
requests.exceptions.RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Storage/storageAccounts?api-version=2017-06-01 (Caused by ResponseError('too many 500 error responses',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/azure/cli/main.py", line 36, in main
    cmd_result = APPLICATION.execute(args)
  File "/usr/lib/python3.4/site-packages/azure/cli/core/application.py", line 212, in execute
    result = expanded_arg.func(params)
  File "/usr/lib/python3.4/site-packages/azure/cli/core/commands/__init__.py", line 377, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/lib/python3.4/site-packages/azure/cli/core/commands/__init__.py", line 636, in _execute_command
    raise client_exception
  File "/usr/lib/python3.4/site-packages/azure/cli/core/commands/__init__.py", line 626, in _execute_command
    reraise(*sys.exc_info())
  File "/usr/lib/python3.4/site-packages/six.py", line 659, in reraise
    raise value
  File "/usr/lib/python3.4/site-packages/azure/cli/core/commands/__init__.py", line 603, in _execute_command
    result = op(client, **kwargs) if client else op(**kwargs)
  File "/usr/lib/python3.4/site-packages/azure/cli/command_modules/storage/custom.py", line 176, in list_storage_accounts
    return list(accounts)
  File "/usr/lib/python3.4/site-packages/msrest/paging.py", line 109, in __next__
    self.advance_page()
  File "/usr/lib/python3.4/site-packages/msrest/paging.py", line 95, in advance_page
    self._response = self._get_next(self.next_link)
  File "/usr/lib/python3.4/site-packages/azure/mgmt/storage/v2017_06_01/operations/storage_accounts_operations.py", line 542, in internal_paging
    request, header_parameters, **operation_config)
  File "/usr/lib/python3.4/site-packages/msrest/service_client.py", line 215, in send
    raise_with_traceback(ClientRequestError, msg, err)
  File "/usr/lib/python3.4/site-packages/msrest/exceptions.py", line 47, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/usr/lib/python3.4/site-packages/msrest/service_client.py", line 189, in send
    **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.4/site-packages/requests/adapters.py", line 422, in send
    raise RetryError(e, request=request)
msrest.exceptions.ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Storage/storageAccounts?api-version=2017-06-01 (Caused by ResponseError('too many 500 error responses',))

The implementation should catch the exception and produce a sensible error message for the user.


Environment summary

openSUSE Leap 42.3, installed from RPM packages

azure-cli-storage-2.0.16

troydai commented 7 years ago

Thank you @rjschwei for reporting this. I will take a look at the source of this error and review the error handling in the storage module.

troydai commented 7 years ago

We can capture re-interrupt the error message for individual command. However, this falls into a wider category regarding how unexpected exception is presented at the core level.

wstrox commented 6 years ago

A similar issue occurred when resizing an Elastic Pool. e.g. the following invocation failed with a similar message as reported above:

az sql elastic-pool update --id "/subscriptions/xxxxx/resourceGroups/Our-RG/providers/Microsoft.Sql/servers/servername/elasticPools/server-pool" \
    --dtu 200 --edition Standard

but the following succeeded:

az sql elastic-pool update --id "/subscriptions/xxxxx/resourceGroups/Our-RG/providers/Microsoft.Sql/servers/servername/elasticPools/server-pool" \
    --dtu 200 --edition Standard --max-size 50GB --db-dtu-max 200

In this case, it was just a matter of adding the required options.

tjprescott commented 6 years ago

We added a generic exception handler to gracefully handle many exceptions. If there are individual cases that produce stack traces, please open new issues. Stack traces are considered bugs in all cases by CLI team.