Navigation Menu

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

nixos/mysql: split database provisioning into a separate systemd unit #81432

Closed
wants to merge 5 commits into from

Conversation

aanderse
Copy link
Member

@aanderse aanderse commented Mar 1, 2020

Motivation for this change
  • prevent mysql/mariadb server from restarting for no good reason when using ensure* options
  • add a mysql.target so module authors have a .target to use for custom database scripts
  • minor cleanup
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

ping @thorstenweber83

@aanderse
Copy link
Member Author

aanderse commented Aug 9, 2020

@GrahamcOfBorg test mysql mysql-replication
@GrahamcOfBorg test wordpress

@aanderse aanderse marked this pull request as ready for review August 9, 2020 18:50
@aanderse
Copy link
Member Author

aanderse commented Aug 9, 2020

Failing test was already failing before this PR, see https://hydra.nixos.org/build/124999727.

Copy link
Member

@aszlig aszlig left a comment

Choose a reason for hiding this comment

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

Very cool, thanks for your work. This should finally make it easier to customise the service to allow much more complicated scenarios (without replacing the module).

Some random thoughts: Maybe it makes sense to add a test which uses the new mysql.target to not only ensure that ordering works correctly but also to have a working example on how to write those services. Additionally, maybe it makes sense to initialise each database in its own unit - that way you could order your services after eg. mysql-init-mydatabase.service.

NoNewPrivileges = true;
# Sandboxing
ProtectSystem = "strict";
ProtectHome = true;
Copy link
Member

Choose a reason for hiding this comment

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

Did you check whether confinement.enable works here? Because if that's the case we can even restrict access to just the relevant store paths.

@aanderse
Copy link
Member Author

I like the suggestion of a separate .service for each database. I'm thinking a single .service for all users and then each database init service can run before the users init service. Sound good @aszlig?

@aanderse aanderse closed this Dec 21, 2020
@aanderse aanderse deleted the mysql-post-start branch December 21, 2021 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants