Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create-app (aka bootstrap) by default assumes that neondb_owner user already exists #272

Open
mrl5 opened this issue Aug 23, 2024 · 0 comments

Comments

@mrl5
Copy link
Contributor

mrl5 commented Aug 23, 2024

neonctl bootstrap (aka create-app) by default assumes that neondb_owner user already exists and at the same time doesn't accept owner_name as a parameter

Steps to reproduce

  1. Create some project and database, don't use neondb name.
  2. Make sure that neondb_owner user doesn't exists.
  3. Run neonctl bootstrap

Expected result

  • neondb_owner user is created if not exists

Actual result

<REDACTED>
✔ What Neon project would you like to use? › some_existing_project
Branch
┌─────────────────────────┬────────────────┬─────────┬─────────┬──────────────────────┬──────────────────────┐
│ Id                      │ Name           │ Primary │ Default │ Created At           │ Updated At           │
├─────────────────────────┼────────────────┼─────────┼─────────┼──────────────────────┼──────────────────────┤
│ br-misty-bonus-a29xcad8 │ dev/y8pjG4iG3d │ false   │ false   │ 2024-08-23T20:41:21Z │ 2024-08-23T20:41:21Z │
└─────────────────────────┴────────────────┴─────────┴─────────┴──────────────────────┴──────────────────────┘
INFO: Resource is locked. Waiting 3000ms before retrying...
ERROR: database owner not found

which under the hood comes from

curl -i --request POST \
    --url https://console.neon.tech/api/v2/projects/ancient-bush-51935299/branches/br-blue-surf-a2a0d1bc/databases \
    --header "Authorization: Bearer $token" \
    --header 'accept: application/json' \
    --header 'content-type: application/json' \
    --data '
{
  "database": {
    "name": "slo",
    "owner_name": "casey"
  }
}
'
HTTP/2 422

{"code":"","message":"database owner not found"}

Nice to have

additional --owner-name flag where you can define it. I think it could also be created if not exist but that's debatable otherwise this could be reused

props.ownerName ??
(await props.apiClient
.listProjectBranchRoles(props.projectId, branchId)
.then(({ data }) => {
if (data.roles.length === 0) {
throw new Error(`No roles found in branch ${branchId}`);
}
if (data.roles.length > 1) {
throw new Error(
`More than one role found in branch ${branchId}. Please specify the owner name. Roles: ${data.roles
.map((r) => r.name)
.join(', ')}`,
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants