From db71d38a5e8f54014ad2dae400f80784d63a18d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 13 Aug 2020 10:03:49 +0200 Subject: [PATCH] ceph: use different command for lvm2 presence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Older versions of lvm do not implement "--help" but "help" only where new versions support both so let's use "help" so the check works for all the versions. Closes: https://github.com/rook/rook/issues/6057 Signed-off-by: Sébastien Han --- pkg/daemon/ceph/osd/daemon.go | 2 +- pkg/daemon/ceph/osd/nsenter_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/daemon/ceph/osd/daemon.go b/pkg/daemon/ceph/osd/daemon.go index 4dc64ff29..a1d3d163e 100644 --- a/pkg/daemon/ceph/osd/daemon.go +++ b/pkg/daemon/ceph/osd/daemon.go @@ -173,7 +173,7 @@ func Provision(context *clusterd.Context, agent *OsdAgent, crushLocation string) // Check for the presence of LVM on the host when NOT running on PVC // since this scenario is still using LVM if !agent.pvcBacked { - ne := NewNsenter(context, lvmCommandToCheck, []string{"--help"}) + ne := NewNsenter(context, lvmCommandToCheck, []string{"help"}) err := ne.checkIfBinaryExistsOnHost() if err != nil { return errors.Wrapf(err, "binary %q does not exist on the host, make sure lvm2 package is installed", lvmCommandToCheck) diff --git a/pkg/daemon/ceph/osd/nsenter_test.go b/pkg/daemon/ceph/osd/nsenter_test.go index c84808174..f6c70cf55 100644 --- a/pkg/daemon/ceph/osd/nsenter_test.go +++ b/pkg/daemon/ceph/osd/nsenter_test.go @@ -27,9 +27,9 @@ import ( ) func TestBuildNsEnterCLI(t *testing.T) { - ne := NewNsenter(&clusterd.Context{}, lvmCommandToCheck, []string{"--help"}) + ne := NewNsenter(&clusterd.Context{}, lvmCommandToCheck, []string{"help"}) args := ne.buildNsEnterCLI(filepath.Join("/sbin/", ne.binary)) - expectedCLI := []string{"--mount=/rootfs/proc/1/ns/mnt", "--", "/sbin/lvm", "--help"} + expectedCLI := []string{"--mount=/rootfs/proc/1/ns/mnt", "--", "/sbin/lvm", "help"} assert.Equal(t, expectedCLI, args) } @@ -38,7 +38,7 @@ func TestCheckIfBinaryExistsOnHost(t *testing.T) { executor := &exectest.MockExecutor{} executor.MockExecuteCommandWithCombinedOutput = func(command string, args ...string) (string, error) { logger.Infof("%s %v", command, args) - if command == "nsenter" && args[0] == "--mount=/rootfs/proc/1/ns/mnt" && args[1] == "--" && args[3] == "--help" { + if command == "nsenter" && args[0] == "--mount=/rootfs/proc/1/ns/mnt" && args[1] == "--" && args[3] == "help" { if args[2] == "/usr/sbin/lvm" || args[2] == "/sbin/lvm" { return "success", nil } @@ -48,7 +48,7 @@ func TestCheckIfBinaryExistsOnHost(t *testing.T) { } context := &clusterd.Context{Executor: executor} - ne := NewNsenter(context, lvmCommandToCheck, []string{"--help"}) + ne := NewNsenter(context, lvmCommandToCheck, []string{"help"}) err := ne.checkIfBinaryExistsOnHost() assert.NoError(t, err) }