From 137d6a674c71b0fd57406f22b20f83fdf9224e7d Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Thu, 27 Feb 2025 16:05:05 +0800 Subject: [PATCH] fix(host): shared lvm activte with auto activation option (#22189) --- pkg/hostman/storageman/lvmutils/lvmutils.go | 5 ++++- pkg/hostman/storageman/storage_slvm.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/hostman/storageman/lvmutils/lvmutils.go b/pkg/hostman/storageman/lvmutils/lvmutils.go index b918e142b7..8287c8dce0 100644 --- a/pkg/hostman/storageman/lvmutils/lvmutils.go +++ b/pkg/hostman/storageman/lvmutils/lvmutils.go @@ -280,11 +280,14 @@ func VgDisplay(vgName string) error { return nil } -func VgActive(vgName string, active bool) error { +func VgActive(vgName string, active, autoActivation bool) error { opts := "-ay" if !active { opts = "-an" } + if active && autoActivation { + opts = "-aay" + } out, err := procutils.NewRemoteCommandAsFarAsPossible("lvm", "vgchange", opts, vgName).Output() if err != nil { return errors.Wrapf(err, "vgchange %s %s failed %s", opts, vgName, out) diff --git a/pkg/hostman/storageman/storage_slvm.go b/pkg/hostman/storageman/storage_slvm.go index f36ff2e7ba..8ddcf38dee 100644 --- a/pkg/hostman/storageman/storage_slvm.go +++ b/pkg/hostman/storageman/storage_slvm.go @@ -152,7 +152,7 @@ func (s *SSLVMStorage) DeleteSnapshot(ctx context.Context, params interface{}) ( } func (s *SSLVMStorage) Accessible() error { - if err := lvmutils.VgActive(s.Path, true); err != nil { + if err := lvmutils.VgActive(s.Path, true, true); err != nil { log.Warningf("vgactive got %s", err) }