diff --git a/go.mod b/go.mod index a92f03de..3a763f26 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ replace ( k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.30.3 k8s.io/kubectl => k8s.io/kubectl v0.30.3 k8s.io/kubelet => k8s.io/kubelet v0.30.3 - k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.30.9 + k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.30.10 k8s.io/metrics => k8s.io/metrics v0.30.3 k8s.io/mount-utils => k8s.io/mount-utils v0.30.3 k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.30.3 @@ -48,8 +48,8 @@ replace ( require ( github.com/google/fscrypt v0.3.5 - github.com/longhorn/go-common-libs v0.0.0-20250204050409-8ebd4432fd70 - github.com/longhorn/types v0.0.0-20241225162202-00d3a5fd7502 + github.com/longhorn/go-common-libs v0.0.0-20250214070119-c86a06c781f5 + github.com/longhorn/types v0.0.0-20250210001806-5ef312749bee github.com/mitchellh/go-ps v1.0.0 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 @@ -94,7 +94,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shirou/gopsutil/v3 v3.24.5 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect - golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c // indirect + golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/term v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/go.sum b/go.sum index 1a672560..e763c8b1 100644 --- a/go.sum +++ b/go.sum @@ -63,10 +63,10 @@ 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-20250204050409-8ebd4432fd70 h1:g8bzjIZQibCEEjp9kJadSex7Tsslw9fENQJnruGes70= -github.com/longhorn/go-common-libs v0.0.0-20250204050409-8ebd4432fd70/go.mod h1:9aezM1ef3JFYww2tCbeEoRr5091C4T6SNyp6LJ87Kqc= -github.com/longhorn/types v0.0.0-20241225162202-00d3a5fd7502 h1:jgw7nosooLe1NQEdCGzM/nEOFzPcurNO+0PDsicc5+A= -github.com/longhorn/types v0.0.0-20241225162202-00d3a5fd7502/go.mod h1:3jHuVDtpkXQzpnp4prguDBskVRric2kmF8aSPkRJ4jw= +github.com/longhorn/go-common-libs v0.0.0-20250214070119-c86a06c781f5 h1:EHHl1jzMC26pJmxLGwxjU0WjNz8vWrF7+s70I0VP060= +github.com/longhorn/go-common-libs v0.0.0-20250214070119-c86a06c781f5/go.mod h1:WHFO5jD8wdnSSB5g+/mKNzcC0bglsPpH7ZBfFNlOMko= +github.com/longhorn/types v0.0.0-20250210001806-5ef312749bee h1:Zs5aeND6m29Tr3wfYmioK9ecSJW+L6o1Xhzj7zQQSrg= +github.com/longhorn/types v0.0.0-20250210001806-5ef312749bee/go.mod h1:3jHuVDtpkXQzpnp4prguDBskVRric2kmF8aSPkRJ4jw= 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= @@ -135,8 +135,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= -golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c h1:KL/ZBHXgKGVmuZBZ01Lt57yE5ws8ZPSkkihmEyq7FXc= -golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= +golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 h1:qNgPs5exUA+G0C96DrPwNrvLSj7GT/9D+3WMWUcUg34= +golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= 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 5638b37d..048a0135 100644 --- a/vendor/github.com/longhorn/go-common-libs/ns/crypto.go +++ b/vendor/github.com/longhorn/go-common-libs/ns/crypto.go @@ -1,8 +1,11 @@ package ns import ( + "os/exec" "time" + "github.com/pkg/errors" + "github.com/longhorn/go-common-libs/types" ) @@ -47,6 +50,24 @@ func (nsexec *Executor) LuksStatus(volume string, timeout time.Duration) (stdout return nsexec.Cryptsetup(args, timeout) } +// IsLuks checks if the device is encrypted with LUKS. +func (nsexec *Executor) IsLuks(devicePath string, timeout time.Duration) (bool, error) { + args := []string{"isLuks", devicePath} + _, err := nsexec.Cryptsetup(args, timeout) + if err == nil { + return true, nil + } + var exitErr *exec.ExitError + if errors.As(err, &exitErr) { + if exitErr.ExitCode() == 1 { + // The device is not encrypted if exit code of 1 is returned + // Ref https://gitlab.com/cryptsetup/cryptsetup/-/blob/main/FAQ.md?plain=1#L2848 + return false, nil + } + } + return false, err +} + // Cryptsetup runs cryptsetup without passphrase. It will return // 0 on success and a non-zero value on error. func (nsexec *Executor) Cryptsetup(args []string, timeout time.Duration) (stdout string, err error) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 31dcf00f..246ea1a7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -67,7 +67,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-20250204050409-8ebd4432fd70 +# github.com/longhorn/go-common-libs v0.0.0-20250214070119-c86a06c781f5 ## explicit; go 1.22.7 github.com/longhorn/go-common-libs/exec github.com/longhorn/go-common-libs/io @@ -78,7 +78,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/types v0.0.0-20241225162202-00d3a5fd7502 +# github.com/longhorn/types v0.0.0-20250210001806-5ef312749bee ## explicit; go 1.22.7 github.com/longhorn/types/pkg/generated/smrpc # github.com/mailru/easyjson v0.7.7 @@ -128,7 +128,7 @@ github.com/urfave/cli # github.com/yusufpapurcu/wmi v1.2.4 ## explicit; go 1.16 github.com/yusufpapurcu/wmi -# golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c +# golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 ## explicit; go 1.22.0 golang.org/x/exp/constraints # golang.org/x/net v0.34.0 @@ -572,7 +572,7 @@ sigs.k8s.io/yaml/goyaml.v2 # k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.30.3 # k8s.io/kubectl => k8s.io/kubectl v0.30.3 # k8s.io/kubelet => k8s.io/kubelet v0.30.3 -# k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.30.9 +# k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.30.10 # k8s.io/metrics => k8s.io/metrics v0.30.3 # k8s.io/mount-utils => k8s.io/mount-utils v0.30.3 # k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.30.3