pulumi / pulumi-azure

A Microsoft Azure Pulumi resource package, providing multi-language access to Azure
Apache License 2.0
131 stars 50 forks source link

Provide error details during failed update #423

Open clstokes opened 4 years ago

clstokes commented 4 years ago

When an update to azure.core.TemplateDeployment fails, the error message emitted doesn't include the detailed error message from the Azure API so the user has very little information to troubleshoot with. Re-running with --debug provides the actual error message that provides the root cause.

Output

  azure:core:TemplateDeployment (test-dep):
    error: Error validating Template for Deployment "test-depe90acdae" (Resource Group "test04a8acc0"): The template deployment 'test-depe90acdae' is not valid according to the validation procedure. The tracking id is '8de04766-c6dc-41b7-8151-88ca889b3e96'. See inner errors for details.

Output with --debug

    debug: 
    debug: {"error":{"code":"InvalidTemplateDeployment","message":"The template deployment 'test-depec23ee52' is not valid according to the validation procedure. The tracking id is 'e2c03844-9320-4af0-bce7-1b325758003a'. See inner errors for details.","details":[{"code":"PreflightValidationCheckFailed","message":"Preflight validation failed. Please refer to the details for the specific errors.","details":[{"code":"AccountTypeMissing","target":"xdv25ywsgizdastorage","message":"The accountType field is missing from the request."}]}]}}
    error: update failed

  azure:core:TemplateDeployment (test-dep):
    error: Error validating Template for Deployment "test-depec23ee52" (Resource Group "test04a8acc0"): The template deployment 'test-depec23ee52' is not valid according to the validation procedure. The tracking id is 'e2c03844-9320-4af0-bce7-1b325758003a'. See inner errors for details.

Code to reproduce

https://gist.github.com/clstokes/298bc0ab59d98a4401f477c8cc9f07fe

Suggestion

Provide the inner errors details in the normal non-debug output.

clstokes commented 4 years ago

Here's another example of the detailed error message not being provided in non-debug output.

Error message

  azure:appservice:Plan (prod-ui-plan):
    error: deleting urn:pulumi:prod::prod::azure:appservice/plan:Plan::prod-ui-plan: Error deleting App Service Plan "prod-ui-plan" (Resource Group "prod"): web.AppServicePlansClient#Delete: Failure sending request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=<nil> <nil>

Debug Error Message

debug: {"Code":"Conflict","Message":"Server farm 'prod-ui-plan' cannot be deleted because it has web app(s) prod-ui assigned to it.","Target":null,"Details":[{"Message":"Server farm 'prod-ui-plan' cannot be deleted because it has web app(s) prod-ui assigned to it."},{"Code":"Conflict"},{"ErrorEntity":{"ExtendedCode":"11003","MessageTemplate":"Server farm '{0}' cannot be deleted because it has web app(s) {1} assigned to it.","Parameters":["prod-ui-plan","prod-ui"],"Code":"Conflict","Message":"Server farm 'prod-ui-plan' cannot be deleted because it has web app(s) prod-ui assigned to it."}}],"Innererror":null}

Note: stack and resource names have been obfuscated so disregard any inconsistencies there.

clstokes commented 4 years ago

@stack72 @mikhailshilkov thoughts on this one? This causes a fair bit of trouble and frustration for our users that hit this.

mikhailshilkov commented 4 years ago

Agreed that's very annoying. @stack72 do you know where we swallow this and whether we could easily improve?