diff --git a/cmd/zfs_object_agent/scripts/Makefile.am b/cmd/zfs_object_agent/scripts/Makefile.am index 2064484cc15f..00c938ef73e3 100644 --- a/cmd/zfs_object_agent/scripts/Makefile.am +++ b/cmd/zfs_object_agent/scripts/Makefile.am @@ -1 +1,3 @@ -dist_bin_SCRIPTS = zoa_chaos_monkey +dist_bin_SCRIPTS = \ + zoa_chaos_monkey \ + start_zoa diff --git a/cmd/zfs_object_agent/scripts/start_zoa b/cmd/zfs_object_agent/scripts/start_zoa new file mode 100755 index 000000000000..e8a32f804b8c --- /dev/null +++ b/cmd/zfs_object_agent/scripts/start_zoa @@ -0,0 +1,46 @@ +#!/bin/sh + +# +# This script starts the ZFS Object Agent process. +# It uses the following environment variables, typically set by zfs-object-agent.service +# to determine which command line parameters to pass to the ZFS Object Agent process. +# - ZOA_LOG: File to log output to +# - ZOA_CONFIG: Configuration file to set tunables (toml/json/yaml" +# - ZETTACACHE_DEVICE: File/device to use for ZettaCache +# - ZOA_LOG_LEVEL : Sets the level of logging verbosity. +# Values can be TRACE, DEBUG, INFO, WARN. +# + +error() { + echo "$@" 1>&2 +} + +ZOA_LOG="${ZOA_LOG:-/var/log/zoa.log}" +PARAMS="-o ${ZOA_LOG}" +echo "Logging to: ${ZOA_LOG}" + +if [ ! -z $ZOA_CONFIG ]; then + echo "Config file: ${ZOA_CONFIG}" + PARAMS="${PARAMS} -t ${ZOA_CONFIG}" +fi + +if [ ! -z $ZETTACACHE_DEVICE ]; then + echo "ZettaCache: ${ZETTACACHE_DEVICE}" + PARAMS="$PARAMS -c ${ZETTACACHE_DEVICE}" +fi + +if [ ! -z $ZOA_LOG_LEVEL ]; then + if [ $ZOA_LOG_LEVEL = 'WARN' ]; then + : # WARN is the default log level. + elif [ $ZOA_LOG_LEVEL = 'INFO' ]; then + PARAMS="${PARAMS} -v" + elif [ $ZOA_LOG_LEVEL = 'DEBUG' ]; then + PARAMS="${PARAMS} -vv" + elif [ $ZOA_LOG_LEVEL = 'TRACE' ]; then + PARAMS="${PARAMS} -vvv" + else + error "Invalid log level setting: $ZOA_LOG_LEVEL; ignoring." + fi +fi + +/sbin/zfs_object_agent ${PARAMS} diff --git a/debian/zfsutils-linux.install b/debian/zfsutils-linux.install index 40defba188fc..1a505da8d083 100644 --- a/debian/zfsutils-linux.install +++ b/debian/zfsutils-linux.install @@ -17,6 +17,8 @@ lib/udev/ debian/tmp/etc/default/zfs etc/default/ debian/tmp/etc/zfs/zfs-functions etc/zfs/ etc/zfs/zpool.d/ +debian/tmp/etc/zfs/zoa_config.toml etc/zfs/ +debian/tmp/etc/zfs/zoa.conf etc/zfs/ usr/lib/*/zfs/zpool.d/ usr/lib/*/zfs/zpool_influxdb sbin/fsck.zfs @@ -38,6 +40,7 @@ sbin/zoa_test cmd/zfs_object_agent/libzoa.so lib/ usr/bin/zvol_wait usr/bin/zoa_chaos_monkey +usr/bin/start_zoa usr/sbin/arc_summary usr/sbin/arcstat usr/sbin/dbufstat diff --git a/etc/systemd/system/zfs-object-agent.service.in b/etc/systemd/system/zfs-object-agent.service.in index 2be6b32866dc..723165dc3b7c 100644 --- a/etc/systemd/system/zfs-object-agent.service.in +++ b/etc/systemd/system/zfs-object-agent.service.in @@ -8,7 +8,8 @@ Before=zfs-import-cache.service Environment="RUST_BACKTRACE=1" Environment="AWS_SECRET_ACCESS_KEY=" Environment="AWS_ACCESS_KEY_ID=" -ExecStart=/sbin/zfs_object_agent -vv +EnvironmentFile=-/etc/zfs/zoa.conf +ExecStart=/usr/bin/start_zoa Restart=always [Install] diff --git a/etc/zfs/Makefile.am b/etc/zfs/Makefile.am index 3dee81c75860..4ebc0a9be65e 100644 --- a/etc/zfs/Makefile.am +++ b/etc/zfs/Makefile.am @@ -8,7 +8,9 @@ dist_pkgsysconf_DATA = \ vdev_id.conf.sas_direct.example \ vdev_id.conf.sas_switch.example \ vdev_id.conf.multipath.example \ - vdev_id.conf.scsi.example + vdev_id.conf.scsi.example \ + zoa.conf \ + zoa_config.toml pkgsysconf_SCRIPTS = \ zfs-functions diff --git a/etc/zfs/zoa.conf b/etc/zfs/zoa.conf new file mode 100644 index 000000000000..fcf770837072 --- /dev/null +++ b/etc/zfs/zoa.conf @@ -0,0 +1,4 @@ +ZOA_LOG=/var/log/zoa.log +ZOA_LOG_LEVEL=DEBUG +ZOA_CONFIG=/etc/zfs/zoa_config.toml +ZETTACACHE_DEVICE= diff --git a/etc/zfs/zoa_config.toml b/etc/zfs/zoa_config.toml new file mode 100644 index 000000000000..94b5ea413286 --- /dev/null +++ b/etc/zfs/zoa_config.toml @@ -0,0 +1,4 @@ +# +# This config file overrides default values for tunable parameters in +# the ZFS Object Agent. +# diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in index 1b63780412a2..d9d1d78e4f5c 100644 --- a/rpm/generic/zfs.spec.in +++ b/rpm/generic/zfs.spec.in @@ -478,6 +478,7 @@ systemctl --system daemon-reload >/dev/null || true %{_bindir}/zvol_wait # Optional zfs_object_agent script %{_bindir}/zoa_chaos_monkey +%{_bindir}/start_zoa # Optional Python 2/3 scripts %{_bindir}/arc_summary %{_bindir}/arcstat @@ -512,6 +513,8 @@ systemctl --system daemon-reload >/dev/null || true %endif %config(noreplace) %{_sysconfdir}/%{name}/zed.d/* %config(noreplace) %{_sysconfdir}/%{name}/zpool.d/* +%config(noreplace) %{_sysconfdir}/%{name}/zoa_config.toml +%config(noreplace) %{_sysconfdir}/%{name}/zoa.conf %config(noreplace) %{_sysconfdir}/%{name}/vdev_id.conf.*.example %attr(440, root, root) %config(noreplace) %{_sysconfdir}/sudoers.d/* %if %{with pam}