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

use /etc/zfs.conf for defaults for better use with systemd #3827

Closed
ggzengel opened this issue Sep 24, 2015 · 17 comments
Closed

use /etc/zfs.conf for defaults for better use with systemd #3827

ggzengel opened this issue Sep 24, 2015 · 17 comments
Labels
Type: Feature Feature request or new feature
Milestone

Comments

@ggzengel
Copy link
Contributor

zpool import and other commands should read defaults from config file to make systemd usage easier.

http://0pointer.de/blog/projects/on-etc-sysinit.html

Often, files in /etc/sysconfig are used to "fake" configuration files for daemons which do not support configuration files natively. This is done by glueing together command line arguments from these variable assignments that are then passed to the daemon. In general proper, native configuration files in these daemons are the much prettier solution however. Command line options like "-k", "-a" or "-f" are not self-explanatory and have a very cryptic syntax. Moreover the same switches in many daemons have (due to the limited vocabulary) often very much contradicting effects. (On one daemon -f might cause the daemon to daemonize, while on another one this option turns exactly this behaviour off.) Command lines generally cannot include sensible comments which most configuration files however can.

@behlendorf behlendorf added the Type: Feature Feature request or new feature label Sep 24, 2015
@behlendorf behlendorf added this to the 0.7.0 milestone Sep 24, 2015
@FransUrbo
Copy link
Contributor

We already have /etc/{default,sysconfig,conf.d}/zfs for this exact purpose. It's used by both the initramfs and SYSV init scripts. And, hopefully, with the dracut scripts as well (if my "Phase 3" PR gets accepted). It makes sense to make systemd read that file as well.

I just don't know a way to "source" environment settings from an external file in a systemd script/file..

@ggzengel
Copy link
Contributor Author

Like written in this blog I think it's better to have native config files:

  1. systemd can read environment files but there is nothing about sanity check.
  2. I don't like to think about which /dev/disk-by* is the right path on this special system or what should/can I unmount for service.

I know you like to make a lot of scripts but some basics should be inside zfs.

@FransUrbo
Copy link
Contributor

We don't want to create a second config file with the same information when we already have one that's just fine. And that file IS part of the basic layout of ZoL. That and the /etc/zfs/zfs-functions script which contain all support functions one could ever need (and then some :).

@ggzengel
Copy link
Contributor Author

But zfs import won't read it?

@FransUrbo
Copy link
Contributor

Yes it will. ALL SYSV init scripts, the initramfs scripts and, in my "Phase 3" PR (which I hope will be accepted), even the dracut stuff will use it.

Uniformity have been the primary reason why I've been pushing this so hard! Before behlendorf accepted the first SYSV PR, we had FIVE SYSV init scripts! None identical, but did basically the same thing. It was a huge mess to maintain! Having ALL systems using ZoL boot and start the exact same way isn't unreasonable to demand… Linux init scripts, be it SYSV or systemd all uses config files in one way or the other. I've just made sure that we have a common stable ground to stand on...

I don't consider it unreasonable that the systemd services use it to...

@FransUrbo
Copy link
Contributor

I think we need to draw the line somewhere.

I'm not even sure how many distributions that have/will have this problem. Ubuntu (and from what I can tell RedHat/Fedora) isn't distributing the SYSV scripts because it's deprecated, they're only using systemd nowadays.

Gentoo isn't distributing the systemd service files because they have refused to go the systemd route.

Source installs (or packages built from the ZoL source tree) probes the system it's built on and only builds and installs the relevant part. Either systemd services OR SYSV init scripts…

So from this list, I'm the only one distributing both at the same time in the same package… And if this holds true in the real world, then I would actually HATE to have ZoL having that link in it's repository...

@ggzengel
Copy link
Contributor Author

But I don't talk about boot scripts.

The way it works now:

  1. Your script is called
  2. Your read the config files
  3. You call zfs executable

The way it should work:

  1. Your script is called
  2. You call zfs executable
  3. These executable read the config file

@FransUrbo
Copy link
Contributor

Nah, that's not going to happen… it's way out of the scope of how a command line tool is used on Linux.

Feel free to push this (or come up with a PR that does it), but if not, don't count on anyone taking the time to do it...

@ggzengel
Copy link
Contributor Author

You don't have to go far. Begin with letter a and you will find /etc/adduser.conf. There are a lot of variables which will changes the command line behavior.

@FransUrbo
Copy link
Contributor

[celia.pts/6]$ which adduser
/usr/sbin/adduser
[celia.pts/6]$ file /usr/sbin/adduser
/usr/sbin/adduser: Perl script, ASCII text executable

Not a command, a script… I can't vouch for every single command, but I think you'll be hard pressed to find a command that have a config file like that. They probably exist, but they're in a minority. Adding support for that in ZoL is going to be a monumentous job!

@ggzengel
Copy link
Contributor Author

I don't say to do it now and for everything, but there should be a plan what to do in future or it won't never be better.
I think the changes which comes with systemd will make it more simple at the end.

@FransUrbo
Copy link
Contributor

If we're doing this to simply for systemd, I'm against it. As I've said several times, there are distributions that do NOT use it and don't WANT it.

We do not change our command to suite systemd (which is only a service starter, nothing more!), we make systemd work with commands that already exists.

@ggzengel
Copy link
Contributor Author

I want it more comfortable and flexible. So I like to put some things I often use into a config file.

@FransUrbo
Copy link
Contributor

It occurred to me that if you want zpool and zfs to "understand" the configuration we set in /etc/default/zfs, you could source it in /etc/bash.bashrc (which was it's intention).

That way, we don't have to change the ZoL utilities/commands. Granted, that only works for bash (and derivates), but maybe we could/should provide a similar file for csh and derivates? But then, we should probably provide a zfs-functions.csh as well, and I'm not sure anyone would have any interest in either doing that or maintaining it…

However, the only option that's really of any interest to the commands are ZPOOL_IMPORT_PATH (and possibly VERBOSE_MOUNT and DO_OVERLAY_MOUNTS, but there's no way, currently, to get the commands to understand those).

@FransUrbo
Copy link
Contributor

Trying to figure out a way for systemd to use the existing /etc/default/zfs config file, I came across http://fedoraproject.org/wiki/Packaging%3aSystemd#EnvironmentFiles_and_support_for_.2Fetc.2Fsysconfig_files.

How that would help, I don't really know. The only variable we could have the use for is ZPOOL_IMPORT_PATH. I'll see if I can setup a PR for that.

@FransUrbo
Copy link
Contributor

Turns out there's actually quite a few variables we could use from the defaults file. Have a look at #3884. Untested though!

@behlendorf behlendorf modified the milestones: 0.8.0, 0.7.0 Oct 11, 2016
@behlendorf
Copy link
Contributor

Closing, systemd customization has been left to the individual distributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Feature request or new feature
Projects
None yet
Development

No branches or pull requests

3 participants