From patchwork Thu Apr 28 04:57:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Po-Hsu Lin X-Patchwork-Id: 1623414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=mIwPPrNC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kpk0Y6LZNz9s0B for ; Thu, 28 Apr 2022 14:58:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1njwEQ-0006kO-NX; Thu, 28 Apr 2022 04:58:22 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1njwEN-0006kH-AO for kernel-team@lists.ubuntu.com; Thu, 28 Apr 2022 04:58:19 +0000 Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B9EF23F6F3 for ; Thu, 28 Apr 2022 04:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1651121898; bh=02BFCEoxjQJ2j6tuC8TvFkh1EfNN/VpyLj9Yp6cWRTc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mIwPPrNCwknZf33CgW0gsgRvbwZs7KpAXc8wJ7f0ylNH+RN4j8MNqvHhlw1eNw+8g EQtwbFVsYsClLZs0TUx/pwZTpXLOUtfbnbUe9A3kKkrvDUOLlrfq3KOJt2oMJeDBj5 AEZ7LU/P3uajPYiljbIcUk9kauamsjfzW1r6ksCStknuPnRrUb8NallIiGOqVcZnaA lfk6eLAH1UGKlbr0/5ezkQZSqbQGvkOdWd1c2pULOpoQKIFoI4y0dXdOwV8nDQTYek bMnocv95JjW6WkTB3+x0WqkNTO2I3Ta3R6p4k/hT0UU1eQI0RQeMWb8j2D11wbBx9o 3KPOVP/XOyteA== Received: by mail-pf1-f197.google.com with SMTP id b184-20020a62cfc1000000b0050d209cb8dcso2171641pfg.3 for ; Wed, 27 Apr 2022 21:58:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=02BFCEoxjQJ2j6tuC8TvFkh1EfNN/VpyLj9Yp6cWRTc=; b=dV+2x/CFvxuA+PTni2doF8AuvKNlwvp6DbbdHIMYdY3GXZzGfbnvgmSeO+LBo4Y0j+ mPqjoefUtxIJA5EKYciLEYc3aHeaZ4V00vpPl2nmjUKHsTONj06+JQyzLj7mP69fheXK Alv/ARmsGNCzerd5wvFmH1RiKbstgIM9s3Hwgtln7p362UymYHguRxourhRv2wuqRC0X vsBubXrNFGv2O4E2Gzcy2sQ+W6KTrJlrGRXvtnTsX7D636pX6jswwBoVTtFNlByfmFVu 2A3sx+SBbcVmC8GE9wXGZ5qgSoGoXoz8GNJZV6E8l1PVtB0OLgjflGD8TTD1yN8gbt4+ AQHQ== X-Gm-Message-State: AOAM530mUQROQAq8kI5C+e598gNdQDrwzOEAUquoyXLyE/66k0PFz2jh TTy9InIKuD0v7lUWCLT0ay94dBz/eoeTCo+20n6k3qEMFfXJbRZi46LGUx+tuonSXHg7HlU8ASZ Dg4t9rLyBWJN26PvFJRiUARXDBKmlDxSTw/TYSod4 X-Received: by 2002:a63:1117:0:b0:399:2df0:7fb9 with SMTP id g23-20020a631117000000b003992df07fb9mr27411067pgl.40.1651121897000; Wed, 27 Apr 2022 21:58:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyYY+jS8AfEG2S+5JmDUYzvibvv1lNPbhRyFal4qmyxleWMQNfD0mDIn0/U5ZP1zyFgis+dg== X-Received: by 2002:a63:1117:0:b0:399:2df0:7fb9 with SMTP id g23-20020a631117000000b003992df07fb9mr27411045pgl.40.1651121896557; Wed, 27 Apr 2022 21:58:16 -0700 (PDT) Received: from localhost.localdomain (114-136-168-136.emome-ip.hinet.net. [114.136.168.136]) by smtp.gmail.com with ESMTPSA id h12-20020a63210c000000b003c14af5063csm1027681pgh.84.2022.04.27.21.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 21:58:15 -0700 (PDT) From: Po-Hsu Lin To: kernel-team@lists.ubuntu.com Subject: [autotest-client-tests][PATCH] UBUNTU: SAUCE: Don't cleanup ZFS on system with ZFS filesystem in use Date: Thu, 28 Apr 2022 12:57:59 +0800 Message-Id: <20220428045759.320046-1-po-hsu.lin@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1970600/ The post-test-zfs-cleanup add for zfs-related tests will break system that runs on ZFS. Check if the SUT is using it with "df -t zfs" before trying to do the cleanup. Patch tested on s390x LPAR with ubuntu_zfs_smoke_test test (not a zfs-based system though). Fixes: 4c9ac393e457 ("UBUNTU: SAUCE: Remove zfs-related packages after test") Signed-off-by: Po-Hsu Lin Acked-by: Dimitri John Ledkov --- .../ubuntu_performance_fio.py | 22 ++++++++++++------- .../ubuntu_performance_zfs_encryption.py | 21 ++++++++++++------ ubuntu_zfs/ubuntu_zfs.py | 20 +++++++++++------ ubuntu_zfs_fstest/ubuntu_zfs_fstest.py | 21 ++++++++++++------ .../ubuntu_zfs_smoke_test.py | 21 ++++++++++++------ ubuntu_zfs_stress/ubuntu_zfs_stress.py | 21 ++++++++++++------ .../ubuntu_zfs_xfs_generic.py | 21 ++++++++++++------ 7 files changed, 97 insertions(+), 50 deletions(-) diff --git a/ubuntu_performance_fio/ubuntu_performance_fio.py b/ubuntu_performance_fio/ubuntu_performance_fio.py index 364f1b74..0efdcd4c 100644 --- a/ubuntu_performance_fio/ubuntu_performance_fio.py +++ b/ubuntu_performance_fio/ubuntu_performance_fio.py @@ -7,7 +7,7 @@ import re import subprocess import resource import shutil -from autotest.client import test, utils +from autotest.client import test, utils from autotest.client.shared import error TEST_FILESYSTEM = os.getenv('TEST_FILESYSTEM') @@ -409,13 +409,19 @@ class ubuntu_performance_fio(test.test): self.get_sysinfo() return elif test_name == 'post-test-zfs-cleanup': - utils.system('systemctl stop zed') - utils.system('modprobe -r zfs') - # No need to consider ubuntu-zfs package on P/T as they've been blacklisted - utils.system('apt-get remove --yes --force-yes zfsutils-linux') - # Remove .version for the test, in order to trigger setup() again if we want re-test it - cmd = 'rm {}/.version'.format(self.srcdir) - utils.system(cmd) + # Make sure there is no ZFS in use by any filesystem + try: + utils.system('df -t zfs &> /dev/null') # return 1 if not found + print("ZFS in use by filesystem, SKIP cleanup") + except error.CmdError: + print("Stop / unload / remove ZFS") + utils.system('systemctl stop zed') + utils.system('modprobe -r zfs') + # No need to consider ubuntu-zfs package on P/T as they've been blacklisted + utils.system('apt-get remove --yes --force-yes zfsutils-linux') + # Remove .version for the test, in order to trigger setup() again if we want re-test it + cmd = 'rm {}/.version'.format(self.srcdir) + utils.system(cmd) return # diff --git a/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py b/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py index 912543f2..15e52a4d 100644 --- a/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py +++ b/ubuntu_performance_zfs_encryption/ubuntu_performance_zfs_encryption.py @@ -1,6 +1,7 @@ # # from autotest.client import test, utils +from autotest.client.shared import error import platform class ubuntu_performance_zfs_encryption(test.test): @@ -39,13 +40,19 @@ class ubuntu_performance_zfs_encryption(test.test): if test_name == 'setup': return elif test_name == 'post-test-zfs-cleanup': - utils.system('systemctl stop zed') - utils.system('modprobe -r zfs') - # No need to consider ubuntu-zfs package on P/T as they've been blacklisted - utils.system('apt-get remove --yes --force-yes zfsutils-linux') - # Remove .version for the test, in order to trigger setup() again if we want re-test it - cmd = 'rm {}/.version'.format(self.srcdir) - utils.system(cmd) + # Make sure there is no ZFS in use by any filesystem + try: + utils.system('df -t zfs &> /dev/null') # return 1 if not found + print("ZFS in use by filesystem, SKIP cleanup") + except error.CmdError: + print("Stop / unload / remove ZFS") + utils.system('systemctl stop zed') + utils.system('modprobe -r zfs') + # No need to consider ubuntu-zfs package on P/T as they've been blacklisted + utils.system('apt-get remove --yes --force-yes zfsutils-linux') + # Remove .version for the test, in order to trigger setup() again if we want re-test it + cmd = 'rm {}/.version'.format(self.srcdir) + utils.system(cmd) return cmd = '%s/%s %s' % (self.bindir, test_name, self.srcdir) diff --git a/ubuntu_zfs/ubuntu_zfs.py b/ubuntu_zfs/ubuntu_zfs.py index f91bf4e2..c1d53b42 100644 --- a/ubuntu_zfs/ubuntu_zfs.py +++ b/ubuntu_zfs/ubuntu_zfs.py @@ -78,13 +78,19 @@ class ubuntu_zfs(test.test): if test_name == 'setup': return elif test_name == 'post-test-zfs-cleanup': - utils.system('systemctl stop zed') - utils.system('modprobe -r zfs') - # No need to consider ubuntu-zfs package on P/T as they've been blacklisted - utils.system('apt-get remove --yes --force-yes zfsutils-linux') - # Remove .version for the test, in order to trigger setup() again if we want re-test it - cmd = 'rm {}/.version'.format(self.srcdir) - utils.system(cmd) + # Make sure there is no ZFS in use by any filesystem + try: + utils.system('df -t zfs &> /dev/null') # return 1 if not found + print("ZFS in use by filesystem, SKIP cleanup") + except error.CmdError: + print("Stop / unload / remove ZFS") + utils.system('systemctl stop zed') + utils.system('modprobe -r zfs') + # No need to consider ubuntu-zfs package on P/T as they've been blacklisted + utils.system('apt-get remove --yes --force-yes zfsutils-linux') + # Remove .version for the test, in order to trigger setup() again if we want re-test it + cmd = 'rm {}/.version'.format(self.srcdir) + utils.system(cmd) return os.chdir(self.srcdir) diff --git a/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py b/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py index a557ed5b..8b793009 100644 --- a/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py +++ b/ubuntu_zfs_fstest/ubuntu_zfs_fstest.py @@ -4,6 +4,7 @@ import multiprocessing import os import platform from autotest.client import test, utils +from autotest.client.shared import error class ubuntu_zfs_fstest(test.test): version = 1 @@ -66,13 +67,19 @@ class ubuntu_zfs_fstest(test.test): if test_name == 'setup': return elif test_name == 'post-test-zfs-cleanup': - utils.system('systemctl stop zed') - utils.system('modprobe -r zfs') - # No need to consider ubuntu-zfs package on P/T as they've been blacklisted - utils.system('apt-get remove --yes --force-yes zfsutils-linux') - # Remove .version for the test, in order to trigger setup() again if we want re-test it - cmd = 'rm {}/.version'.format(self.srcdir) - utils.system(cmd) + # Make sure there is no ZFS in use by any filesystem + try: + utils.system('df -t zfs &> /dev/null') # return 1 if not found + print("ZFS in use by filesystem, SKIP cleanup") + except error.CmdError: + print("Stop / unload / remove ZFS") + utils.system('systemctl stop zed') + utils.system('modprobe -r zfs') + # No need to consider ubuntu-zfs package on P/T as they've been blacklisted + utils.system('apt-get remove --yes --force-yes zfsutils-linux') + # Remove .version for the test, in order to trigger setup() again if we want re-test it + cmd = 'rm {}/.version'.format(self.srcdir) + utils.system(cmd) return os.chdir(self.srcdir) diff --git a/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py b/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py index 6ad6b4c7..41276eca 100644 --- a/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py +++ b/ubuntu_zfs_smoke_test/ubuntu_zfs_smoke_test.py @@ -1,6 +1,7 @@ # # from autotest.client import test, utils +from autotest.client.shared import error import platform class ubuntu_zfs_smoke_test(test.test): @@ -39,13 +40,19 @@ class ubuntu_zfs_smoke_test(test.test): if test_name == 'setup': return elif test_name == 'post-test-zfs-cleanup': - utils.system('systemctl stop zed') - utils.system('modprobe -r zfs') - # No need to consider ubuntu-zfs package on P/T as they've been blacklisted - utils.system('apt-get remove --yes --force-yes zfsutils-linux') - # Remove .version for the test, in order to trigger setup() again if we want re-test it - cmd = 'rm {}/.version'.format(self.srcdir) - utils.system(cmd) + # Make sure there is no ZFS in use by any filesystem + try: + utils.system('df -t zfs &> /dev/null') # return 1 if not found + print("ZFS in use by filesystem, SKIP cleanup") + except error.CmdError: + print("Stop / unload / remove ZFS") + utils.system('systemctl stop zed') + utils.system('modprobe -r zfs') + # No need to consider ubuntu-zfs package on P/T as they've been blacklisted + utils.system('apt-get remove --yes --force-yes zfsutils-linux') + # Remove .version for the test, in order to trigger setup() again if we want re-test it + cmd = 'rm {}/.version'.format(self.srcdir) + utils.system(cmd) return cmd = '%s/%s %s' % (self.bindir, test_name, self.srcdir) diff --git a/ubuntu_zfs_stress/ubuntu_zfs_stress.py b/ubuntu_zfs_stress/ubuntu_zfs_stress.py index e2e68799..6103a27b 100644 --- a/ubuntu_zfs_stress/ubuntu_zfs_stress.py +++ b/ubuntu_zfs_stress/ubuntu_zfs_stress.py @@ -5,6 +5,7 @@ import os import platform import shutil from autotest.client import test, utils +from autotest.client.shared import error class ubuntu_zfs_stress(test.test): version = 1 @@ -64,13 +65,19 @@ class ubuntu_zfs_stress(test.test): def run_once(self, test_name): if test_name == 'post-test-zfs-cleanup': - utils.system('systemctl stop zed') - utils.system('modprobe -r zfs') - # No need to consider ubuntu-zfs package on P/T as they've been blacklisted - utils.system('apt-get remove --yes --force-yes zfsutils-linux') - # Remove .version for the test, in order to trigger setup() again if we want re-test it - cmd = 'rm {}/.version'.format(self.srcdir) - utils.system(cmd) + # Make sure there is no ZFS in use by any filesystem + try: + utils.system('df -t zfs &> /dev/null') # return 1 if not found + print("ZFS in use by filesystem, SKIP cleanup") + except error.CmdError: + print("Stop / unload / remove ZFS") + utils.system('systemctl stop zed') + utils.system('modprobe -r zfs') + # No need to consider ubuntu-zfs package on P/T as they've been blacklisted + utils.system('apt-get remove --yes --force-yes zfsutils-linux') + # Remove .version for the test, in order to trigger setup() again if we want re-test it + cmd = 'rm {}/.version'.format(self.srcdir) + utils.system(cmd) return stress_ng = os.path.join(self.srcdir, 'stress-ng', 'stress-ng') diff --git a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py index 11bae635..8fff91a3 100644 --- a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py +++ b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py @@ -5,6 +5,7 @@ import platform import shutil from autotest.client import test, utils from autotest.client import canonical +from autotest.client.shared import error class ubuntu_zfs_xfs_generic(test.test): version = 5 @@ -133,13 +134,19 @@ class ubuntu_zfs_xfs_generic(test.test): if test_name == 'setup': return elif test_name == 'post-test-zfs-cleanup': - utils.system('systemctl stop zed') - utils.system('modprobe -r zfs') - # No need to consider ubuntu-zfs package on P/T as they've been blacklisted - utils.system('apt-get remove --yes --force-yes zfsutils-linux') - # Remove .version for the test, in order to trigger setup() again if we want re-test it - cmd = 'rm {}/.version'.format(self.srcdir) - utils.system(cmd) + # Make sure there is no ZFS in use by any filesystem + try: + utils.system('df -t zfs &> /dev/null') # return 1 if not found + print("ZFS in use by filesystem, SKIP cleanup") + except error.CmdError: + print("Stop / unload / remove ZFS") + utils.system('systemctl stop zed') + utils.system('modprobe -r zfs') + # No need to consider ubuntu-zfs package on P/T as they've been blacklisted + utils.system('apt-get remove --yes --force-yes zfsutils-linux') + # Remove .version for the test, in order to trigger setup() again if we want re-test it + cmd = 'rm {}/.version'.format(self.srcdir) + utils.system(cmd) return os.chdir(os.path.join(self.srcdir, 'xfstests-bld', 'xfstests-dev'))