Skip to content

Commit

Permalink
refactor(utils): move is mount read only function to common lib
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 7394

Signed-off-by: Jack Lin <[email protected]>
  • Loading branch information
ChanYiLin authored and innobead committed Mar 7, 2024
1 parent ddbcfa3 commit 6e921c6
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 110 deletions.
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,18 @@ replace (
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-20240305104227-2dc630b0df92
github.com/longhorn/go-common-libs v0.0.0-20240307063052-6e77996eda29
github.com/mitchellh/go-ps v1.0.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/urfave/cli v1.22.14
golang.org/x/net v0.22.0
golang.org/x/sys v0.18.0
google.golang.org/grpc v1.62.0
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
k8s.io/kubernetes v1.29.2
k8s.io/mount-utils v0.29.2
Expand All @@ -54,6 +52,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/opencontainers/selinux v1.11.0 // indirect
Expand Down
77 changes: 9 additions & 68 deletions go.sum

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions pkg/server/share_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/longhorn/longhorn-share-manager/pkg/server/nfs"
"github.com/longhorn/longhorn-share-manager/pkg/types"
"github.com/longhorn/longhorn-share-manager/pkg/volume"

commonUtils "github.com/longhorn/go-common-libs/utils"
)

const waitBetweenChecks = time.Second * 5
Expand Down Expand Up @@ -246,7 +248,7 @@ func (m *ShareManager) hasHealthyVolume() error {
mounter := mount.New("")
mountPoints, _ := mounter.List()
for _, mp := range mountPoints {
if mp.Path == mountPath && isMountPointReadOnly(mp) {
if mp.Path == mountPath && commonUtils.IsMountPointReadOnly(mp) {
return fmt.Errorf(ReadOnlyErr, mountPath)
}
}
Expand Down Expand Up @@ -279,12 +281,3 @@ func (m *ShareManager) ShareIsExported() bool {
func (m *ShareManager) Shutdown() {
m.shutdown()
}

func isMountPointReadOnly(mp mount.MountPoint) bool {
for _, opt := range mp.Opts {
if opt == "ro" {
return true
}
}
return false
}
1 change: 1 addition & 0 deletions vendor/github.com/longhorn/go-common-libs/io/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vendor/github.com/longhorn/go-common-libs/types/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/longhorn/go-common-libs/utils/mount.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/google.golang.org/grpc/clientconn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions vendor/google.golang.org/grpc/internal/transport/transport.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/google.golang.org/grpc/resolver/resolver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/google.golang.org/grpc/resolver_wrapper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 35 additions & 19 deletions vendor/google.golang.org/grpc/rpc_util.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions vendor/google.golang.org/grpc/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/google.golang.org/grpc/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ github.com/google/fscrypt/util
# github.com/google/uuid v1.6.0
## explicit
github.com/google/uuid
# github.com/longhorn/go-common-libs v0.0.0-20240305104227-2dc630b0df92
# github.com/longhorn/go-common-libs v0.0.0-20240307063052-6e77996eda29
## explicit; go 1.21
github.com/longhorn/go-common-libs/exec
github.com/longhorn/go-common-libs/io
Expand Down Expand Up @@ -92,7 +92,7 @@ golang.org/x/text/unicode/norm
# google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80
## explicit; go 1.19
google.golang.org/genproto/googleapis/rpc/status
# google.golang.org/grpc v1.62.0
# google.golang.org/grpc v1.62.1
## explicit; go 1.19
google.golang.org/grpc
google.golang.org/grpc/attributes
Expand Down

0 comments on commit 6e921c6

Please sign in to comment.