pulumi / pulumi-azure-native

Azure Native Provider
Apache License 2.0
123 stars 32 forks source link

azure_native.dbforpostgresql.Configuration FAIL on DELETE #2043

Open antoine-lecomte opened 1 year ago

antoine-lecomte commented 1 year ago

What happened?

Trying to delete a azure_native.dbforpostgresql.Configuration resource fails with the following error:

{"error":{"code":"InternalServerError","message":"An unexpected error occured while processing the request. Tracking ID: 'b3c4f166-7bea-4181-b477-7f5dd58aa4c0'"}}

Steps to reproduce

import * as pulumi from "@pulumi/pulumi";
import * as dbforpostgresql from '@pulumi/azure-native/dbforpostgresql/v20210601'

const configuration = new dbforpostgresql.Configuration("configuration", {
    configurationName: "psql-epa-common-config-azure.extensions",
    resourceGroupName: "TestGroup",
    serverName: "testserver",
    source: "user-override",
    value: "PG_TRGM",
});

Expected Behavior

Actual Behavior

Asking to delete the resource and enabling the debug output of pulumi up provide more information

Pulumi actually do a PUT https://management.azure.com/subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions?api-version=2021-06-01 with a body content :

{"properties":{"source":"system-default"}}

Azure return an error 500 with response

{"error":{"code":"InternalServerError","message":"An unexpected error occured while processing the request. Tracking ID: 'b3c4f166-7bea-4181-b477-7f5dd58aa4c0'"}}

Complete log below :

