Skip to content

Conversation

olirice
Copy link
Contributor

@olirice olirice commented Aug 2, 2022

Installs pg_jsonschema v0.1.0

The ansible task is a best effort but might have some issues. Is there a way to check it in CI without merging to develop?

@olirice olirice requested a review from dragarcia August 2, 2022 15:27
Copy link
Contributor

@dragarcia dragarcia left a comment

Choose a reason for hiding this comment

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

The ansible task is a best effort but might have some issues. Is there a way to check it in CI without merging to develop?

What I usually do is spin up the latest image, SSH in, and attempt to install the extension using the steps outlined in the task.


Other than that, we'll just need to:

  • Remove ansible/tasks/postgres-extensions/.21-pg_jsonschema.yml.swp and add *.swp in .gitignore.
  • Rename 21-pg_jsonschema.yml and anything related to it name-wise to 22-pg_jsonschema.yml as 21-auto_explain.yml already exists.
  • Bump common.vars.pkr.hcl to the next version.
tags:
- rust

- name: install cargo-pgx
Copy link
Contributor

Choose a reason for hiding this comment

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

The following error was returned upon running this step:

Error: 0: problem running initdb: "/usr/lib/postgresql/bin/initdb" "-D" "/root/.pgx/data-14" initdb: error: cannot be run as root Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process. 

Would there be any implications if all the steps here aside from the downloading and installation of dependencies were to be performed by the postgres Linux user (which I'm assuming should be owning the server process)?

Copy link
Contributor

@dragarcia dragarcia Aug 5, 2022

Choose a reason for hiding this comment

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

Have tested running everything as the postgres Linux user and it looks to be working. Only hitch is that we would have to temporarily grant the postgres Linux user ownership of /usr/lib/postgresql/lib to ensure cargo pgx install --release is fully installed. Else, the following error would be returned:

Error: 0: failed copying `/tmp/pg_jsonschema/target/release/libpg_jsonschema.so` to `/usr/lib/postgresql/lib/pg_jsonschema.so` 1: Permission denied (os error 13) Location: /home/postgres/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-pgx-0.4.5/src/command/install.rs:234 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0: cargo_pgx::command::install::install_extension with pg_version=14.14 release=true test=false features=["pg14"] at /home/postgres/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-pgx-0.4.5/src/command/install.rs:84 1: cargo_pgx::command::install::execute at /home/postgres/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-pgx-0.4.5/src/command/install.rs:51 

Should be okay since we're returning ownership to the root Linux user afterward. @olirice which OS user do you use for these steps when following the installation in the pg_jsonschema readme?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The installation instructions in the readme are more for trying it vs a release so the OS user can be the user who ran cargo pgx init when setting up the pgx framework

tested running everything as the postgres Linux user and it looks to be working. Only hitch is that we would have to temporarily grant the postgres Linux user ownership of /usr/lib/postgresql/lib to ensure cargo pgx install --release is fully installed

Could you please please push that change to this branch? I'm not clear how to do it

@olirice
Copy link
Contributor Author

olirice commented Aug 5, 2022

@dragarcia thanks for the feedback! I made the changes you mentioned in all of the comments except the one that is still unresolved

What I usually do is spin up the latest image, SSH in, and attempt to install the extension using the steps outlined in the task.

do you run the actual ansible script for that, or copy/paste the commands?

@olirice olirice requested a review from dragarcia August 5, 2022 19:12
- ensure certain steps are run by the postgres Linux user - temporarily grant ownership for certain directories to the postgres Linux user
@dragarcia
Copy link
Contributor

do you run the actual ansible script for that, or copy/paste the commands?

The latter. More precisely, I would first come up with the steps in the form of shell commands, run each of these steps to ensure that they're working as expected, then translate them into Ansible tasks.

@dragarcia dragarcia merged commit 36e6502 into develop Aug 8, 2022
@dragarcia dragarcia deleted the pg_jsonschema_task branch August 8, 2022 08:18
pessimo pushed a commit to pessimo/postgres that referenced this pull request Sep 14, 2022
* install pg_jsonschema v0.1.0 * tabs to spaces * Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com> * Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com> * remove and ignore swp files * pg_jsonschema task 21 -> 22 * bump img version * remaining steps - ensure certain steps are run by the postgres Linux user - temporarily grant ownership for certain directories to the postgres Linux user Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com>
hf pushed a commit that referenced this pull request Jan 23, 2023
* install pg_jsonschema v0.1.0 * tabs to spaces * Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com> * Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com> * remove and ignore swp files * pg_jsonschema task 21 -> 22 * bump img version * remaining steps - ensure certain steps are run by the postgres Linux user - temporarily grant ownership for certain directories to the postgres Linux user Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com>
damonrand pushed a commit to cepro/postgres that referenced this pull request Jun 15, 2025
* install pg_jsonschema v0.1.0 * tabs to spaces * Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com> * Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com> * remove and ignore swp files * pg_jsonschema task 21 -> 22 * bump img version * remaining steps - ensure certain steps are run by the postgres Linux user - temporarily grant ownership for certain directories to the postgres Linux user Co-authored-by: dragarcia <Angelico.delosreyes@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants