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

(fix): fix database bootstrap #102

Conversation

vincentsarago
Copy link
Member

@vincentsarago vincentsarago commented Mar 12, 2024

⚠️ Checklist if your PR is changing anything else than documentation

  • Posted the link to a successful manually triggered deployment workflow (successful including the resources destruction)

Merge request description

admin_params = get_secret(params["conn_secret_arn"])

# Custom eoAPI user/password/dbname parameters
eoapi_params = get_secret(params["new_user_secret_arn"])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to make the variable names a bit more clear!

timeout=30,
)
print("Status code: " + response.status_code)
print("Status code: ", response.status_code)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was a bug here

# Update permissions to eoAPI user to assume pgstac_* roles
with conn.cursor() as cur:
print(f"Update *{eoapi_params['username']}* permissions...")
print(f"Update '{eoapi_params['username']}' permissions...")
update_user_permissions(
cursor=cur,
db_name=eoapi_params["dbname"],
username=eoapi_params["username"],
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to have the search path set to pgstac,public in order to update the user permission or granting pgstac_* to user won't work 😅

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One trick that might be useful is to just set the search_path on the new database you are creating.
ALTER DATABASE mydb SET SEARCH_PATH TO pgstac, public;

@vincentsarago
Copy link
Member Author

ok, So deployment still fails with the same error message

[ERROR] InsufficientPrivilege: must be member of role "pgstac_ingest"
Traceback (most recent call last):
  File "/var/task/handler.py", line 266, in handler
    raise e
  File "/var/task/handler.py", line 230, in handler
    Migrate(pgdb).run_migration(params["pgstac_version"])
  File "/var/task/pypgstac/migrate.py", line 149, in run_migration
    cur.execute(migration_sql)
  File "/var/task/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)

When running the handler locally I don't get any error! there must be something special about RDS

@vincentsarago vincentsarago marked this pull request as ready for review March 13, 2024 15:04
@vincentsarago vincentsarago merged commit fa9b40b into feature/update-runtimes-and-add-pgstac-customization Mar 13, 2024
3 checks passed
@vincentsarago vincentsarago deleted the patch/fix-database-bootstrap branch March 13, 2024 15:06
vincentsarago added a commit that referenced this pull request Mar 13, 2024
* feat: update runtimes and add pgstac customization options

* Update lib/tipg-api/runtime/requirements.txt

Co-authored-by: Emile Tenezakis  <e.tenezakis@gmail.com>

* change defaults

* revert version updates

* Revert "revert version updates"

This reverts commit 0d675e2.

* back to 0.7.1

* (fix): fix database bootstrap (#102)

* (fix): fix database bootstrap

* fix handler

* update to pgstac 0.8.5

---------

Co-authored-by: Emile Tenezakis <e.tenezakis@gmail.com>
github-actions bot pushed a commit that referenced this pull request Mar 13, 2024
# [7.1.0](v7.0.1...v7.1.0) (2024-03-13)

### Features

* update runtimes and add pgstac customization options ([#100](#100)) ([9e49e7e](9e49e7e)), closes [#102](#102)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants