And disable it when destroying the pool.

Signed-off-by: Maximiliano Sandoval <m.sando...@proxmox.com>
---

Differences from v1:
 - Add --now flag to commands so they are `started` on top of `enabled`.


 src/PVE/API2/Disks/ZFS.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/PVE/API2/Disks/ZFS.pm b/src/PVE/API2/Disks/ZFS.pm
index 6fb6bd6b..6d9ace5b 100644
--- a/src/PVE/API2/Disks/ZFS.pm
+++ b/src/PVE/API2/Disks/ZFS.pm
@@ -490,6 +490,13 @@ __PACKAGE__->register_method ({
                run_command($cmd);
            }
 
+           if (-e '/lib/systemd/system/zfs-scrub-monthly@.timer') {
+               my $scrubtimer = 'zfs-scrub-monthly@'. 
PVE::Systemd::escape_unit($name, undef) . '.timer';
+               $cmd = ['systemctl', 'enable', $scrubtimer, '--now'];
+               print "# ", join(' ', @$cmd), "\n";
+               run_command($cmd);
+           }
+
            PVE::Diskmanage::udevadm_trigger($devs->@*);
 
            if ($param->{add_storage}) {
@@ -583,6 +590,11 @@ __PACKAGE__->register_method ({
                    run_command(['systemctl', 'disable', $importunit]);
                }
 
+               if (-e '/lib/systemd/system/zfs-scrub-monthly@.timer') {
+                   my $scrubtimer = 'zfs-scrub-monthly@' . 
PVE::Systemd::escape_unit($name) . '.timer';
+                   run_command(['systemctl', 'disable', $scrubtimer, '--now']);
+               }
+
                run_command(['zpool', 'destroy', $name]);
 
                my $config_err;
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to