https://pulumi.com logo
#azure
Title
# azure
g

gorgeous-accountant-60580

08/02/2023, 11:28 AM
We’re trying to update from using
azure-native:dbforpostgresql/v20210601:Server
to using
azure-native:dbforpostgresql/v20221201:Server
, but this fails as Pulumi attempts to create new databases overwriting the existing ones. The azure-native documentation says that you can update API versions back and forth, and I see that our previous API version is listed as an alias in the new version of the provider (https://github.com/pulumi/pulumi-azure-native-sdk/blob/dbforpostgresql/v1.104.0/dbforpostgresql/v20221201/server.go#L105) Are there any obvious gotchas here?
m

melodic-tomato-39005

08/02/2023, 11:41 AM
Hi Morten! What version of the Azure Native provider are you using?
g

gorgeous-accountant-60580

08/02/2023, 11:41 AM
We are using v1.104.0 and trying to move to an API version which also exists in v2 so that we can migrate
m

melodic-tomato-39005

08/02/2023, 11:44 AM
can you share Pulumi’s diff when running
up
?
g

gorgeous-accountant-60580

08/02/2023, 11:47 AM
Copy code
jsonPayload: {
level: "debug"
caller: "services/platform/gollum/pkg/stack/stack.go:157"
message: "Updating (alert-service.dsj-alerts.azure-dev):

    pulumi:pulumi:Stack postgres-alert-service.dsj-alerts.azure-dev running 
    cognite:database:azure:Postgres dsj-alerts-alert-service  
    cognite:database:Instance dsj-alerts-alert-service  
@ updating....
    random:index:RandomPassword dsj-alerts-alert-service-postgresql-username-password  
    azure-native:resources:ResourceGroup dsj-alerts-alert-service-rg  
    azure-native:network:PrivateZone dsj-alerts-alert-service  
    azure-native:network:VirtualNetworkLink dsj-alerts-alert-service-defaultVnet  
@ updating.....
    random:index:RandomString dsj-alerts-alert-service-sa-suffix  
    azure-native:network:VirtualNetworkLink dsj-alerts-alert-service-aksVnet  
    azure-native:operationalinsights:Workspace dsj-alerts-alert-service  
    azure-native:storage:StorageAccount dsj-alerts-alert-service  
@ updating....
 +  azure-native:dbforpostgresql/v20221201:Server dsj-alerts-alert-service creating (0s) 
 +  azure-native:dbforpostgresql/v20221201:Server dsj-alerts-alert-service creating (0s) error: cannot create already existing subresource '/subscriptions/531564ca-ed4c-48b5-b4d0-6363b20c3aeb/resourceGroups/rg-postgresql-dsj-alerts-alert-service/providers/Microsoft.DBforPostgreSQL/flexibleServers/dsj-alerts-alert-service-azure-dev'
 +  azure-native:dbforpostgresql/v20221201:Server dsj-alerts-alert-service **creating failed** error: cannot create already existing subresource '/subscriptions/531564ca-ed4c-48b5-b4d0-6363b20c3aeb/resourceGroups/rg-postgresql-dsj-alerts-alert-service/providers/Microsoft.DBforPostgreSQL/flexibleServers/dsj-alerts-alert-service-azure-dev'
@ updating....
    pulumi:pulumi:Stack postgres-alert-service.dsj-alerts.azure-dev running error: update failed
    pulumi:pulumi:Stack postgres-alert-service.dsj-alerts.azure-dev **failed** 1 error
    cognite:database:azure:Postgres dsj-alerts-alert-service  
    cognite:database:Instance dsj-alerts-alert-service  

Diagnostics:
  azure-native:dbforpostgresql/v20221201:Server (dsj-alerts-alert-service):
    error: cannot create already existing subresource '/subscriptions/531564ca-ed4c-48b5-b4d0-6363b20c3aeb/resourceGroups/rg-postgresql-dsj-alerts-alert-service/providers/Microsoft.DBforPostgreSQL/flexibleServers/dsj-alerts-alert-service-azure-dev'

  pulumi:pulumi:Stack (postgres-alert-service.dsj-alerts.azure-dev):
    error: update failed

Outputs:
  - AdminPassword: [secret]
  - AdminUser    : "postgres"
  - Host         : "[snip]"
  - Port         : "5432"

Resources:
    11 unchanged

Duration: 5s

"
stack: "alert-service.dsj-alerts.azure-dev"
}
We run our own k8s operator that runs pulumi, so that output might be a tiny bit nonstandard
m

melodic-tomato-39005

08/02/2023, 11:56 AM
Hmm, not sure on first glance. What does
pulumi refresh
say?>
t

tall-librarian-49374

08/02/2023, 12:29 PM
@melodic-tomato-39005 Isn't it upgrading from Single Server to Flexible Server?
g

gorgeous-accountant-60580

08/02/2023, 12:29 PM
We’re already on flexible server
t

tall-librarian-49374

08/02/2023, 12:29 PM
Nice, sorry for a wrong guess
g

gorgeous-accountant-60580

08/02/2023, 12:38 PM
@melodic-tomato-39005 our service only prints refresh logs on failure, so I don’t have any refresh output. I do have some failed refresh attempts from when we first tried v2
That failed with a ton of errors like so:
Copy code
azure-native:dbforpostgresql/v20210601:Configuration (idle_in_transaction_session_timeout):
    error: autorest/azure: Service returned an error. Status=400 Code="MissingApiVersionParameter" Message="The api-version query parameter (?api-version=) is required for all requests."
m

melodic-tomato-39005

08/02/2023, 2:13 PM
So you are refreshing successfully, you just don’t have the output?
Are you using component resources per chance? It sounds potentially similar to https://github.com/pulumi/pulumi-azure-native/issues/2505.
g

gorgeous-accountant-60580

08/02/2023, 2:16 PM
@melodic-tomato-39005 Yes, refresh seems successful. I think the issue you linked is relevant. We’re using a component resource to group some things
I see this comment, which could help: “Explicitly adding an alias to the
CustomResourceOptions
for the old name seems to allow Pulumi to keep the link, and avoids Pulumi wanting to delete stuff.”
Will resources be updated to the new API version in the stack file, or will we have to keep that alias around forever?
m

melodic-tomato-39005

08/02/2023, 2:20 PM
I’m not sure, sorry