From b35cfa777070f5ee6c24b84dcfd7c1e0a23454bd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 28 Sep 2024 04:21:15 +0000 Subject: [PATCH] fix(deps): update github.com/longhorn/go-common-libs digest to 3a320d8 --- go.mod | 2 +- go.sum | 4 +- .../longhorn/go-common-libs/io/file.go | 13 ++++--- .../longhorn/go-common-libs/ns/joiner.go | 27 +------------ .../go-common-libs/ns/joiner_darwin.go | 10 +++++ .../go-common-libs/ns/joiner_linux.go | 38 +++++++++++++++++++ .../longhorn/go-common-libs/sys/sys.go | 6 +-- .../go-common-libs/types/namespace.go | 11 ------ .../go-common-libs/types/namespace_darwin.go | 5 +++ .../go-common-libs/types/namespace_linux.go | 14 +++++++ vendor/modules.txt | 2 +- 11 files changed, 82 insertions(+), 50 deletions(-) create mode 100644 vendor/github.com/longhorn/go-common-libs/ns/joiner_darwin.go create mode 100644 vendor/github.com/longhorn/go-common-libs/ns/joiner_linux.go create mode 100644 vendor/github.com/longhorn/go-common-libs/types/namespace_darwin.go create mode 100644 vendor/github.com/longhorn/go-common-libs/types/namespace_linux.go diff --git a/go.mod b/go.mod index 61a2170e..e39af227 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ replace ( require ( github.com/google/fscrypt v0.3.5 - github.com/longhorn/go-common-libs v0.0.0-20240921050101-797b589b669d + github.com/longhorn/go-common-libs v0.0.0-20240926084818-3a320d860af4 github.com/mitchellh/go-ps v1.0.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 29ffc01b..31e55252 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/longhorn/go-common-libs v0.0.0-20240921050101-797b589b669d h1:MXJlzyXLptspJEc1UC7ee2eBIYksTl0RT2bXUAXU+8Q= -github.com/longhorn/go-common-libs v0.0.0-20240921050101-797b589b669d/go.mod h1:L8QlyY7cqL84FcxnJ8HK6DaQ1Ej9JiZtZ94OW5W+Yyw= +github.com/longhorn/go-common-libs v0.0.0-20240926084818-3a320d860af4 h1:XIVowDtBbw8kAEf0JCCFx5eMyUkuDBhAhpM3WtUAN0U= +github.com/longhorn/go-common-libs v0.0.0-20240926084818-3a320d860af4/go.mod h1:L8QlyY7cqL84FcxnJ8HK6DaQ1Ej9JiZtZ94OW5W+Yyw= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= diff --git a/vendor/github.com/longhorn/go-common-libs/io/file.go b/vendor/github.com/longhorn/go-common-libs/io/file.go index d4ad1c00..aea7fd4b 100644 --- a/vendor/github.com/longhorn/go-common-libs/io/file.go +++ b/vendor/github.com/longhorn/go-common-libs/io/file.go @@ -12,6 +12,7 @@ import ( "github.com/pkg/errors" "github.com/shirou/gopsutil/v3/disk" "github.com/sirupsen/logrus" + "golang.org/x/sys/unix" "github.com/longhorn/go-common-libs/types" ) @@ -227,8 +228,8 @@ func GetDiskStat(path string) (diskStat types.DiskStat, err error) { err = errors.Wrapf(err, "failed to get fs stat for %v", path) }() - var statfs syscall.Statfs_t - if err := syscall.Statfs(path, &statfs); err != nil { + var statfs unix.Statfs_t + if err := unix.Statfs(path, &statfs); err != nil { return diskStat, err } @@ -239,7 +240,7 @@ func GetDiskStat(path string) (diskStat types.DiskStat, err error) { // Convert the FSID components to a single uint64 FSID value var fsidValue uint64 - for _, component := range statfs.Fsid.X__val { + for _, component := range statfs.Fsid.Val { // Combine components using bit manipulation fsidValue = (fsidValue << 32) | uint64(uint32(component)) } @@ -254,9 +255,9 @@ func GetDiskStat(path string) (diskStat types.DiskStat, err error) { Driver: types.DiskDriverNone, FreeBlocks: int64(statfs.Bfree), TotalBlocks: int64(statfs.Blocks), - BlockSize: statfs.Bsize, - StorageMaximum: int64(statfs.Blocks) * statfs.Bsize, - StorageAvailable: int64(statfs.Bfree) * statfs.Bsize, + BlockSize: int64(statfs.Bsize), + StorageMaximum: int64(statfs.Blocks) * int64(statfs.Bsize), + StorageAvailable: int64(statfs.Bfree) * int64(statfs.Bsize), }, nil } diff --git a/vendor/github.com/longhorn/go-common-libs/ns/joiner.go b/vendor/github.com/longhorn/go-common-libs/ns/joiner.go index b62e9c9b..09c7ace1 100644 --- a/vendor/github.com/longhorn/go-common-libs/ns/joiner.go +++ b/vendor/github.com/longhorn/go-common-libs/ns/joiner.go @@ -46,31 +46,6 @@ func (joiners *Joiners) JoinReverse() (err error) { return joiners.Join() } -// Join joins all the namespaces in the Joiners. -func (joiners *Joiners) Join() (err error) { - for _, joiner := range *joiners { - if joiner.isJoined { - logrus.Tracef("Already joined namespace: %s", joiner.namespace) - continue - } - - if joiner.namespace == types.NamespaceMnt { - err := unix.Unshare(unix.CLONE_NEWNS) - if err != nil { - return errors.Wrapf(err, "failed to unshare namespace: %+s", joiner.namespace) - } - } - - if err := unix.Setns(joiner.fd, 0); err != nil { - return errors.Wrapf(err, "failed to set namespace: %+s", joiner.namespace) - } - - joiner.isJoined = true - logrus.Tracef("Joined namespace: %v", joiner.namespace) - } - return nil -} - // Reset resets all the Joiners. func (joiners *Joiners) Reset() (err error) { for _, joiner := range *joiners { @@ -214,7 +189,7 @@ func (jd *JoinerDescriptor) openAndRecordNamespaceFiles(namespace types.Namespac // The original namespace file is the namespace file of the process thread that is // executing the joiner (e.g. /proc/1/task/2/ns/mnt) func (jd *JoinerDescriptor) openAndRecordOriginalNamespaceFile(ns string, namespace types.Namespace) error { - pthreadFile := filepath.Join("/proc", fmt.Sprint(os.Getpid()), "task", fmt.Sprint(unix.Gettid()), "ns", ns) + pthreadFile := filepath.Join("/proc", fmt.Sprint(os.Getpid()), "task", fmt.Sprint(Gettid()), "ns", ns) originFd, err := jd.origin.OpenFile(pthreadFile) if err != nil { return errors.Wrapf(err, "failed to open process thread file %v", pthreadFile) diff --git a/vendor/github.com/longhorn/go-common-libs/ns/joiner_darwin.go b/vendor/github.com/longhorn/go-common-libs/ns/joiner_darwin.go new file mode 100644 index 00000000..4a2a2e05 --- /dev/null +++ b/vendor/github.com/longhorn/go-common-libs/ns/joiner_darwin.go @@ -0,0 +1,10 @@ +package ns + +// Join joins all the namespaces in the Joiners. +func (joiners *Joiners) Join() (err error) { + return nil +} + +func Gettid() int { + return 0 +} diff --git a/vendor/github.com/longhorn/go-common-libs/ns/joiner_linux.go b/vendor/github.com/longhorn/go-common-libs/ns/joiner_linux.go new file mode 100644 index 00000000..a05ce801 --- /dev/null +++ b/vendor/github.com/longhorn/go-common-libs/ns/joiner_linux.go @@ -0,0 +1,38 @@ +package ns + +import ( + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "golang.org/x/sys/unix" + + "github.com/longhorn/go-common-libs/types" +) + +// Join joins all the namespaces in the Joiners. +func (joiners *Joiners) Join() (err error) { + for _, joiner := range *joiners { + if joiner.isJoined { + logrus.Tracef("Already joined namespace: %s", joiner.namespace) + continue + } + + if joiner.namespace == types.NamespaceMnt { + err := unix.Unshare(unix.CLONE_NEWNS) + if err != nil { + return errors.Wrapf(err, "failed to unshare namespace: %+s", joiner.namespace) + } + } + + if err := unix.Setns(joiner.fd, 0); err != nil { + return errors.Wrapf(err, "failed to set namespace: %+s", joiner.namespace) + } + + joiner.isJoined = true + logrus.Tracef("Joined namespace: %v", joiner.namespace) + } + return nil +} + +func Gettid() int { + return unix.Gettid() +} diff --git a/vendor/github.com/longhorn/go-common-libs/sys/sys.go b/vendor/github.com/longhorn/go-common-libs/sys/sys.go index e4e23a30..076d3dcc 100644 --- a/vendor/github.com/longhorn/go-common-libs/sys/sys.go +++ b/vendor/github.com/longhorn/go-common-libs/sys/sys.go @@ -6,18 +6,18 @@ import ( "path/filepath" "strconv" "strings" - "syscall" "github.com/pkg/errors" "github.com/sirupsen/logrus" + "golang.org/x/sys/unix" "github.com/longhorn/go-common-libs/types" ) // GetKernelRelease returns the kernel release string. func GetKernelRelease() (string, error) { - utsname := &syscall.Utsname{} - if err := syscall.Uname(utsname); err != nil { + utsname := &unix.Utsname{} + if err := unix.Uname(utsname); err != nil { logrus.WithError(err).Warn("Failed to get kernel release") return "", err } diff --git a/vendor/github.com/longhorn/go-common-libs/types/namespace.go b/vendor/github.com/longhorn/go-common-libs/types/namespace.go index 7358a407..b0c56623 100644 --- a/vendor/github.com/longhorn/go-common-libs/types/namespace.go +++ b/vendor/github.com/longhorn/go-common-libs/types/namespace.go @@ -2,8 +2,6 @@ package types import ( "time" - - "golang.org/x/sys/unix" ) const ( @@ -28,15 +26,6 @@ const ( NamespaceNet = Namespace("net") ) -func (ns Namespace) Flag() uintptr { - switch ns { - case NamespaceNet: - return unix.CLONE_NEWNET - default: - return 0 - } -} - func (ns Namespace) String() string { return string(ns) } diff --git a/vendor/github.com/longhorn/go-common-libs/types/namespace_darwin.go b/vendor/github.com/longhorn/go-common-libs/types/namespace_darwin.go new file mode 100644 index 00000000..baf5465f --- /dev/null +++ b/vendor/github.com/longhorn/go-common-libs/types/namespace_darwin.go @@ -0,0 +1,5 @@ +package types + +func (ns Namespace) Flag() uintptr { + return 0 +} diff --git a/vendor/github.com/longhorn/go-common-libs/types/namespace_linux.go b/vendor/github.com/longhorn/go-common-libs/types/namespace_linux.go new file mode 100644 index 00000000..a0c18fd2 --- /dev/null +++ b/vendor/github.com/longhorn/go-common-libs/types/namespace_linux.go @@ -0,0 +1,14 @@ +package types + +import ( + "golang.org/x/sys/unix" +) + +func (ns Namespace) Flag() uintptr { + switch ns { + case NamespaceNet: + return unix.CLONE_NEWNET + default: + return 0 + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 40c1f4e9..7dd43f55 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -64,7 +64,7 @@ github.com/josharian/intern # github.com/json-iterator/go v1.1.12 ## explicit; go 1.12 github.com/json-iterator/go -# github.com/longhorn/go-common-libs v0.0.0-20240921050101-797b589b669d +# github.com/longhorn/go-common-libs v0.0.0-20240926084818-3a320d860af4 ## explicit; go 1.22.0 github.com/longhorn/go-common-libs/exec github.com/longhorn/go-common-libs/io