diff --git a/go.mod b/go.mod index 81784243..3c3696f4 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/google/uuid v1.6.0 github.com/longhorn/backupstore v0.0.0-20240827054225-fe89e488b75f github.com/longhorn/go-common-libs v0.0.0-20240821134112-907f57efd48f - github.com/longhorn/go-spdk-helper v0.0.0-20240820144231-33c0873802ff + github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51 github.com/longhorn/types v0.0.0-20240827042720-af8f10eb57cd github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index eacb3544..b58f441e 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/longhorn/backupstore v0.0.0-20240827054225-fe89e488b75f h1:/Wo/leT2yr github.com/longhorn/backupstore v0.0.0-20240827054225-fe89e488b75f/go.mod h1:N4cqNhSs4VUw9aGbO2OfyiIvJL7/L53hUrNiT73UN+U= github.com/longhorn/go-common-libs v0.0.0-20240821134112-907f57efd48f h1:hjqUs3WVodkzrWwlUMVsnKAlom3uohoNlhZBGLsRvQY= github.com/longhorn/go-common-libs v0.0.0-20240821134112-907f57efd48f/go.mod h1:Qv34svr/msf6XoUwnrltNBTwMhQljbHEhb5ZKWiRdxo= -github.com/longhorn/go-spdk-helper v0.0.0-20240820144231-33c0873802ff h1:8vR29tkbmzmdqRVtOo5kL7Rs7nfhA6duXsmetIh1Tbg= -github.com/longhorn/go-spdk-helper v0.0.0-20240820144231-33c0873802ff/go.mod h1:Bzz7kGNYikAJqpmeV3cgN8jP1y9M+/oaiBc5iolIxuA= +github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51 h1:qU69qwOdcJyDG36Bgp4/b/lydmpJZsPVx+bpszrzQFc= +github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51/go.mod h1:i9btdUP+14isigk+vOfANF7MQAbDO+u/ixeA/oOUwtA= 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/types v0.0.0-20240827042720-af8f10eb57cd h1:AwVxaFaxLPmyl++SyigaZZw8u+Ggun7HlcmNgNqyhjs= diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/initiator.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/initiator.go index efc57621..0190aaa2 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/initiator.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/initiator.go @@ -10,8 +10,8 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" - commonNs "github.com/longhorn/go-common-libs/ns" - commonTypes "github.com/longhorn/go-common-libs/types" + commonns "github.com/longhorn/go-common-libs/ns" + commontypes "github.com/longhorn/go-common-libs/types" "github.com/longhorn/nsfilelock" "github.com/longhorn/go-spdk-helper/pkg/types" @@ -47,7 +47,7 @@ type Initiator struct { isUp bool hostProc string - executor *commonNs.Executor + executor *commonns.Executor logger logrus.FieldLogger } @@ -59,7 +59,7 @@ func NewInitiator(name, subsystemNQN, hostProc string) (*Initiator, error) { } // If transportAddress or transportServiceID is empty, the initiator is still valid for stopping - executor, err := util.NewExecutor(commonTypes.ProcDirectory) + executor, err := util.NewExecutor(commontypes.ProcDirectory) if err != nil { return nil, err } diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvme.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvme.go index 88ed9c7e..75e26da9 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvme.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvme.go @@ -7,7 +7,7 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" - commonNs "github.com/longhorn/go-common-libs/ns" + commonns "github.com/longhorn/go-common-libs/ns" ) const ( @@ -15,7 +15,7 @@ const ( ) // DiscoverTarget discovers a target -func DiscoverTarget(ip, port string, executor *commonNs.Executor) (subnqn string, err error) { +func DiscoverTarget(ip, port string, executor *commonns.Executor) (subnqn string, err error) { hostID, err := getHostID(executor) if err != nil { return "", err @@ -40,7 +40,7 @@ func DiscoverTarget(ip, port string, executor *commonNs.Executor) (subnqn string } // ConnectTarget connects to a target -func ConnectTarget(ip, port, nqn string, executor *commonNs.Executor) (controllerName string, err error) { +func ConnectTarget(ip, port, nqn string, executor *commonns.Executor) (controllerName string, err error) { // Trying to connect an existing subsystem will error out with exit code 114. // Hence, it's better to check the existence first. if devices, err := GetDevices(ip, port, nqn, executor); err == nil && len(devices) > 0 { @@ -60,12 +60,12 @@ func ConnectTarget(ip, port, nqn string, executor *commonNs.Executor) (controlle } // DisconnectTarget disconnects a target -func DisconnectTarget(nqn string, executor *commonNs.Executor) error { +func DisconnectTarget(nqn string, executor *commonns.Executor) error { return disconnect(nqn, executor) } // GetDevices returns all devices -func GetDevices(ip, port, nqn string, executor *commonNs.Executor) (devices []Device, err error) { +func GetDevices(ip, port, nqn string, executor *commonns.Executor) (devices []Device, err error) { defer func() { err = errors.Wrapf(err, "failed to get devices for address %s:%s and nqn %s", ip, port, nqn) }() @@ -172,11 +172,11 @@ func GetDevices(ip, port, nqn string, executor *commonNs.Executor) (devices []De } // GetSubsystems returns all devices -func GetSubsystems(executor *commonNs.Executor) (subsystems []Subsystem, err error) { +func GetSubsystems(executor *commonns.Executor) (subsystems []Subsystem, err error) { return listSubsystems("", executor) } // Flush commits data and metadata associated with the specified namespace(s) to nonvolatile media. -func Flush(device, namespaceID string, executor *commonNs.Executor) (output string, err error) { +func Flush(device, namespaceID string, executor *commonns.Executor) (output string, err error) { return flush(device, namespaceID, executor) } diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvmecli.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvmecli.go index 91a6300d..35aada96 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvmecli.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/nvme/nvmecli.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - commonNs "github.com/longhorn/go-common-libs/ns" + commonns "github.com/longhorn/go-common-libs/ns" "github.com/longhorn/go-spdk-helper/pkg/types" ) @@ -67,7 +67,7 @@ type Path struct { State string `json:"State,omitempty"` } -func cliVersion(executor *commonNs.Executor) (major, minor int, err error) { +func cliVersion(executor *commonns.Executor) (major, minor int, err error) { opts := []string{ "--version", } @@ -105,7 +105,7 @@ func cliVersion(executor *commonNs.Executor) (major, minor int, err error) { return major, minor, nil } -func showHostNQN(executor *commonNs.Executor) (string, error) { +func showHostNQN(executor *commonns.Executor) (string, error) { opts := []string{ "--show-hostnqn", } @@ -124,7 +124,7 @@ func showHostNQN(executor *commonNs.Executor) (string, error) { return "", fmt.Errorf("failed to get host NQN from %s", outputStr) } -func listSubsystems(devicePath string, executor *commonNs.Executor) ([]Subsystem, error) { +func listSubsystems(devicePath string, executor *commonns.Executor) ([]Subsystem, error) { major, _, err := cliVersion(executor) if err != nil { return nil, err @@ -154,7 +154,7 @@ func listSubsystems(devicePath string, executor *commonNs.Executor) ([]Subsystem return listSubsystemsV2(jsonStr, executor) } -func listSubsystemsV1(jsonStr string, executor *commonNs.Executor) ([]Subsystem, error) { +func listSubsystemsV1(jsonStr string, executor *commonns.Executor) ([]Subsystem, error) { output := map[string][]Subsystem{} if err := json.Unmarshal([]byte(jsonStr), &output); err != nil { return nil, err @@ -169,7 +169,7 @@ type ListSubsystemsV2Output struct { Subsystems []Subsystem `json:"Subsystems"` } -func listSubsystemsV2(jsonStr string, executor *commonNs.Executor) ([]Subsystem, error) { +func listSubsystemsV2(jsonStr string, executor *commonns.Executor) ([]Subsystem, error) { var output []ListSubsystemsV2Output if err := json.Unmarshal([]byte(jsonStr), &output); err != nil { return nil, err @@ -197,7 +197,7 @@ type CliDevice struct { SectorSize int32 `json:"SectorSize,omitempty"` } -func listControllers(executor *commonNs.Executor) ([]CliDevice, error) { +func listControllers(executor *commonns.Executor) ([]CliDevice, error) { opts := []string{ "list", "-o", "json", @@ -218,7 +218,7 @@ func listControllers(executor *commonNs.Executor) ([]CliDevice, error) { return output["Devices"], nil } -func getHostID(executor *commonNs.Executor) (string, error) { +func getHostID(executor *commonns.Executor) (string, error) { outputStr, err := executor.Execute(nil, "cat", []string{"/etc/nvme/hostid"}, types.ExecuteTimeout) if err == nil { return strings.TrimSpace(string(outputStr)), nil @@ -232,7 +232,7 @@ func getHostID(executor *commonNs.Executor) (string, error) { return "", err } -func discovery(hostID, hostNQN, ip, port string, executor *commonNs.Executor) ([]DiscoveryPageEntry, error) { +func discovery(hostID, hostNQN, ip, port string, executor *commonns.Executor) ([]DiscoveryPageEntry, error) { opts := []string{ "discover", "-t", DefaultTransportType, @@ -301,7 +301,7 @@ func discovery(hostID, hostNQN, ip, port string, executor *commonNs.Executor) ([ return output.Entries, nil } -func connect(hostID, hostNQN, nqn, transpotType, ip, port string, executor *commonNs.Executor) (string, error) { +func connect(hostID, hostNQN, nqn, transpotType, ip, port string, executor *commonns.Executor) (string, error) { var err error opts := []string{ @@ -349,7 +349,7 @@ func connect(hostID, hostNQN, nqn, transpotType, ip, port string, executor *comm return output["device"], nil } -func disconnect(nqn string, executor *commonNs.Executor) error { +func disconnect(nqn string, executor *commonns.Executor) error { opts := []string{ "disconnect", "--nqn", nqn, @@ -414,7 +414,7 @@ func GetIPAndPortFromControllerAddress(address string) (string, string) { return traddr, trsvcid } -func flush(devicePath, namespaceID string, executor *commonNs.Executor) (string, error) { +func flush(devicePath, namespaceID string, executor *commonns.Executor) (string, error) { opts := []string{ "flush", diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/setup/setup.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/setup/setup.go index 0e84861c..b6e58dd6 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/setup/setup.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/spdk/setup/setup.go @@ -7,7 +7,7 @@ import ( "github.com/pkg/errors" - commonNs "github.com/longhorn/go-common-libs/ns" + commonns "github.com/longhorn/go-common-libs/ns" "github.com/longhorn/go-spdk-helper/pkg/types" ) @@ -16,7 +16,7 @@ const ( spdkSetupPath = "/usr/src/spdk/scripts/setup.sh" ) -func Bind(deviceAddr, deviceDriver string, executor *commonNs.Executor) (string, error) { +func Bind(deviceAddr, deviceDriver string, executor *commonns.Executor) (string, error) { if deviceAddr == "" { return "", fmt.Errorf("device address is empty") } @@ -40,7 +40,7 @@ func Bind(deviceAddr, deviceDriver string, executor *commonNs.Executor) (string, return outputStr, nil } -func Unbind(deviceAddr string, executor *commonNs.Executor) (string, error) { +func Unbind(deviceAddr string, executor *commonns.Executor) (string, error) { if deviceAddr == "" { return "", fmt.Errorf("device address is empty") } @@ -59,7 +59,7 @@ func Unbind(deviceAddr string, executor *commonNs.Executor) (string, error) { return outputStr, nil } -func GetDiskDriver(deviceAddr string, executor *commonNs.Executor) (string, error) { +func GetDiskDriver(deviceAddr string, executor *commonns.Executor) (string, error) { if deviceAddr == "" { return "", fmt.Errorf("device address is empty") } @@ -78,7 +78,7 @@ func GetDiskDriver(deviceAddr string, executor *commonNs.Executor) (string, erro return extractJSON(outputStr) } -func GetDiskStatus(deviceAddr string, executor *commonNs.Executor) (*types.DiskStatus, error) { +func GetDiskStatus(deviceAddr string, executor *commonns.Executor) (*types.DiskStatus, error) { if deviceAddr == "" { return nil, fmt.Errorf("device address is empty") } diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/util/device.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/util/device.go index f55f4fd8..32009875 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/util/device.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/util/device.go @@ -14,7 +14,7 @@ import ( "github.com/sirupsen/logrus" "golang.org/x/sys/unix" - commonNs "github.com/longhorn/go-common-libs/ns" + commonns "github.com/longhorn/go-common-libs/ns" "github.com/longhorn/go-spdk-helper/pkg/types" ) @@ -51,7 +51,7 @@ func RemoveDevice(dev string) error { } // GetKnownDevices returns the path of the device with the given major and minor numbers -func GetKnownDevices(executor *commonNs.Executor) (map[string]*LonghornBlockDevice, error) { +func GetKnownDevices(executor *commonns.Executor) (map[string]*LonghornBlockDevice, error) { knownDevices := make(map[string]*LonghornBlockDevice) // Example command output @@ -94,7 +94,7 @@ func GetKnownDevices(executor *commonNs.Executor) (map[string]*LonghornBlockDevi } // DetectDevice detects the device with the given path -func DetectDevice(path string, executor *commonNs.Executor) (*BlockDevice, error) { +func DetectDevice(path string, executor *commonns.Executor) (*BlockDevice, error) { // Example command output // $ lsblk -l -n -o NAME,MAJ:MIN // nvme1n1 259:3 @@ -180,7 +180,7 @@ func parseNumber(str string) (int, error) { } // GetDeviceSectorSize returns the sector size of the given device -func GetDeviceSectorSize(devPath string, executor *commonNs.Executor) (int64, error) { +func GetDeviceSectorSize(devPath string, executor *commonns.Executor) (int64, error) { opts := []string{ "--getsz", devPath, } @@ -194,7 +194,7 @@ func GetDeviceSectorSize(devPath string, executor *commonNs.Executor) (int64, er } // GetDeviceNumbers returns the major and minor numbers of the given device -func GetDeviceNumbers(devPath string, executor *commonNs.Executor) (int, int, error) { +func GetDeviceNumbers(devPath string, executor *commonns.Executor) (int, int, error) { opts := []string{ "-l", "-J", "-n", "-o", "MAJ:MIN", devPath, } diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/util/dmsetup.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/util/dmsetup.go index 591012c8..6f57fb96 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/util/dmsetup.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/util/dmsetup.go @@ -5,7 +5,7 @@ import ( "regexp" "strings" - commonNs "github.com/longhorn/go-common-libs/ns" + commonns "github.com/longhorn/go-common-libs/ns" "github.com/longhorn/go-spdk-helper/pkg/types" ) @@ -15,7 +15,7 @@ const ( ) // DmsetupCreate creates a device mapper device with the given name and table -func DmsetupCreate(dmDeviceName, table string, executor *commonNs.Executor) error { +func DmsetupCreate(dmDeviceName, table string, executor *commonns.Executor) error { opts := []string{ "create", dmDeviceName, "--table", table, } @@ -24,7 +24,7 @@ func DmsetupCreate(dmDeviceName, table string, executor *commonNs.Executor) erro } // DmsetupSuspend suspends the device mapper device with the given name -func DmsetupSuspend(dmDeviceName string, noflush, nolockfs bool, executor *commonNs.Executor) error { +func DmsetupSuspend(dmDeviceName string, noflush, nolockfs bool, executor *commonns.Executor) error { opts := []string{ "suspend", dmDeviceName, } @@ -42,7 +42,7 @@ func DmsetupSuspend(dmDeviceName string, noflush, nolockfs bool, executor *commo } // DmsetupResume removes the device mapper device with the given name -func DmsetupResume(dmDeviceName string, executor *commonNs.Executor) error { +func DmsetupResume(dmDeviceName string, executor *commonns.Executor) error { opts := []string{ "resume", dmDeviceName, } @@ -51,7 +51,7 @@ func DmsetupResume(dmDeviceName string, executor *commonNs.Executor) error { } // DmsetupReload reloads the table of the device mapper device with the given name and table -func DmsetupReload(dmDeviceName, table string, executor *commonNs.Executor) error { +func DmsetupReload(dmDeviceName, table string, executor *commonns.Executor) error { opts := []string{ "reload", dmDeviceName, "--table", table, } @@ -60,7 +60,7 @@ func DmsetupReload(dmDeviceName, table string, executor *commonNs.Executor) erro } // DmsetupRemove removes the device mapper device with the given name -func DmsetupRemove(dmDeviceName string, force, deferred bool, executor *commonNs.Executor) error { +func DmsetupRemove(dmDeviceName string, force, deferred bool, executor *commonns.Executor) error { opts := []string{ "remove", dmDeviceName, } @@ -75,7 +75,7 @@ func DmsetupRemove(dmDeviceName string, force, deferred bool, executor *commonNs } // DmsetupDeps returns the dependent devices of the device mapper device with the given name -func DmsetupDeps(dmDeviceName string, executor *commonNs.Executor) ([]string, error) { +func DmsetupDeps(dmDeviceName string, executor *commonns.Executor) ([]string, error) { opts := []string{ "deps", dmDeviceName, "-o", "devname", } @@ -116,7 +116,7 @@ type DeviceInfo struct { } // DmsetupInfo returns the information of the device mapper device with the given name -func DmsetupInfo(dmDeviceName string, executor *commonNs.Executor) ([]*DeviceInfo, error) { +func DmsetupInfo(dmDeviceName string, executor *commonns.Executor) ([]*DeviceInfo, error) { opts := []string{ "info", "--columns", diff --git a/vendor/github.com/longhorn/go-spdk-helper/pkg/util/executor.go b/vendor/github.com/longhorn/go-spdk-helper/pkg/util/executor.go index 96f56e81..694961ec 100644 --- a/vendor/github.com/longhorn/go-spdk-helper/pkg/util/executor.go +++ b/vendor/github.com/longhorn/go-spdk-helper/pkg/util/executor.go @@ -1,13 +1,13 @@ package util import ( - commonNs "github.com/longhorn/go-common-libs/ns" - commonTypes "github.com/longhorn/go-common-libs/types" + commonns "github.com/longhorn/go-common-libs/ns" + commontypes "github.com/longhorn/go-common-libs/types" ) // NewExecutor creates a new namespaced executor -func NewExecutor(hostProc string) (*commonNs.Executor, error) { - namespaces := []commonTypes.Namespace{commonTypes.NamespaceMnt, commonTypes.NamespaceIpc, commonTypes.NamespaceNet} +func NewExecutor(hostProc string) (*commonns.Executor, error) { + namespaces := []commontypes.Namespace{commontypes.NamespaceMnt, commontypes.NamespaceIpc, commontypes.NamespaceNet} - return commonNs.NewNamespaceExecutor(commonTypes.ProcessNone, hostProc, namespaces) + return commonns.NewNamespaceExecutor(commontypes.ProcessNone, hostProc, namespaces) } diff --git a/vendor/modules.txt b/vendor/modules.txt index edc45e89..152f7f13 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -64,7 +64,7 @@ github.com/longhorn/go-common-libs/sync github.com/longhorn/go-common-libs/sys github.com/longhorn/go-common-libs/types github.com/longhorn/go-common-libs/utils -# github.com/longhorn/go-spdk-helper v0.0.0-20240820144231-33c0873802ff +# github.com/longhorn/go-spdk-helper v0.0.0-20240827171022-9fe38fff5b51 ## explicit; go 1.22.0 github.com/longhorn/go-spdk-helper/pkg/jsonrpc github.com/longhorn/go-spdk-helper/pkg/nvme