Skip to content

Commit 6e3a460

Browse files
authored
Merge pull request #1527 from iltyty/fix-nas-mounter
Fix incorrect nas mounter issue
2 parents 5be8fbb + 79a3af5 commit 6e3a460

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

pkg/nas/csi_agent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type CSIAgent struct {
1616

1717
func NewCSIAgent(socketPath string) *CSIAgent {
1818
config := &internal.NodeConfig{
19+
AgentMode: true,
1920
EnablePortCheck: true,
2021
MountProxySocket: socketPath,
2122
CNFSGetter: unsupportedCNFSGetter{},

pkg/nas/internal/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type NodeConfig struct {
8686

8787
// path of mount proxy socket
8888
MountProxySocket string
89+
AgentMode bool
8990

9091
// clients for kubernetes
9192
KubeClient kubernetes.Interface

pkg/nas/mounter.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ func (m *NasMounter) Mount(source string, target string, fstype string, options
3232
return err
3333
}
3434

35-
func newNasMounter() mountutils.Interface {
35+
func newNasMounter(agentMode bool) mountutils.Interface {
3636
inner := mountutils.NewWithoutSystemd("")
37-
return &NasMounter{
37+
m := &NasMounter{
3838
Interface: inner,
3939
alinasMounter: inner,
4040
}
41+
if !agentMode {
42+
m.alinasMounter = mounter.NewConnectorMounter(inner, "")
43+
}
44+
return m
4145
}
4246

4347
func newNasMounterWithProxy(socketPath string) mountutils.Interface {

pkg/nas/mounter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (m *errorMockMounter) Mount(source string, target string, fstype string, op
2525
}
2626

2727
func TestNewNasMounter(t *testing.T) {
28-
actual := newNasMounter()
28+
actual := newNasMounter(true)
2929
assert.NotNil(t, actual)
3030
}
3131

pkg/nas/nodeserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func newNodeServer(config *internal.NodeConfig) *nodeServer {
7070
},
7171
}
7272
if config.MountProxySocket == "" {
73-
ns.mounter = newNasMounter()
73+
ns.mounter = newNasMounter(ns.config.AgentMode)
7474
} else {
7575
ns.recorder = utils.NewEventRecorder()
7676
ns.mounter = newNasMounterWithProxy(config.MountProxySocket)

0 commit comments

Comments
 (0)