Skip to content

nixos/redis: enable multiple instances of redis-server#142635

Merged
tomberek merged 2 commits intoNixOS:masterfrom
ju1m:redis
Dec 13, 2021
Merged

nixos/redis: enable multiple instances of redis-server#142635
tomberek merged 2 commits intoNixOS:masterfrom
ju1m:redis

Conversation

@ju1m
Copy link
Contributor

@ju1m ju1m commented Oct 23, 2021

Motivation for this change

Revamping of services.redis to support per-application redis-server as it's supposed to be used since Redis databases are only mere key prefixes without any configuration or ACL of their own.
This is was extracted from #133984 to do a proper review.

Things done
  • nix -L run -f . nixosTests.redis
  • nix -L run -f . nixosTests.txredisapi
  • 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 via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages 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/)
  • 21.11 Release Notes (or backporting 21.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
  • Fits CONTRIBUTING.md.

@ju1m ju1m requested a review from WilliButz as a code owner October 23, 2021 03:47
@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 Oct 23, 2021
@ju1m ju1m requested a review from flokli October 23, 2021 03:49
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Oct 23, 2021
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/prs-ready-for-review/3032/628

@ju1m ju1m requested review from Izorkin and dasJ November 3, 2021 12:28
@aanderse
Copy link
Member

aanderse commented Nov 3, 2021

Might be a bit late in the release cycle to merge this for 21.11.

@Izorkin
Copy link
Contributor

Izorkin commented Nov 3, 2021

It seems to me that the option looks bad:

services.redis.servers."".enable = true;

Сan try like this?:

services.redis.servers."default".enable = true;

or:

services.redis.servers.enable = true;
services.redis.servers."test1".enable = true;
services.redis.servers."test2".enable = true;

@ju1m
Copy link
Contributor Author

ju1m commented Nov 13, 2021

It seems to me that the option looks bad:

services.redis.servers."".enable = true;

@Izorkin, indeed, I find it bad looking too, but to my mind it is a reminder that redis-server is not meant to be a global service, and that you should specify a server dedicated to your usage. I mean, naming it "" or "default" leads to the same bad practice this PR wants to get rid of.

Сan try like this?:

services.redis.servers."default".enable = true;

The thing is that mkRenamedOptionModule-ing using "default" instead of "" would break backward compatibility of the Unix user, group and socket path, unless the "default" server is singled out to behave like the "" server, but then what to do with the "" server? making it a synonym? disallowing it? I prefer to avoid special cases and keep the current 1-to-1 mapping.

or:

services.redis.servers.enable = true;
services.redis.servers."test1".enable = true;
services.redis.servers."test2".enable = true;

Not sure it can be done and that would be confusing because services.redis.servers is an attrset, so I would prefer to keep it simple.
What could be done is using mkAliasOptionModule instead of mkRenamedOptionModule, but again this would weaken the goal of this PR to get rid of any such thing as a global redis-server.

@tomberek
Copy link
Contributor

tomberek commented Dec 1, 2021

Re-visit/re-review this now that 21.11 is complete?

Copy link
Member

@symphorien symphorien left a comment

Choose a reason for hiding this comment

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

I'm really not familiar with redis, but I left two small comments

Copy link
Member

Choose a reason for hiding this comment

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

why this default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For backward compatibility: previously redis was accessible over TCP by default, but this is not (easily) possible with multiple instances due to the need to allocate a TCP port.

@aanderse aanderse requested a review from roberth December 9, 2021 13:21
@aanderse
Copy link
Member

aanderse commented Dec 9, 2021

ping @roberth because of #148456

@roberth
Copy link
Member

roberth commented Dec 9, 2021

I don't think this interacts with #148456 more than any other module so that's fine.
Peeking at the PR, it seems that "" instead of "default" could be a decent choice if it means that the module logic is simpler and more predictable.
Please do add instructions to the release notes and explain the occurrences of "" using inline comments, so other maintainers know what's going on.

That all said, I will leave the review to maintainers who use redis.

@roberth roberth removed their request for review December 9, 2021 13:30
@ju1m ju1m force-pushed the redis branch 2 times, most recently from abe003b to 604df18 Compare December 9, 2021 15:20
@github-actions github-actions bot added 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation labels Dec 9, 2021
@ju1m
Copy link
Contributor Author

ju1m commented Dec 9, 2021

  • Add release note.
  • Fix description of services.redis.extraConfig.
  • Rebase on latest master.

@tomberek
Copy link
Contributor

I'll merge this after the weekend it there is no further interest or discussion. This will provide a long time to fix any issues prior to the next release.

@ju1m ju1m mentioned this pull request Jan 21, 2022
15 tasks
@ju1m
Copy link
Contributor Author

ju1m commented Jan 21, 2022

@lunik1, it has, my mistake, I've proposed a fix there: #156004

@yu-re-ka
Copy link
Contributor

#158945

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

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 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 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants