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

Enrich PostgreSQL ensure users and databases support #203474

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rycee
Copy link
Member

@rycee rycee commented Nov 28, 2022

Description of changes

This PR includes a general cleanup of the generation of the "ensure users and databases" script.

It also makes it possible to create users with password.

Finally, it also makes it possible to create databases with additional parameters such as DB owner and encoding.

The matrix-synapse test is updated to use the new capabilities.

The changes should be backwards compatible.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Nov 28, 2022
Specifically, this commit makes it possible to set various database
parameters beside just the name.
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Nov 28, 2022
This reorganizes the ensure code generation to make the code a bit
less dense and also do general cleanups.

Most importantly, the order is changed to first create users, then
databases, and finally grants. This allows the database creation to
refer to new users as owners.
@rycee rycee changed the title Enrich PostgreSQL ensure users and databases support WIP: Enrich PostgreSQL ensure users and databases support Nov 28, 2022
This replaces the explicit database setup script to instead use the
PostgreSQL `ensureUsers` and `ensureDatabases` options.
@rycee rycee changed the title WIP: Enrich PostgreSQL ensure users and databases support Enrich PostgreSQL ensure users and databases support Nov 28, 2022
Copy link
Member

@RaitoBezarius RaitoBezarius left a comment

Choose a reason for hiding this comment

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

Amazing! Do you think it would be possible to have a bit of more NixOS tests for exercising this? Do you know if this can affect existing setups, as in, have you tried to run other tests? Can you add release notes information on this?

@rycee
Copy link
Member Author

rycee commented Dec 8, 2022

@RaitoBezarius Thanks for having a look! Yeah, more tests would be good. Shouldn't be too tricky.

The change should be entirely backwards compatible.

I can add a bullet point in the release notes.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/anybody-wanna-adopt-203474/25524/1

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

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

We are missing migrations from the old settings.


isTemplate = mkOption {
type = types.nullOr types.bool;
default = null;
Copy link
Member

Choose a reason for hiding this comment

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

Why not default to false here?


allowConnections = mkOption {
type = types.nullOr types.bool;
default = null;
Copy link
Member

Choose a reason for hiding this comment

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

I think I reasonable default would be true

default = null;
example = "sv_SE.utf8";
description = lib.mdDoc ''
Character classification to use for the new database.
Copy link
Member

Choose a reason for hiding this comment

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

Does this fallback to the current environment set locale?


template = mkOption {
type = types.nullOr types.str;
default = null;
Copy link
Member

Choose a reason for hiding this comment

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

What uses postgres when creating a DB? We should default to that

Copy link
Member

Choose a reason for hiding this comment

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

I suspect that most of these options might have different defaults depending on the postgresql version.

Some of these could also be influenced by options for the daemon itself

@exzombie
Copy link
Contributor

exzombie commented Jun 5, 2023

I can confirm that the mechanism to set the database owner implemented here solves #216989. Looking forward to seeing this merged! Note that the manual section on Nextcloud should be updated to include setting the owner.

@rycee
Copy link
Member Author

rycee commented Jun 18, 2023

@exzombie I will not work more on this PR. I would be happy for you to take it over if you are interested.

@exzombie
Copy link
Contributor

@rycee I'm sorry to hear that. I'm afraid I can't take this over right now, too much going on.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/what-about-state-management/37082/1

@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict This PR has merge conflicts with the target branch labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants