diff --git a/go.mod b/go.mod index 9a4d6c8c..e12aa5d6 100644 --- a/go.mod +++ b/go.mod @@ -3,38 +3,38 @@ module github.com/longhorn/longhorn-share-manager go 1.21 replace ( - k8s.io/api => k8s.io/api v0.29.1 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.29.1 - k8s.io/apimachinery => k8s.io/apimachinery v0.29.1 - k8s.io/apiserver => k8s.io/apiserver v0.29.1 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.29.1 - k8s.io/client-go => k8s.io/client-go v0.29.1 - k8s.io/cloud-provider => k8s.io/cloud-provider v0.29.1 - k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.29.1 - k8s.io/code-generator => k8s.io/code-generator v0.29.1 - k8s.io/component-base => k8s.io/component-base v0.29.1 - k8s.io/component-helpers => k8s.io/component-helpers v0.29.1 - k8s.io/controller-manager => k8s.io/controller-manager v0.29.1 - k8s.io/cri-api => k8s.io/cri-api v0.29.1 - k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.29.1 - k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.29.1 - k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.29.1 - k8s.io/kube-proxy => k8s.io/kube-proxy v0.29.1 - k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.29.1 - k8s.io/kubectl => k8s.io/kubectl v0.29.1 - k8s.io/kubelet => k8s.io/kubelet v0.29.1 - k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.29.1 - k8s.io/metrics => k8s.io/metrics v0.29.1 - k8s.io/mount-utils => k8s.io/mount-utils v0.29.1 - k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.29.1 - k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.29.1 + k8s.io/api => k8s.io/api v0.29.2 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.29.2 + k8s.io/apimachinery => k8s.io/apimachinery v0.29.2 + k8s.io/apiserver => k8s.io/apiserver v0.29.2 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.29.2 + k8s.io/client-go => k8s.io/client-go v0.29.2 + k8s.io/cloud-provider => k8s.io/cloud-provider v0.29.2 + k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.29.2 + k8s.io/code-generator => k8s.io/code-generator v0.29.2 + k8s.io/component-base => k8s.io/component-base v0.29.2 + k8s.io/component-helpers => k8s.io/component-helpers v0.29.2 + k8s.io/controller-manager => k8s.io/controller-manager v0.29.2 + k8s.io/cri-api => k8s.io/cri-api v0.29.2 + k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.29.2 + k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.29.2 + k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.29.2 + k8s.io/kube-proxy => k8s.io/kube-proxy v0.29.2 + k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.29.2 + k8s.io/kubectl => k8s.io/kubectl v0.29.2 + k8s.io/kubelet => k8s.io/kubelet v0.29.2 + k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.29.2 + k8s.io/metrics => k8s.io/metrics v0.29.2 + k8s.io/mount-utils => k8s.io/mount-utils v0.29.2 + k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.29.2 + k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.29.2 ) require ( github.com/golang/protobuf v1.5.3 github.com/google/fscrypt v0.3.4 - github.com/longhorn/go-common-libs v0.0.0-20240207153251-d5e1ceae50ac + github.com/longhorn/go-common-libs v0.0.0-20240219094750-e7176c332156 github.com/mitchellh/go-ps v1.0.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 @@ -44,7 +44,7 @@ require ( google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 k8s.io/kubernetes v1.28.5 - k8s.io/mount-utils v0.29.1 + k8s.io/mount-utils v0.29.2 k8s.io/utils v0.0.0-20240102154912-e7106e64919e ) diff --git a/go.sum b/go.sum index a9c3b6b4..7bcd0d51 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,8 @@ github.com/longhorn/go-common-libs v0.0.0-20240207150648-1e655f4e19ea h1:BsxiPf7 github.com/longhorn/go-common-libs v0.0.0-20240207150648-1e655f4e19ea/go.mod h1:nIECQARppamt2zwFSdzADRTVKo/7izFwWIS3VWi7D/s= github.com/longhorn/go-common-libs v0.0.0-20240207153251-d5e1ceae50ac h1:Nz/fI1xZHmywhoQtgYCVA3m298wPGY7Mub6Od88WGoA= github.com/longhorn/go-common-libs v0.0.0-20240207153251-d5e1ceae50ac/go.mod h1:nIECQARppamt2zwFSdzADRTVKo/7izFwWIS3VWi7D/s= +github.com/longhorn/go-common-libs v0.0.0-20240219094750-e7176c332156 h1:Jv1+UlfrzSodyIobaioQn8Vh4RQ+23FpN2Q60iFdqCU= +github.com/longhorn/go-common-libs v0.0.0-20240219094750-e7176c332156/go.mod h1:nIECQARppamt2zwFSdzADRTVKo/7izFwWIS3VWi7D/s= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc= github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= @@ -171,6 +173,8 @@ k8s.io/mount-utils v0.28.5 h1:JRBnrJ3uGHMGzJlk/CqzcL6wtayAOfTqecAugYZeff4= k8s.io/mount-utils v0.28.5/go.mod h1:ceMAZ+Nzlk8zOwN205YXXGJRGmf1o0/XIwsKnG44p0I= k8s.io/mount-utils v0.29.1 h1:veXlIm52Y4tm3H0pG03cOdkw0KOJxYDa0fQqhJCoqvQ= k8s.io/mount-utils v0.29.1/go.mod h1:9IWJTMe8tG0MYMLEp60xK9GYVeCdA3g4LowmnVi+t9Y= +k8s.io/mount-utils v0.29.2 h1:FrUfgvOo63nqJRPXKoqN/DW1lMnR/y0pzpFErKh6p2o= +k8s.io/mount-utils v0.29.2/go.mod h1:9IWJTMe8tG0MYMLEp60xK9GYVeCdA3g4LowmnVi+t9Y= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= diff --git a/vendor/github.com/longhorn/go-common-libs/ns/crypto.go b/vendor/github.com/longhorn/go-common-libs/ns/crypto.go index d8988dda..5638b37d 100644 --- a/vendor/github.com/longhorn/go-common-libs/ns/crypto.go +++ b/vendor/github.com/longhorn/go-common-libs/ns/crypto.go @@ -65,5 +65,5 @@ func (nsexec *Executor) CryptsetupWithPassphrase(passphrase string, args []strin // For Talos Linux, cryptsetup comes pre-installed in the host namespace // (ref: https://github.com/siderolabs/pkgs/blob/release-1.4/reproducibility/pkg.yaml#L10) // for the [Disk Encryption](https://www.talos.dev/v1.4/talos-guides/configuration/disk-encryption/). - return nsexec.ExecuteWithStdin(types.BinaryCryptsetup, args, passphrase, timeout) + return nsexec.ExecuteWithStdin(nil, types.BinaryCryptsetup, args, passphrase, timeout) } diff --git a/vendor/github.com/longhorn/go-common-libs/ns/executor.go b/vendor/github.com/longhorn/go-common-libs/ns/executor.go index 617f21e0..a850e771 100644 --- a/vendor/github.com/longhorn/go-common-libs/ns/executor.go +++ b/vendor/github.com/longhorn/go-common-libs/ns/executor.go @@ -46,7 +46,7 @@ func NewNamespaceExecutor(processName, procDirectory string, namespaces []types. } // prepareCommandArgs prepares the nsenter command arguments. -func (nsexec *Executor) prepareCommandArgs(binary string, args []string) []string { +func (nsexec *Executor) prepareCommandArgs(binary string, args, envs []string) []string { cmdArgs := []string{} for _, ns := range nsexec.namespaces { nsPath := filepath.Join(nsexec.nsDirectory, ns.String()) @@ -59,24 +59,29 @@ func (nsexec *Executor) prepareCommandArgs(binary string, args []string) []strin cmdArgs = append(cmdArgs, "--net="+nsPath) } } + if len(envs) > 0 { + cmdArgs = append(cmdArgs, "env", "-i") + cmdArgs = append(cmdArgs, envs...) + } + cmdArgs = append(cmdArgs, binary) return append(cmdArgs, args...) } // Execute executes the command in the namespace. If NsDirectory is empty, // it will execute the command in the current namespace. -func (nsexec *Executor) Execute(binary string, args []string, timeout time.Duration) (string, error) { - return nsexec.executor.Execute(nil, types.NsBinary, nsexec.prepareCommandArgs(binary, args), timeout) +func (nsexec *Executor) Execute(envs []string, binary string, args []string, timeout time.Duration) (string, error) { + return nsexec.executor.Execute(nil, types.NsBinary, nsexec.prepareCommandArgs(binary, args, envs), timeout) } // ExecuteWithStdin executes the command in the namespace with stdin. // If NsDirectory is empty, it will execute the command in the current namespace. -func (nsexec *Executor) ExecuteWithStdin(binary string, args []string, stdinString string, timeout time.Duration) (string, error) { - return nsexec.executor.ExecuteWithStdin(types.NsBinary, nsexec.prepareCommandArgs(binary, args), stdinString, timeout) +func (nsexec *Executor) ExecuteWithStdin(envs []string, binary string, args []string, stdinString string, timeout time.Duration) (string, error) { + return nsexec.executor.ExecuteWithStdin(types.NsBinary, nsexec.prepareCommandArgs(binary, args, envs), stdinString, timeout) } // ExecuteWithStdinPipe executes the command in the namespace with stdin pipe. // If NsDirectory is empty, it will execute the command in the current namespace. -func (nsexec *Executor) ExecuteWithStdinPipe(binary string, args []string, stdinString string, timeout time.Duration) (string, error) { - return nsexec.executor.ExecuteWithStdinPipe(types.NsBinary, nsexec.prepareCommandArgs(binary, args), stdinString, timeout) +func (nsexec *Executor) ExecuteWithStdinPipe(envs []string, binary string, args []string, stdinString string, timeout time.Duration) (string, error) { + return nsexec.executor.ExecuteWithStdinPipe(types.NsBinary, nsexec.prepareCommandArgs(binary, args, envs), stdinString, timeout) } diff --git a/vendor/github.com/longhorn/go-common-libs/ns/filelock.go b/vendor/github.com/longhorn/go-common-libs/ns/filelock.go index 698cca6c..b0ce92c6 100644 --- a/vendor/github.com/longhorn/go-common-libs/ns/filelock.go +++ b/vendor/github.com/longhorn/go-common-libs/ns/filelock.go @@ -40,7 +40,7 @@ func LockFile(path string) (result *os.File, err error) { // FileLock is a struct responsible for locking a file. type FileLock struct { FilePath string // The path of the file to lock. - File *os.File // The file handle aquired after successful lock. + File *os.File // The file handle acquired after successful lock. Timeout time.Duration // The maximum time to wait for lock acquisition. done chan struct{} // A channel for signaling lock release. 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 ea6f029a..e4e23a30 100644 --- a/vendor/github.com/longhorn/go-common-libs/sys/sys.go +++ b/vendor/github.com/longhorn/go-common-libs/sys/sys.go @@ -56,13 +56,13 @@ func GetOSDistro(osReleaseContent string) (string, error) { // GetSystemBlockDeviceInfo returns the block device info for the system. func GetSystemBlockDeviceInfo() (map[string]types.BlockDeviceInfo, error) { - return getSystemBlockDeviceInfo(os.ReadDir, os.ReadFile) + return getSystemBlockDeviceInfo(types.SysClassBlockDirectory, os.ReadDir, os.ReadFile) } // getSystemBlockDeviceInfo returns the block device info for the system. // It injects the readDirFn and readFileFn for testing. -func getSystemBlockDeviceInfo(readDirFn func(string) ([]os.DirEntry, error), readFileFn func(string) ([]byte, error)) (map[string]types.BlockDeviceInfo, error) { - devices, err := readDirFn(types.SysClassBlockDirectory) +func getSystemBlockDeviceInfo(sysClassBlockDirectory string, readDirFn func(string) ([]os.DirEntry, error), readFileFn func(string) ([]byte, error)) (map[string]types.BlockDeviceInfo, error) { + devices, err := readDirFn(sysClassBlockDirectory) if err != nil { return nil, err } @@ -82,12 +82,12 @@ func getSystemBlockDeviceInfo(readDirFn func(string) ([]os.DirEntry, error), rea deviceInfo := make(map[string]types.BlockDeviceInfo, len(devices)) for _, device := range devices { deviceName := device.Name() - devicePath := filepath.Join(types.SysClassBlockDirectory, deviceName, "dev") + devicePath := filepath.Join(sysClassBlockDirectory, deviceName, "dev") if _, err := os.Stat(devicePath); os.IsNotExist(err) { // If the device path does not exist, check if the device path exists in the "device" directory. // Some devices such as "nvme0cn1" created from SPDK do not have "dev" file under their sys/class/block directory. - alternativeDevicePath := filepath.Join(types.SysClassBlockDirectory, deviceName, "device", "dev") + alternativeDevicePath := filepath.Join(sysClassBlockDirectory, deviceName, "device", "dev") if _, altErr := os.Stat(alternativeDevicePath); os.IsNotExist(altErr) { errs := fmt.Errorf("primary error: %w; alternative error: %w", err, altErr) logrus.WithFields(logrus.Fields{ diff --git a/vendor/modules.txt b/vendor/modules.txt index 29430393..38e95e58 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -28,7 +28,7 @@ github.com/google/fscrypt/util # github.com/google/uuid v1.3.1 ## explicit github.com/google/uuid -# github.com/longhorn/go-common-libs v0.0.0-20240207153251-d5e1ceae50ac +# github.com/longhorn/go-common-libs v0.0.0-20240219094750-e7176c332156 ## explicit; go 1.21 github.com/longhorn/go-common-libs/exec github.com/longhorn/go-common-libs/io @@ -199,7 +199,7 @@ k8s.io/klog/v2/internal/sloghandler # k8s.io/kubernetes v1.28.5 ## explicit; go 1.20 k8s.io/kubernetes/pkg/volume/util/hostutil -# k8s.io/mount-utils v0.29.1 => k8s.io/mount-utils v0.29.1 +# k8s.io/mount-utils v0.29.2 => k8s.io/mount-utils v0.29.2 ## explicit; go 1.21 k8s.io/mount-utils # k8s.io/utils v0.0.0-20240102154912-e7106e64919e @@ -208,28 +208,28 @@ k8s.io/utils/exec k8s.io/utils/io k8s.io/utils/keymutex k8s.io/utils/path -# k8s.io/api => k8s.io/api v0.29.1 -# k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.29.1 -# k8s.io/apimachinery => k8s.io/apimachinery v0.29.1 -# k8s.io/apiserver => k8s.io/apiserver v0.29.1 -# k8s.io/cli-runtime => k8s.io/cli-runtime v0.29.1 -# k8s.io/client-go => k8s.io/client-go v0.29.1 -# k8s.io/cloud-provider => k8s.io/cloud-provider v0.29.1 -# k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.29.1 -# k8s.io/code-generator => k8s.io/code-generator v0.29.1 -# k8s.io/component-base => k8s.io/component-base v0.29.1 -# k8s.io/component-helpers => k8s.io/component-helpers v0.29.1 -# k8s.io/controller-manager => k8s.io/controller-manager v0.29.1 -# k8s.io/cri-api => k8s.io/cri-api v0.29.1 -# k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.29.1 -# k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.29.1 -# k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.29.1 -# k8s.io/kube-proxy => k8s.io/kube-proxy v0.29.1 -# k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.29.1 -# k8s.io/kubectl => k8s.io/kubectl v0.29.1 -# k8s.io/kubelet => k8s.io/kubelet v0.29.1 -# k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.29.1 -# k8s.io/metrics => k8s.io/metrics v0.29.1 -# k8s.io/mount-utils => k8s.io/mount-utils v0.29.1 -# k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.29.1 -# k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.29.1 +# k8s.io/api => k8s.io/api v0.29.2 +# k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.29.2 +# k8s.io/apimachinery => k8s.io/apimachinery v0.29.2 +# k8s.io/apiserver => k8s.io/apiserver v0.29.2 +# k8s.io/cli-runtime => k8s.io/cli-runtime v0.29.2 +# k8s.io/client-go => k8s.io/client-go v0.29.2 +# k8s.io/cloud-provider => k8s.io/cloud-provider v0.29.2 +# k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.29.2 +# k8s.io/code-generator => k8s.io/code-generator v0.29.2 +# k8s.io/component-base => k8s.io/component-base v0.29.2 +# k8s.io/component-helpers => k8s.io/component-helpers v0.29.2 +# k8s.io/controller-manager => k8s.io/controller-manager v0.29.2 +# k8s.io/cri-api => k8s.io/cri-api v0.29.2 +# k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.29.2 +# k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.29.2 +# k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.29.2 +# k8s.io/kube-proxy => k8s.io/kube-proxy v0.29.2 +# k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.29.2 +# k8s.io/kubectl => k8s.io/kubectl v0.29.2 +# k8s.io/kubelet => k8s.io/kubelet v0.29.2 +# k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.29.2 +# k8s.io/metrics => k8s.io/metrics v0.29.2 +# k8s.io/mount-utils => k8s.io/mount-utils v0.29.2 +# k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.29.2 +# k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.29.2