api-v2
api-v2 copied to clipboard
GETs on newly created database replicas return 404
Hello all, I'm getting some unexpected behavior when using the digitalocean api. Please let me know if I'm doing something wrong or if this is not the best way to report this.
The digitalocean api is returning a 404 NOT FOUND status for newly created database replicas. It takes a few minutes to return a 200 OK and the replica json. I believe the expected behavior is that the api return a 200 OK immediately upon creation.
How to replicate
- Create a db cluster
- Wait for db cluster to have
status
ofonline
- Create a replica db in db cluster
- Get replica db (get 404)
- List replica dbs (get no results)
- Note that replica db shows up in the https://digitalocean.com databases ui
- Wait for replica to have
status
ofonline
in ui - Get replica db (get 200)
- List replica dbs (get expected result)
Create a db cluster
export DIGITALOCEAN_TOKEN=''
curl --request POST \
--url https://api.digitalocean.com/v2/databases \
--header "authorization: Bearer {DIGITALOCEAN_TOKEN}" \
--header 'content-type: application/json' \
--data '
{
"name": "pg-primary-6d3f7199",`
"engine": "pg",
"version": "14",
"region": "nyc1",
"size": "db-s-1vcpu-1gb",
"num_nodes": 1
}'
Create db cluster response
{
"database": {
"id": "b571c46d-6888-41da-b8d1-dd0f5bd0c216",
"name": "pg-primary-6d3f7199",
"engine": "pg",
"version": "14",
"connection": {
"protocol": "postgresql",
"uri": "postgresql://{USERNAME}:{PASSWORD}@pg-primary-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
"database": "defaultdb",
"host": "pg-primary-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com",
"port": 25060,
"user": "{USERNAME}",
"password": "{PASSWORD}",
"ssl": true
},
"private_connection": {
"protocol": "postgresql",
"uri": "postgresql://{USERNAME}:{PASSWORD}@private-pg-primary-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
"database": "defaultdb",
"host": "private-pg-primary-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com",
"port": 25060,
"user": "{USERNAME}",
"password": "{PASSWORD}",
"ssl": true
},
"users": null,
"db_names": null,
"num_nodes": 1,
"region": "nyc1",
"status": "creating",
"created_at": "2022-10-04T19:50:01Z",
"maintenance_window": {
"day": "wednesday",
"hour": "09:19:39",
"pending": false
},
"size": "db-s-1vcpu-1gb",
"tags": null,
"private_network_uuid": "{UUID}",
"project_id": ""
}
}
Wait for db cluster to have status
of online
. This request will return the expected 200 OK response with JSON containing db cluster info.
curl --request GET \
--url https://api.digitalocean.com/v2/databases/b571c46d-6888-41da-b8d1-dd0f5bd0c216 \
--header "authorization: Bearer ${DIGITALOCEAN_TOKEN}" \
--header 'content-type: application/json'
Create a replica db in db cluster
curl --request POST \
--url https://api.digitalocean.com/v2/databases/b571c46d-6888-41da-b8d1-dd0f5bd0c216/replicas \
--header "authorization: Bearer ${DIGITALOCEAN_TOKEN}" \
--header 'content-type: application/json' \
--data '
{
"name": "pg-replica-6d3f7199",
"region": "nyc1",
"size": "db-s-1vcpu-1gb"
}'
Create replica db response
{
"replica": {
"id": "",
"name": "pg-replica-6d3f7199",
"connection": {
"protocol": "postgresql",
"uri": "postgresql://{USERNAME}:{PASSWORD}@pg-replica-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
"database": "defaultdb",
"host": "pg-replica-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com",
"port": 25060,
"user": "{USERNAME}",
"password": "{PASSWORD}",
"ssl": true
},
"private_connection": {
"protocol": "postgresql",
"uri": "postgresql://{USERNAME}:{PASSWORD}@private-pg-replica-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com:25060/defaultdb?sslmode=require",
"database": "defaultdb",
"host": "private-pg-replica-6d3f7199-do-user-{USER}-0.b.db.ondigitalocean.com",
"port": 25060,
"user": "{USERNAME}",
"password": "{PASSWORD}",
"ssl": true
},
"region": "nyc1",
"status": "forking",
"created_at": "2022-10-04T20:18:29Z",
"private_network_uuid": "{UUID}"
}
}
Get replica db
curl --request GET \
--url https://api.digitalocean.com/v2/databases/b571c46d-6888-41da-b8d1-dd0f5bd0c216/replicas/pg-replica-6d3f7199 \
--header "authorization: Bearer ${DIGITALOCEAN_TOKEN}" \
--header 'content-type: application/json'
Get replica db response
404 NOT FOUND
{
"message": "not found",
"id": "not_found",
"request_id": "6c72c63d-53a4-49a1-ad2c-8d4182d40502"
}
List replica dbs
curl --request GET \
--url https://api.digitalocean.com/v2/databases/b571c46d-6888-41da-b8d1-dd0f5bd0c216/replicas \
--header "authorization: Bearer ${DIGITALOCEAN_TOKEN}" \
--header 'content-type: application/json'
List replica dbs response
200 OK
{
"replicas": null
}
The GET replica db request returns a 404 NOT FOUND for a few minutes then returns 200 0K once the replica db has a status
of online
. The replica db is displayed in the https://digitalocean.com databases dashboard ui while the api returns a 404 NOT FOUND.
I believe the expected behavior is that a GET on the newly created replica db return a 200 OK response with the replica db json.
Thank you for reviewing this report! Please let me know if I can provide any additional information.