pulumi / pulumi-cloudflare

Pulumi's Cloudflare package, providing multi-language infrastructure as code for Cloudflare
Apache License 2.0
104 stars 13 forks source link

Upgrade from 3.6.0 to 4.15.0 causes all Record resources to be recreated and fail #325

Open barclayadam opened 1 year ago

barclayadam commented 1 year ago

What happened?

After upgrading Cloudflare all our Record resources are marked as required replacements, unnecessarily. This either ends with a failure due to the records being protected, or the replacement fails because it attempts to create the same DNS record which, given it's identical, fails in CF API.

Expected Behavior

No replacements of Record resources

Steps to reproduce

  1. Create a Record and up, using provider version 3.6.0
  2. Upgrade package.json to use @pulumi/cloudflare 4.15.0
  3. Run deployment again and see failure

Output of pulumi about

CLI Version 3.53.1 Go Version go1.19.5 Go Compiler gc

Plugins NAME VERSION azure 4.37.0 azure-native 1.93.0 azuread 5.26.1 cloudflare 4.15.0 docker 3.0.0 docker-buildkit 0.1.17 kubernetes 3.23.1 newrelic 4.18.0 nodejs unknown random 4.0.0 tls 4.0.0

Host OS Microsoft Windows 11 Pro Version 10.0.22000 Build 22000 Arch x86_64

Additional context

No response

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).

AaronFriel commented 1 year ago

Hey @barclayadam, thanks for reporting this. What properties did you see in the diff between 3.6.0 and 4.15.0 that Pulumi flagged for replace?

yz89122 commented 1 year ago

same issue here: https://github.com/pulumi/pulumi-cloudflare/issues/272

yz89122 commented 1 year ago

@AaronFriel I've encounter this issue, too. In my case, Pulumi preview says every field have changed, but the values are actually the same.

I tried use version 4 to import my resource again, and see the difference inside state file is the schema_version in outputs.__meta bumped from 1 to 2. And I tried change schema_version from 2 to 1, it'll reproduce this problem.

barclayadam commented 1 year ago

@AaronFriel sorry for the delay, I have just turned my attention back towards the upgrade. According to the Pulumi portal all field values have changed:

image

I'm not sure if an issue, but the "Diff" view does not actually show any differences on that resource:

image

I have tried this on the latest v5.0.0 provider and the result is the same. We have roughly 50 records so would like whatever needs to be done automated if possible, without re-importing resources etc. This is a blocker for us to upgrade the provider at the moment.

barclayadam commented 1 year ago

I use the automation engine, so have grabbed the resourcePreEvent that shows the calculated diffs:

{
    "sequence": 86,
    "timestamp": 1683797799,
    "resourcePreEvent":
    {
        "metadata":
        {
            "op": "create-replacement",
            "urn": "urn:pulumi:uat-deploy-global::s365-analytics::cloudflare:index/record:Record::analytics-ingestion-cname",
            "type": "cloudflare:index/record:Record",
            "old":
            {
                "type": "cloudflare:index/record:Record",
                "urn": "urn:pulumi:uat-deploy-global::s365-analytics::cloudflare:index/record:Record::analytics-ingestion-cname",
                "custom": true,
                "id": "<redacted-id>",
                "parent": "urn:pulumi:uat-deploy-global::s365-analytics::pulumi:pulumi:Stack::s365-analytics-uat-deploy-global",
                "inputs":
                {
                    "__defaults":
                    [
                        "allowOverwrite"
                    ],
                    "allowOverwrite": false,
                    "name": "campaigns",
                    "proxied": true,
                    "type": "CNAME",
                    "value": "<redacted-value>",
                    "zoneId": "<redacted-zoneid>"
                },
                "outputs":
                {
                    "__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":30000000000,\"update\":30000000000},\"schema_version\":\"1\"}",
                    "allowOverwrite": false,
                    "createdOn": "2020-11-30T11:41:03.598548Z",
                    "data":
                    {},
                    "hostname": "<redacted-hostname>",
                    "id": "<redacted-id>",
                    "metadata":
                    {
                        "auto_added": "false",
                        "managed_by_apps": "false",
                        "managed_by_argo_tunnel": "false",
                        "source": "primary"
                    },
                    "modifiedOn": "2020-11-30T11:41:03.598548Z",
                    "name": "campaigns",
                    "priority": 0,
                    "proxiable": true,
                    "proxied": true,
                    "ttl": 1,
                    "type": "CNAME",
                    "value": "<redacted-value>",
                    "zoneId": "<redacted-zoneid>"
                },
                "provider": ""
            },
            "new":
            {
                "type": "cloudflare:index/record:Record",
                "urn": "urn:pulumi:uat-deploy-global::s365-analytics::cloudflare:index/record:Record::analytics-ingestion-cname",
                "custom": true,
                "id": "",
                "parent": "urn:pulumi:uat-deploy-global::s365-analytics::pulumi:pulumi:Stack::s365-analytics-uat-deploy-global",
                "inputs":
                {
                    "__defaults":
                    [
                        "allowOverwrite"
                    ],
                    "allowOverwrite": false,
                    "name": "campaigns",
                    "proxied": true,
                    "type": "CNAME",
                    "value": "<redacted-value>",
                    "zoneId": "<redacted-zoneid>"
                },
                "outputs":
                {},
                "provider": ""
            },
            "keys":
            [
                "type",
                "name",
                "zoneId"
            ],
            "diffs":
            [
                "type",
                "value",
                "allowOverwrite",
                "proxied",
                "name",
                "zoneId"
            ],
            "detailedDiff":
            {
                "allowOverwrite":
                {
                    "diffKind": "update",
                    "inputDiff": false
                },
                "name":
                {
                    "diffKind": "update-replace",
                    "inputDiff": false
                },
                "proxied":
                {
                    "diffKind": "update",
                    "inputDiff": false
                },
                "type":
                {
                    "diffKind": "update-replace",
                    "inputDiff": false
                },
                "value":
                {
                    "diffKind": "update",
                    "inputDiff": false
                },
                "zoneId":
                {
                    "diffKind": "update-replace",
                    "inputDiff": false
                }
            },
            "provider": "urn:pulumi:uat-deploy-global::s365-analytics::pulumi:providers:cloudflare::default_5_0_0::6123d7e9-ce2e-421c-8e26-988603666244"
        }
    }
}

I have redacted some properties. I confirmed that values are identical between the olds and news though (i.e. where it has everywhere that appears was definitely the same value

onching commented 1 year ago

@AaronFriel I've encounter this issue, too. In my case, Pulumi preview says every field have changed, but the values are actually the same.

I tried use version 4 to import my resource again, and see the difference inside state file is the schema_version in outputs.__meta bumped from 1 to 2. And I tried change schema_version from 2 to 1, it'll reproduce this problem.

(3.6.0 to 4.16.0 using state buckets not pulumi service) I created a new dns A record using the new provider and compared the json objects in the stack export. I actually noticed another difference. outputs.__meta. schema_version also changed 1 -> 2 but also a new property tags: [] and data: {} to data: null.

i went so far as to export the stack modify a dns record that was showing as a replacement by manually changing the schema_version 1 -> 2 and added the property tags: [] and data:null. after which "up" reported nothing to do. Refresh added comment: "". If you're willing to risk it, it's a workaround. you can follow the steps of creating a new record in your stack to compare differences in the export to try to minimize risk.