Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.27k stars 3.87k forks source link

Incorrect error message #12438

Open yossi-y opened 4 years ago

yossi-y commented 4 years ago

Description

Two issues:

  1. Customer was able to create a cluster without providing -SkuName.

    • In cluster create REST, you are required to provide both -SkuName and -SkuCapacity
    • In cluster update, when updating capacity, you need to provide both -SkuName and -SkuCapacity
  2. We have a case where customer configured CMK and then updated it with incorrect capacity value and got generic error message: "Update-AzOperationalInsightsCluster: Operation returned an invalid status code 'BadRequest'"

Instead of the one returned from the API: { "error": { "code": "BadRequest", "message": "CapacityReservationLevel must be in the range of 1000-3000. Contact us to increase the limit LAIngestionRate@microsoft.com" } }

Steps to reproduce

Update-AzOperationalInsightsCluster -ResourceGroupName {rg-name} -ClusterName {cluster-name} -SkuName CapacityReservation -SkuCapacity 1000


## Environment data

<!-- Please run $PSVersionTable and paste the output in the below code block
     If running the Docker container image, indicate the tag of the image used and the version of Docker engine-->

## Module versions

<!-- Please run (Get-Module  -ListAvailable) and paste the output in the below code block -->

```powershell

Debug output

Error output

VeryEarly commented 4 years ago

The reason why error message was not thrown properly is because the error defined in swagger (ClusterErrorResponse): https://github.com/Azure/azure-rest-api-specs/blob/master/specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/preview/2020-03-01-preview/Clusters.json#L322

the generated SDK didn’t add the exception body to exception message: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/ClustersOperations.cs#L890 to https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/ClustersOperations.cs#L917

In Azure-PowerShell we usually throw server error by generated SDK directly without catch them in client code. So you can only see the message: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/ClustersOperations.cs#L892

exception.body was there but not printed to powershell console: https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/operationalinsights/Microsoft.Azure.Management.OperationalInsights/src/Generated/ClustersOperations.cs#L899

There are two options:

  1. Update swagger spec: remove definition of “default” response, generated SDK will use “CloudError” which will add exception body to message
  2. We catch the exception in client side explicitly
yossi-y commented 4 years ago

Adding @yoramsinger .

We will go with option #1. I opened a bug on the team to fix: Bug (https://msazure.visualstudio.com/DefaultCollection/One/_workitems/edit/8824222) Control plane - Incorrect ClusterErrorResponse definition in cluster swagger.

Once we have the .NET SDK updated, do we need to update PowerShell package as well?

dingmeng-xue commented 3 years ago

Once SDK is updated, client side code doesn't need to be changed. I change the tag and let's close this ticket one service is deployed.

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @SameergMS, @dadunl.

Issue Details
## Description Two issues: 1. Customer was able to create a cluster without providing -SkuName. - In cluster create REST, you are required to provide both -SkuName and -SkuCapacity - In cluster update, when updating capacity, you need to provide both -SkuName and -SkuCapacity 2. We have a case where customer configured CMK and then updated it with incorrect capacity value and got generic error message: "Update-AzOperationalInsightsCluster: Operation returned an invalid status code 'BadRequest'" Instead of the one returned from the API: { "error": { "code": "BadRequest", "message": "CapacityReservationLevel must be in the range of 1000-3000. Contact us to increase the limit LAIngestionRate@microsoft.com" } } ## Steps to reproduce Update-AzOperationalInsightsCluster -ResourceGroupName {rg-name} -ClusterName {cluster-name} -SkuName CapacityReservation -SkuCapacity 1000 ``` ## Environment data ``` ``` ## Module versions ```powershell ``` ## Debug output ``` ``` ## Error output ``` ```
Author: yossi-y
Assignees: VeryEarly
Labels: `Monitor`, `Monitor - Operational Insights`, `Service Attention`
Milestone: -
VeryEarly commented 3 years ago

client side need to upgrade SDK version to Microsoft.Azure.Management.OperationalInsights-0.22.0-preview or above.