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

ZFS: Adding ZED configuration options #64306

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@sjau
Copy link
Contributor

commented Jul 4, 2019

Motivation for this change

The ZFS Events Daemon (ZED) offer notifications upon zpool events like errors on scrubbing, failing disks and more (if desired). Enabling/altering those options in the configuration.nix helps to lessen the administrative tasks of regularly checking the status of the zpools.

Most of the options that are configurable in the '/etc/zfs/zed.d/zed.rc' file can be configured now through the configuration.nix. A few options, like changing the lock folder, were left alone as the use of those doesn't seem to be widespread.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nix-review --run "nix-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.

# matching subclasses are excluded from logging.
#ZED_SYSLOG_SUBCLASS_INCLUDE="checksum|scrub_*|vdev.*"
#ZED_SYSLOG_SUBCLASS_EXCLUDE="statechange|config_*|history_event"
''

This comment has been minimized.

Copy link
@Infinisil

Infinisil Jul 16, 2019

Member

I'd like to see this as a more general option as an abstraction, something like

{
  options.services.zfs.zed.settings = mkOption {
    type = with types; attrsOf (nullOr (either str (either int bool)));
    # ...
  };
}

, leaning towards NixOS/rfcs#42, then people can override these settings and add ones not supported by the module.

Then you can move these definitions into the config section of the module like this:

{
  services.zfs.zed.settings = {
    ZED_DEBUG_LOG = mkDefault cfgZED.debugLog;
    ZED_EMAIL_ADDR = mkDefault (concatStringsSep " " cfgZED.email.addresses);
    # ...
  };
}

And the config file gets generated only from this settings option (where null values mean that it won't get set, which simplifies things and makes sense).

email.program = mkOption {
type = types.nullOr types.str;
default = null;
example = "mail";

This comment has been minimized.

Copy link
@Infinisil

Infinisil Jul 16, 2019

Member

It might make sense to use pkgs.system-sendmail by default here.

Also need to make sure ZED can get access to these executables through PATH (if using a non-path executable). Should maybe be noted in the description or supported somehow.

Command-line options for the email program.
The string @ADDRESS@ will be replaced with the recipient email address(es).
The string @SUBJECT@ will be replaced with the notification subject;
this should be protected with quotes to prevent word-splitting.

This comment has been minimized.

Copy link
@Infinisil

Infinisil Jul 16, 2019

Member

With our types, we can use types.listOf types.str and then lib.escapeShellArgs to generate the arguments to not have to worry about escaping.

description = ''
Pushbullet access token.
This grants full access to your account -- protect it accordingly!
<https://www.pushbullet.com/get-started>

This comment has been minimized.

Copy link
@Infinisil

Infinisil Jul 16, 2019

Member

You need to use this syntax for links: <link xlink:href="https://example.com"/>

environment.etc."zfs/zed.d/statechange-notify.sh".source = "${packages.zfsUser}/etc/zfs/zed.d/statechange-notify.sh";
environment.etc."zfs/zed.d/vdev_attach-led.sh".source = "${packages.zfsUser}/etc/zfs/zed.d/vdev_attach-led.sh";
environment.etc."zfs/zed.d/vdev_clear-led.sh".source = "${packages.zfsUser}/etc/zfs/zed.d/vdev_clear-led.sh";
environment.etc."zfs/zed.d/zed-functions.sh".source = "${packages.zfsUser}/etc/zfs/zed.d/zed-functions.sh";

This comment has been minimized.

Copy link
@Infinisil

Infinisil Jul 16, 2019

Member

You can abstract this:

{
  environment.etc = genAttrs (map (file: "zfs/zed.d/${file}") [
    "all-syslog.sh"
    "data-notify.sh"
    # ... 
  ]) (file: { source = "${packages.zfsUser}/etc/${file}"; });
}
environment.etc."zfs/zed.d/zed-functions.sh".source = "${packages.zfsUser}/etc/zfs/zed.d/zed-functions.sh";
environment.etc."zfs/zed.d/zed.rc".text = ''
${zedConf}
'';

This comment has been minimized.

Copy link
@Infinisil

Infinisil Jul 16, 2019

Member

Can just do

{
  environment.etc."zfs/zed.d/zed.rc".text = zedConf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.