Skip to content

Commit

Permalink
services: add GlusterFS service
Browse files Browse the repository at this point in the history
This service is only limited in configuration options.
But it is sufficient to run glusterd and configure it using the gluster command
  • Loading branch information
bachp committed Feb 2, 2017
1 parent a5a4b13 commit 19759cf
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Expand Up @@ -339,6 +339,7 @@
./services/monitoring/zabbix-server.nix
./services/network-filesystems/cachefilesd.nix
./services/network-filesystems/drbd.nix
./services/network-filesystems/glusterfs.nix
./services/network-filesystems/ipfs.nix
./services/network-filesystems/netatalk.nix
./services/network-filesystems/nfsd.nix
Expand Down
84 changes: 84 additions & 0 deletions nixos/modules/services/network-filesystems/glusterfs.nix
@@ -0,0 +1,84 @@
{ config, lib, pkgs, ... }:

with lib;

let
inherit (pkgs) glusterfs;

cfg = config.services.glusterfs;

in

{

###### interface

options = {

services.glusterfs = {

enable = mkEnableOption "GlusterFS Daemon";

logLevel = mkOption {
type = types.enum ["DEBUG" "INFO" "WARNING" "ERROR" "CRITICAL" "TRACE" "NONE"];
description = "Log level used by the GlusterFS daemon";
default = "INFO";
};

extraFlags = mkOption {
type = types.listOf types.str;
description = "Extra flags passed to the GlusterFS daemon";
default = [];
};
};
};

###### implementation

config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.glusterfs ];

services.rpcbind.enable = true;

systemd.services.glusterd = {

description = "GlusterFS, a clustered file-system server";

wantedBy = [ "multi-user.target" ];

requires = [ "rpcbind.service" ];
after = [ "rpcbind.service" "network.target" "local-fs.target" ];
before = [ "network-online.target" ];

This comment has been minimized.

Copy link
@nh2

nh2 May 6, 2017

Contributor

@bachp Why is this in before? According to the systemd docs for network-online.target:

Units that strictly require a configured network connection should pull in network-online.target

and even more:

All mount units for remote network file systems automatically pull in this unit, and order themselves after it.

According to this, if anything it should be in after, shouldn't it? You need the network to be online before glusterd will work, but you don't need glusterd to be running for your network connection to work.

I'm asking because this introduces a cycle in something I'm trying to configure: My task (say setupGlusterConfig must run before glusterd but after the network is online.

This comment has been minimized.

Copy link
@bachp

bachp May 7, 2017

Author Member

@nh2 That's a good point. I mostly took the systemd unif from the upstream one. I first need to dig into the whole system network stuff again.

But I assume the quote

All mount units for remote network file systems automatically pull in this unit, and order themselves after it.

is for the client side of network mounts not for the server side. They should come up before network-online.server so that the client side has them available. But that's just my understanding from the top of my head.

This comment has been minimized.

Copy link
@nh2

nh2 May 8, 2017

Contributor

I mostly took the systemd unit from the upstream one.

That makes a lot of sense then. I'll try to find out with upstream glusterfs what their motivations were -- that might tell us more.


preStart = ''
install -m 0755 -d /var/log/glusterfs
'';

serviceConfig = {
Type="forking";
PIDFile="/run/glusterd.pid";
LimitNOFILE=65536;
ExecStart="${glusterfs}/sbin/glusterd -p /run/glusterd.pid --log-level=${cfg.logLevel} ${toString cfg.extraFlags}";
KillMode="process";

This comment has been minimized.

Copy link
@nh2

nh2 May 15, 2017

Contributor

@bachp We may want to divert from the upstream systemd config here.

With process, sub-processes that glusterd spawns, such as geo-replication gsyncd, are not shut down on systemct stop or even systemctl kill, which means that e.g. a nixops deploy leaves old configurations running.

This comment has been minimized.

Copy link
@bachp

bachp May 15, 2017

Author Member

I'm open to improvements here. If we make it work better for NixOS then there is no need to stick to the upstream version.

};
};

systemd.services.glustereventsd = {

description = "Gluster Events Notifier";

wantedBy = [ "multi-user.target" ];

after = [ "syslog.target" "network.target" ];

serviceConfig = {
Type="simple";
Environment="PYTHONPATH=${glusterfs}/usr/lib/python2.7/site-packages";
PIDFile="/run/glustereventsd.pid";
ExecStart="${glusterfs}/sbin/glustereventsd --pid-file /run/glustereventsd.pid";
ExecReload="/bin/kill -SIGUSR2 $MAINPID";
KillMode="control-group";
};
};
};
}

0 comments on commit 19759cf

Please sign in to comment.