From 162dd766ffdeb5ec4f6ec7d26c47160c6b494a66 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Thu, 3 Jun 2021 19:31:52 +0800 Subject: [PATCH] fix: hpssacli should skip empty slots hpssacli may fail when detect disks on empty slots, which cause raid detection failure --- pkg/baremetal/utils/raid/hpssactl/hpssactl.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/baremetal/utils/raid/hpssactl/hpssactl.go b/pkg/baremetal/utils/raid/hpssactl/hpssactl.go index f8dad8733c..f50c495a5d 100644 --- a/pkg/baremetal/utils/raid/hpssactl/hpssactl.go +++ b/pkg/baremetal/utils/raid/hpssactl/hpssactl.go @@ -20,9 +20,8 @@ import ( "strconv" "strings" - "github.com/pkg/errors" - "yunion.io/x/log" + "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/pkg/utils" @@ -382,11 +381,18 @@ func (r *HPSARaid) parsePhyDevs(lines []string) error { r.adapters = append(r.adapters, adapter) } } + var errs []error for _, a := range r.adapters { - if err := a.ParsePhyDevs(); err != nil { - return err + err := a.ParsePhyDevs() + if err != nil { + log.Errorf("parse adapter %d fail: %s", a.GetIndex(), err) + errs = append(errs, err) } } + if len(errs) == len(r.adapters) { + // all failed + return errors.NewAggregate(errs) + } return nil }