diff --git a/go.mod b/go.mod index 97a303d69..032c34dde 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/longhorn/go-common-libs v0.0.0-20240811024046-b6ddc3efb72e github.com/longhorn/go-spdk-helper v0.0.0-20240811121608-9383fa59dd7c github.com/longhorn/longhorn-engine v1.7.0-rc3 - github.com/longhorn/longhorn-spdk-engine v0.0.0-20240814084953-a36eff7350ad + github.com/longhorn/longhorn-spdk-engine v0.0.0-20240815033436-41791a2d0239 github.com/longhorn/types v0.0.0-20240725040629-473d671316c4 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 604122644..a8ce5888d 100644 --- a/go.sum +++ b/go.sum @@ -101,8 +101,8 @@ github.com/longhorn/go-spdk-helper v0.0.0-20240811121608-9383fa59dd7c h1:ztjrkxi github.com/longhorn/go-spdk-helper v0.0.0-20240811121608-9383fa59dd7c/go.mod h1:BrtXoVnIZ97+uZ+cMcaICc5KnuJkh8j3+G1NjKxh+8Q= github.com/longhorn/longhorn-engine v1.7.0-rc3 h1:YTt++OeSrEOlifz++8VAOH/aJ4lGShD2TaJP1ZaQ3Uw= github.com/longhorn/longhorn-engine v1.7.0-rc3/go.mod h1:2Hq/3QzW4fF2yUg+kauiAT3ps5WCKLMkrwXW2Wyfj9o= -github.com/longhorn/longhorn-spdk-engine v0.0.0-20240814084953-a36eff7350ad h1:eWFkNrHFE7qCHnn97BcTk/kZQtXuhL8wy3S32VX425o= -github.com/longhorn/longhorn-spdk-engine v0.0.0-20240814084953-a36eff7350ad/go.mod h1:4X7OQr01G10WSxq0ETEFxS/gQvgcE3YUEIU3MZujTcc= +github.com/longhorn/longhorn-spdk-engine v0.0.0-20240815033436-41791a2d0239 h1:1bHRQ6MYz4z3ul614ZGFjcT9EdeIUtUYKBi/Qjg5dHc= +github.com/longhorn/longhorn-spdk-engine v0.0.0-20240815033436-41791a2d0239/go.mod h1:4X7OQr01G10WSxq0ETEFxS/gQvgcE3YUEIU3MZujTcc= github.com/longhorn/nsfilelock v0.0.0-20200723175406-fa7c83ad0003 h1:Jw9uANsGcHTxp6HcC++/vN17LfeuDmozHI2j6DoZf5E= github.com/longhorn/nsfilelock v0.0.0-20200723175406-fa7c83ad0003/go.mod h1:0CLeXlf59Lg6C0kjLSDf47ft73Dh37CwymYRKWwAn04= github.com/longhorn/sparse-tools v0.0.0-20240703010727-92451e38077a h1:+o63c0oh7ZNKeQdc0Hawfzz5vRa4LiDvLOtJYjegtnk= diff --git a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go index cd3467ba1..41dec0f71 100644 --- a/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go +++ b/vendor/github.com/longhorn/longhorn-spdk-engine/pkg/spdk/engine.go @@ -33,21 +33,23 @@ import ( type Engine struct { sync.RWMutex - Name string - VolumeName string - SpecSize uint64 - ActualSize uint64 + Name string + VolumeName string + SpecSize uint64 + ActualSize uint64 + IP string + Port int32 + TargetIP string + TargetPort int32 + Frontend string + Endpoint string + Nqn string + Nguid string + + // TODO: Use a single map to store all replica info ReplicaAddressMap map[string]string ReplicaBdevNameMap map[string]string ReplicaModeMap map[string]types.Mode - IP string - Port int32 - TargetIP string - TargetPort int32 - Frontend string - Endpoint string - Nqn string - Nguid string initiator *nvme.Initiator dmDeviceBusy bool @@ -189,14 +191,14 @@ func (e *Engine) Create(spdkClient *spdkclient.Client, replicaAddressMap map[str for replicaName, replicaAddr := range replicaAddressMap { bdevName, err := connectNVMfBdev(spdkClient, replicaName, replicaAddr) if err != nil { - e.log.WithError(err).Warnf("Failed to get bdev from replica %s with address %s during creation, will mark the mode from %v to ERR and skip it and continue", replicaName, replicaAddr, e.ReplicaModeMap[replicaName]) + e.log.WithError(err).Warnf("Failed to get bdev from replica %s with address %s during creation, will mark the mode from %v to ERR and continue", replicaName, replicaAddr, e.ReplicaModeMap[replicaName]) e.ReplicaModeMap[replicaName] = types.ModeERR + e.ReplicaBdevNameMap[replicaName] = "" + } else { + // TODO: Check if a replica is really a RW replica rather than a rebuilding failed replica + e.ReplicaModeMap[replicaName] = types.ModeRW e.ReplicaBdevNameMap[replicaName] = bdevName - continue } - // TODO: Check if a replica is really a RW replica rather than a rebuilding failed replica - e.ReplicaModeMap[replicaName] = types.ModeRW - e.ReplicaBdevNameMap[replicaName] = bdevName replicaBdevList = append(replicaBdevList, bdevName) } e.ReplicaAddressMap = replicaAddressMap @@ -239,13 +241,14 @@ func (e *Engine) Create(spdkClient *spdkclient.Client, replicaAddressMap map[str for replicaName, replicaAddr := range replicaAddressMap { _, ok := engineWithTarget.ReplicaAddressMap[replicaName] if !ok { - e.log.WithError(err).Warnf("Failed to get bdev from replica %s with address %s, will mark the mode from %v to ERR and skip it and continue", replicaName, replicaAddr, e.ReplicaModeMap[replicaName]) + e.log.WithError(err).Warnf("Failed to get bdev from replica %s with address %s, will mark the mode from %v to ERR and continue", replicaName, replicaAddr, e.ReplicaModeMap[replicaName]) e.ReplicaModeMap[replicaName] = types.ModeERR - continue + e.ReplicaBdevNameMap[replicaName] = "" + } else { + e.ReplicaModeMap[replicaName] = types.ModeRW + e.ReplicaBdevNameMap[replicaName] = replicaName } - e.ReplicaModeMap[replicaName] = types.ModeRW - e.ReplicaBdevNameMap[replicaName] = replicaName replicaBdevList = append(replicaBdevList, replicaName) } @@ -570,6 +573,7 @@ func (e *Engine) ValidateAndUpdate(spdkClient *spdkclient.Client) (err error) { for replicaName := range e.ReplicaAddressMap { if _, exists := e.ReplicaBdevNameMap[replicaName]; !exists { e.ReplicaModeMap[replicaName] = types.ModeERR + e.ReplicaBdevNameMap[replicaName] = "" e.log.Errorf("Engine marked replica %s mode from %v to ERR since it is not found in engine %s bdev name map during ValidateAndUpdate", replicaName, e.ReplicaModeMap[replicaName], e.Name) } if _, exists := e.ReplicaModeMap[replicaName]; !exists { diff --git a/vendor/modules.txt b/vendor/modules.txt index a8a9f50c4..39acd9722 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -230,7 +230,7 @@ github.com/longhorn/longhorn-engine/pkg/sync github.com/longhorn/longhorn-engine/pkg/types github.com/longhorn/longhorn-engine/pkg/util github.com/longhorn/longhorn-engine/pkg/util/disk -# github.com/longhorn/longhorn-spdk-engine v0.0.0-20240814084953-a36eff7350ad +# github.com/longhorn/longhorn-spdk-engine v0.0.0-20240815033436-41791a2d0239 ## explicit; go 1.22.0 github.com/longhorn/longhorn-spdk-engine/pkg/api github.com/longhorn/longhorn-spdk-engine/pkg/client