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

WIP: Refactor systemd and use /etc/default/zfs if available #3884

Closed
wants to merge 4 commits into from

Conversation

FransUrbo
Copy link
Contributor

Rearrangement of some source directories.

  • Move the systemd files into the contrib directory. This isn't really part of the ZFS/ZoL code, so it's more appropriate to put it in the contrib directory.

Use the /etc/{default,sysconfig}/zfs file in systemd service files (1of3).

  • Instead of looing for the hardcoded @sysconfdir@/zfs/zpool.cache file, use the $ZFS_CACHE if/when set.
  • Instead of using hardcoded /dev/disk/by-id dir in import, use the ZPOOL_IMPORT_PATH if/when set.
  • Use ZPOOL_IMPORT_OPTS if/when applicable.

Use the /etc/{default,sysconfig}/zfs file in systemd service files (2of3).

  • Use VERBOSE_MOUNT, DO_OVERLAY_MOUNTS and/or MOUNT_EXTRA_OPTIONS to zfs mount if/when applicable.

Use the /etc/{default,sysconfig}/zfs file in systemd service files (3of3).

  • Use the ZED_ARGS variable when starting zed if/when applicable.

This whole PR is untested, so I'm tagging this WIP.

@FransUrbo
Copy link
Contributor Author

The first commit isn't really necessary, but I've been increasingly ... "annoyed" that there's stuff that isn't really part of ZoL in the tree. I think it makes more sense to have all that in the contrib directory (which we created it for). So this PR includes a move of the systemd directory into contrib/.

@FransUrbo FransUrbo force-pushed the refactor-systemd branch 2 times, most recently from 20760c3 to 79aeba3 Compare October 4, 2015 13:44
@FransUrbo FransUrbo changed the title Refactor systemd Refactor systemd and use /etc/default/zfs if available Oct 4, 2015
@FransUrbo FransUrbo changed the title Refactor systemd and use /etc/default/zfs if available WIP: Refactor systemd and use /etc/default/zfs if available Oct 4, 2015
@FransUrbo
Copy link
Contributor Author

@behlendorf Do we have an (approximate) ETA on this?

Tag this 0.7.0?

@@ -63,8 +63,6 @@ AC_CONFIG_FILES([
etc/Makefile
etc/init.d/Makefile
etc/zfs/Makefile
etc/systemd/Makefile
etc/systemd/system/Makefile
Copy link
Contributor

@behlendorf behlendorf May 26, 2016

Choose a reason for hiding this comment

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

I don't think this belongs in contrib. This is code we support and maintain as part of the project so I'd like to leave where it is.

@behlendorf behlendorf added this to the 0.7.0 milestone May 26, 2016
@@ -12,4 +12,5 @@ Before=local-fs.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=@sbindir@/zfs mount -a
ExecStart=@sbindir@/zfs mount -a ${VERBOSE_MOUNT:+-v} ${DO_OVERLAY_MOUNTS:+-O} ${MOUNT_EXTRA_OPTIONS}
Copy link
Contributor

Choose a reason for hiding this comment

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

My only concern with this is that VERBOSE_MOUNT="no" and DO_OVERLAY_MOUNT="no". That means both these options will be enabled when they should be disabled. How about limiting this to just MOUNT_EXTRA_OPTIONS which will work correctly.

@behlendorf
Copy link
Contributor

@FransUrbo sorry about completely neglecting this. The gist of these changes look entirely reasonable to me. If you can address the issues I mentioned and rebase this against master without the "Rearrangement of some source directories" patch I don't see why we can't get it tested and added as part of the other proposed systemd changes.

@FransUrbo
Copy link
Contributor Author

@FransUrbo sorry about completely neglecting this.

That's ok I guess, I've grown used to it :)
If you can address the issues I mentioned and rebase this against master without the "Rearrangement of some source directories" patch I don't see why we can't get it tested and added as part of the other proposed systemd changes.

In my opinion, everything that isn't part of the core ZFS code, should
go into contrib. It's technically the work of the downstream maintainers
to deal with this, not us.

But since there haven't been any, it made sense for us to do it. And
we can keep doing it for everyone that prefer to install from source.

But I think contrib is correct in this case. However, we can leave that
discussion to later if you're adamant about this.

@behlendorf
Copy link
Contributor

Let's leave the contrib argument for latter and move forward on the rest of these changes. :)

@FransUrbo
Copy link
Contributor Author

@behlendorf Ok, I've updated the PR with your remarks fixed. I updated the comments to, maybe you should merge them into one commit when/if accepting it.

@FransUrbo
Copy link
Contributor Author

Looking at this and your #4699 again, I think it's possible to merge the two import files into one and just update the documentation for /etc/{sysconfig,default}/zfs to indicate that one could use the ZPOOL_IMPORT_OPTS with systemd to choose between importing with cache or scan.


[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-@initconfdir@/zfs
ExecStartPre=/sbin/modprobe zfs
ExecStart=@sbindir@/zpool import ${ZPOOL_CACHE:+-c "${ZPOOL_CACHE}"} -aN ${ZPOOL_IMPORT_OPTS}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure we can write the one line equivalence of

Pseudo code:

if cache exists; then
use cache file
else if ZPOOL_IMPORT_PATH is set; then
use ZPOOL_IMPORT_PATH
fi

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave these two files separate for now. That allows for each to enabled/disabled independently.

FransUrbo added 4 commits May 26, 2016 21:30
Use the /etc/{default,sysconfig}/zfs file in systemd service files.

* Instead of looing for the hardcoded @sysconfdir@/zfs/zpool.cache
  file, use the $ZPOOL_CACHE if/when set.
* Instead of using hardcoded /dev/disk/by-id dir in import, use
  the ZPOOL_IMPORT_PATH if/when set.
* Use ZPOOL_IMPORT_OPTS if/when applicable.

Signed-off-by: Turbo Fredriksson <[email protected]>
Use the /etc/{default,sysconfig}/zfs file in systemd service files.

* Use MOUNT_EXTRA_OPTIONS from mentioned file if/when applicable.

Signed-off-by: Turbo Fredriksson <[email protected]>
Use the /etc/{default,sysconfig}/zfs file in systemd service files.

* Use the ZED_ARGS variable when starting zed if/when applicable.

Signed-off-by: Turbo Fredriksson <[email protected]>
* Add 'Documentation' entry for those service files that don't have any.
@behlendorf
Copy link
Contributor

When testing this under CentOS 7 I ran in to numerous problems.

  • The environment variable substitutions aren't working, this may be because systemd does its own parsing of the unit files so normal shell syntax isn't supported.
  • initconfdir replacement isn't defined and needs to be added to the Makefile.am: -e 's,@initconfdir\@,$(DEFAULT_INITCONF_DIR),g'.
  • Variables appear not to be allowed in ConditionPathExists.

Adding this kind of support I think is a good idea but it needs more testing.

@behlendorf
Copy link
Contributor

Closing. While I think this is a good idea the proposed patches just don't work. I ran in to numerous problems as described in the comment above. If someone would like to add this functionality they should open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants