git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #29868 from nh2/nh2-glusterfs-improvements-for-17.09-master

glusterfs service: a few fixes and improvements

commit74db6fabcbae46a4c79cd4025ebac2032679db1c authorJoachim F <joachifm@users.noreply.github.com> dateSat 30 Sep 2017, 12:19 (9 years ago) parentb5d11a718eecae
1 file changed+61−6
nixos/modules/services/network-filesystems/glusterfs.nix+61−6
nixos/modules/services/network-filesystems/glusterfs.nix+61−6
@@ -41,6 +41,57 @@ in
4141 default = "INFO";
4242 };
4343
44+ useRpcbind = mkOption {
45+ type = types.bool;
46+ description = ''
47+ Enable use of rpcbind. This is required for Gluster's NFS functionality.
48+
49+ You may want to turn it off to reduce the attack surface for DDoS reflection attacks.
50+
51+ See https://davelozier.com/glusterfs-and-rpcbind-portmap-ddos-reflection-attacks/
52+ and https://bugzilla.redhat.com/show_bug.cgi?id=1426842 for details.
53+ '';
54+ default = true;
55+ };
56+
57+ enableGlustereventsd = mkOption {
58+ type = types.bool;
59+ description = "Whether to enable the GlusterFS Events Daemon";
60+ default = true;
61+ };
62+
63+ killMode = mkOption {
64+ type = types.enum ["control-group" "process" "mixed" "none"];
65+ description = ''
66+ The systemd KillMode to use for glusterd.
67+
68+ glusterd spawns other daemons like gsyncd.
69+ If you want these to stop when glusterd is stopped (e.g. to ensure
70+ that NixOS config changes are reflected even for these sub-daemons),
71+ set this to 'control-group'.
72+ If however you want running volume processes (glusterfsd) and thus
73+ gluster mounts not be interrupted when glusterd is restarted
74+ (for example, when you want to restart them manually at a later time),
75+ set this to 'process'.
76+ '';
77+ default = "control-group";
78+ };
79+
80+ stopKillTimeout = mkOption {
81+ type = types.str;
82+ description = ''
83+ The systemd TimeoutStopSec to use.
84+
85+ After this time after having been asked to shut down, glusterd
86+ (and depending on the killMode setting also its child processes)
87+ are killed by systemd.
88+
89+ The default is set low because GlusterFS (as of 3.10) is known to
90+ not tell its children (like gsyncd) to terminate at all.
91+ '';
92+ default = "5s";
93+ };
94+
4495 extraFlags = mkOption {
4596 type = types.listOf types.str;
4697 description = "Extra flags passed to the GlusterFS daemon";
@@ -89,7 +140,7 @@ in
89140 config = mkIf cfg.enable {
90141 environment.systemPackages = [ pkgs.glusterfs ];
91142
92− services.rpcbind.enable = true;
143+ services.rpcbind.enable = cfg.useRpcbind;
93144
94145 environment.etc = mkIf (cfg.tlsSettings != null) {
95146 "ssl/glusterfs.pem".source = cfg.tlsSettings.tlsPem;
@@ -104,9 +155,8 @@ in
104155
105156 wantedBy = [ "multi-user.target" ];
106157
107− requires = [ "rpcbind.service" ];
108− after = [ "rpcbind.service" "network.target" "local-fs.target" ];
109− before = [ "network-online.target" ];
158+ requires = lib.optional cfg.useRpcbind "rpcbind.service";
159+ after = [ "network.target" "local-fs.target" ] ++ lib.optional cfg.useRpcbind [ "rpcbind.service" ];
110160
111161 preStart = ''
112162 install -m 0755 -d /var/log/glusterfs
@@ -130,11 +180,12 @@ in
130180 PIDFile="/run/glusterd.pid";
131181 LimitNOFILE=65536;
132182 ExecStart="${glusterfs}/sbin/glusterd -p /run/glusterd.pid --log-level=${cfg.logLevel} ${toString cfg.extraFlags}";
133− KillMode="process";
183+ KillMode=cfg.killMode;
184+ TimeoutStopSec=cfg.stopKillTimeout;
134185 };
135186 };
136187
137− systemd.services.glustereventsd = {
188+ systemd.services.glustereventsd = mkIf cfg.enableGlustereventsd {
138189 inherit restartTriggers;
139190
140191 description = "Gluster Events Notifier";
@@ -143,6 +194,10 @@ in
143194
144195 after = [ "syslog.target" "network.target" ];
145196
197+ preStart = ''
198+ install -m 0755 -d /var/log/glusterfs
199+ '';
200+
146201 serviceConfig = {
147202 Type="simple";
148203 Environment="PYTHONPATH=${glusterfs}/usr/lib/python2.7/site-packages";