pulumi:pulumi:Stack epa-iac-dev running I1021 09:22:24.142258    7980 provider.go:1189] azure-native.Delete(urn:pulumi:dev::epa-iac::maif:dbforpostgresql:FlexibleServer$azure-native:dbforpostgresql/v20210601:Configuration::psql-epa-common-config-azure.extensions) executing
pulumi:pulumi:Stack epa-iac-dev running I1021 09:22:24.143258    7980 provider.go:1840] HTTP Request Begin PUT https://management.azure.com/subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions?api-version=2021-06-01 ===================================================
pulumi:pulumi:Stack epa-iac-dev running PUT /subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions?api-version=2021-06-01 HTTP/1.1
pulumi:pulumi:Stack epa-iac-dev running Host: management.azure.com
pulumi:pulumi:Stack epa-iac-dev running User-Agent: Go/go1.19.1 (amd64-windows) go-autorest/v14.2.1 pulumi-azure-native/v1.79.1 pid-a90539d8-a7a6-5826-95c4-1fbef22d4b22
pulumi:pulumi:Stack epa-iac-dev running Content-Length: 42
pulumi:pulumi:Stack epa-iac-dev running Content-Type: application/json; charset=utf-8
pulumi:pulumi:Stack epa-iac-dev running {"properties":{"source":"system-default"}}
pulumi:pulumi:Stack epa-iac-dev running ===================================================== HTTP Request End PUT https://management.azure.com/subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions?api-version=2021-06-01
pulumi:pulumi:Stack epa-iac-dev running I1021 09:22:24.661049    7980 provider.go:1863] HTTP Response Begin PUT [https://management.azure.com/subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions?api-version=2021-06-01 ===================================================
pulumi:pulumi:Stack epa-iac-dev running HTTP/1.1 500 Internal Server Error
pulumi:pulumi:Stack epa-iac-dev running Connection: close
pulumi:pulumi:Stack epa-iac-dev running Content-Length: 162
pulumi:pulumi:Stack epa-iac-dev running Cache-Control: no-cache
pulumi:pulumi:Stack epa-iac-dev running Content-Type: application/json; charset=utf-8
pulumi:pulumi:Stack epa-iac-dev running Date: Fri, 21 Oct 2022 07:22:24 GMT
pulumi:pulumi:Stack epa-iac-dev running Expires: -1
pulumi:pulumi:Stack epa-iac-dev running Pragma: no-cache
pulumi:pulumi:Stack epa-iac-dev running Server: Microsoft-HTTPAPI/2.0
pulumi:pulumi:Stack epa-iac-dev running Strict-Transport-Security: max-age=31536000; includeSubDomains
pulumi:pulumi:Stack epa-iac-dev running X-Content-Type-Options: nosniff
pulumi:pulumi:Stack epa-iac-dev running X-Ms-Correlation-Request-Id: cd3ce457-19c8-438a-90d6-a1b5e1b3c045
pulumi:pulumi:Stack epa-iac-dev running X-Ms-Failure-Cause: service
pulumi:pulumi:Stack epa-iac-dev running X-Ms-Ratelimit-Remaining-Subscription-Writes: 1197
pulumi:pulumi:Stack epa-iac-dev running X-Ms-Request-Id: b3c4f166-7bea-4181-b477-7f5dd58aa4c0
pulumi:pulumi:Stack epa-iac-dev running X-Ms-Routing-Request-Id: FRANCECENTRAL:20221021T072224Z:cd3ce457-19c8-438a-90d6-a1b5e1b3c045
pulumi:pulumi:Stack epa-iac-dev running {"error":{"code":"InternalServerError","message":"An unexpected error occured while processing the request. Tracking ID: 'b3c4f166-7bea-4181-b477-7f5dd58aa4c0'"}}

It seems that the API allow only a body content with source value user-override {"properties":{"source":"user-override","value":"PROVIDED_VALUE"}}

Output of pulumi about

CLI Version 3.12.0 Go Version go1.16.7 Go Compiler gc

Plugins NAME VERSION nodejs unknown

Host OS Microsoft Windows 10 Enterprise Version 10.0.19042 Build 19042 Arch x86_64

This project is written in nodejs (C:\PROGRA~1\Node\nodejs\node.exe v16.9.0)

Additional context

I switched to the Azure legacy provider with azure.postgresql.FlexibleServerConfiguration to work around the issue. It works as intended.

The debug output of pulumi up during a DELETE show a different workflow with 2 operations :

GET https://management.azure.com/subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions?api-version=2021-06-01

Response :

{
    "properties": {
        "value": "PG_TRGM",
        "description": "Specifies which extensions are allowed to be created in the server.",
        "defaultValue": "",
        "dataType": "Set",
        "allowedValues": ",address_standardizer,address_standardizer_data_us,amcheck,bloom,btree_gin,btree_gist,citext,cube,dblink,dict_int,dict_xsyn,earthdistance,fuzzystrmatch,hstore,hypopg,intagg,intarray,isn,lo,ltree,orafce,pageinspect,pg_buffercache,pg_cron,pg_freespacemap,pg_hint_plan,pg_partman,pg_prewarm,pg_repack,pg_stat_statements,pg_trgm,pg_visibility,pgaudit,pgcrypto,pglogical,pgrouting,pgrowlocks,pgstattuple,plpgsql,plv8,postgis,postgis_raster,postgis_sfcgal,postgis_tiger_geocoder,postgis_topology,postgres_fdw,sslinfo,tablefunc,timescaledb,tsm_system_rows,tsm_system_time,unaccent,uuid-ossp",
        "source": "user-override",
        "isDynamicConfig": true,
        "isReadOnly": false,
        "isConfigPendingRestart": false,
        "documentationLink": "https://docs.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-extensions#postgres-13-extensions"
    },
    "id": "/subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions",
    "name": "azure.extensions",
    "type": "Microsoft.DBforPostgreSQL/flexibleServers/configurations"
}

PATCH https://management.azure.com/subscriptions/xxxxxxxx-a703-434e-b344-3e31dcef3709/resourceGroups/rg-epa-postgresql-flexible-dev/providers/Microsoft.DBforPostgreSQL/flexibleServers/psql-epa-common-dev/configurations/azure.extensions?api-version=2021-06-01

Body content :

{"properties":{"source":"user-override","value":""}}

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

danielrbradley commented 1 year ago

Thanks for the detailed writeup @antoine-lecomte!

It appears our default value to update back to is set in defaultResourcesState.

Open questions I'm not yet clear on: