Azure / Azure/azure-rest-api-specs

Listing Compute Usages Returns Incomplete Response

Open
#25,455 34 comments 0 reactions 1 assignee Assigned to @TravisCragg-MSFT View on GitHub
Compute customer-reported needs-team-attention question Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

- **Package Name**: azure-mgmt-compute
- **Package Version**: 30.0.0
- **Operating System**: Linux
- **Python Version**: 3.9.16

**Describe the bug**
Calling `.usage.list()` on a `ComputeManagementClient` in the Python SDK will inconsistently result in a DecodeError. This method call will result in calls to the [Compute Usage List](https://learn.microsoft.com/en-us/rest/api/compute/usage/list?tabs=HTTP) API. We see this happening in less than 10% of calls for affected subscriptions.

Originally opened against [azure-sdk-for-python](https://github.com/Azure/azure-sdk-for-python) in [#issue-31643](https://github.com/Azure/azure-sdk-for-python/issues/31643)

Sample tail of stack trace:

```
File "/usr/local/lib/python3.9/site-packages/azure/core/paging.py", line 124, in __next__
return next(self._page_iterator)
File "/usr/local/lib/python3.9/site-packages/azure/core/paging.py", line 76, in __next__
self._response = self._get_next(self.continuation_token)
File "/usr/local/lib/python3.9/site-packages/azure/mgmt/compute/v2019_03_01/operations/_operations.py", line 8929, in get_next
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 202, in run
return first_node.send(pipeline_request)
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 70, in send
response = self.next.send(request)
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 70, in send
response = self.next.send(request)
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 70, in send
response = self.next.send(request)
[Previous line repeated 1 more time]
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/_base.py", line 75, in send
_await_result(self._policy.on_response, request, response)
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/_tools.py", line 35, in await_result
result = func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/policies/_universal.py", line 712, in on_response
response.context[self.CONTEXT_NAME] = self.deserialize_from_http_generics(
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/policies/_universal.py", line 677, in deserialize_from_http_generics
return cls.deserialize_from_text(response.text(encoding), mime_type, response=response)
File "/usr/local/lib/python3.9/site-packages/azure/core/pipeline/policies/_universal.py", line 609, in deserialize_from_text
raise DecodeError(
azure.core.exceptions.DecodeError: JSON is invalid: Expecting property name enclosed in double quotes: line 679 column 21 (char 15692)
Content: {
"value": [
{
"limit": 2500,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "availabilitySets",
"localizedValue": "Availability Sets"
}
},
{
"limit": 350,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "cores",
"localizedValue": "Total Regional vCPUs"
}
},
{
"limit": 25000,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "virtualMachines",
"localizedValue": "Virtual Machines"
}
},
{
"limit": 2500,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "virtualMachineScaleSets",
"localizedValue": "Virtual Machine Scale Sets"
}
},
{
"limit": 3000,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "dedicatedVCpus",
"localizedValue": "Dedicated vCPUs"
}
},
{
"limit": 350,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "lowPriorityCores",
"localizedValue": "Total Regional Low-priority vCPUs"
}
},
{
"limit": 350,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "basicAFamily",
"localizedValue": "Basic A Family vCPUs"
}
},
{
"limit": 350,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "standardA0_A7Family",
"localizedValue": "Standard A0-A7 Family vCPUs"
}
},
{
"limit": 350,
"unit": "Count",
"currentValue": 0,
"name": {
"value": "standardA8_A11Family",
"localizedValue": "Standard A8-A11 Family vCPUs"
}
},
{
"limit": 350,
"unit": "Count",
"currentValue": 0,
"name": {
```

**To Reproduce**
We have been unable to reliably reproduce the issue. However we do continually see a handful of these errors each hour in our logs. Attempts at cataloging the response from the API have confirmed the API does indeed cut off the response as seen in the example above.

**Expected behavior**
The response from azure side should be properly decoded instead of a JSON error. This would appear to require the underlying API to return a complete response.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.