pulumi / pulumi-digitalocean

A DigitalOcean Pulumi resource package, providing multi-language access to DigitalOcean
Apache License 2.0
83 stars 13 forks source link

Deleted databases do not refresh correctly #345

Open jkodroff opened 1 year ago

jkodroff commented 1 year ago

What happened?

A DB that has been deleted outside of Pulumi does not show as deleted after running pulumi refresh and requires stack surgery in order to reconcile.

Steps to reproduce

Run this code:

const cluster = new digitalocean.DatabaseCluster("cluster", {
  engine: "mongodb",
  version: "5",
  region,
  size: digitalocean.DatabaseSlug.DB_1VPCU1GB,
  nodeCount: 1,
});

// The database we'll use for our grocery list.
const db = new digitalocean.DatabaseDb("db", {
  name: "grocery-list",
  clusterId: cluster.id,
});

Delete the DB from the DO console: https://cloud.digitalocean.com

Make some changes and run pulumi refresh -y && pulumi up -y

Expected Behavior

DB should be recreated.

Actual Behavior

An error like the following:

  digitalocean:index:DatabaseDb (db):
    error: deleting urn:pulumi:dev::fullstack-pulumi-mern-digitalocean-part-2::digitalocean:index/databaseDb:DatabaseDb::db: 1 error occurred:
        * Error deleting Database DB: DELETE https://api.digitalocean.com/v2/databases/f07b2861-4b7a-47cf-a1bd-e5f5804d0608/dbs/grocery-list: 404 (request "a0daf7f1-720c-4d1b-bcfc-bfeb651f4b52") cluster not found

Output of pulumi about

No response

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

guineveresaenger commented 1 year ago

Hi @jkodroff - the error message suggests to me that your cluster got deleted somehow?

guineveresaenger commented 1 year ago

Alright, I got my DO credits set up.

I don't see the Error deleting Database DB: error.

However, it appears there's a bug in the READ method for Database; when we invoke Refresh after deleting the grocery-list DB we see the following:

{
  "method": "/pulumirpc.ResourceProvider/Read",
  "request": {
    "id": "ae3a74f2-8e70-493f-9114-373c09470236/database/grocery-list",
    "urn": "urn:pulumi:dev::digitalocean-345::digitalocean:index/databaseDb:DatabaseDb::db",
    "properties": {
      "clusterId": "ae3a74f2-8e70-493f-9114-373c09470236",
      "id": "ae3a74f2-8e70-493f-9114-373c09470236/database/grocery-list",
      "name": "grocery-list"
    },
    "inputs": {
      "__defaults": [],
      "clusterId": "ae3a74f2-8e70-493f-9114-373c09470236",
      "name": "grocery-list"
    }
  },
  "response": {
    "id": "ae3a74f2-8e70-493f-9114-373c09470236/database/grocery-list",
    "properties": {
      "clusterId": "ae3a74f2-8e70-493f-9114-373c09470236",
      "id": "ae3a74f2-8e70-493f-9114-373c09470236/database/grocery-list",
      "name": "grocery-list"
    },
    "inputs": {
      "__defaults": [],
      "clusterId": "ae3a74f2-8e70-493f-9114-373c09470236",
      "name": "grocery-list"
    }
  },
  "metadata": {
    "kind": "resource",
    "mode": "client",
    "name": "digitalocean"
  }
}

which is false since the DB got deleted.