Skip to content

Commit d353b3a

Browse files
authored
Merge pull request #1 from jakirpatel/development
Fixed the bug with mount error.
2 parents 4de87c0 + 969f7e8 commit d353b3a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
"github.com/ContainX/docker-volume-netshare/netshare"
4+
"github.com/jakirpatel/docker-volume-netshare/netshare"
55
)
66

77
var VERSION string = ""

netshare/drivers/nfs.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"os"
66
"path/filepath"
77

8-
log "github.com/sirupsen/logrus"
98
"github.com/docker/go-plugins-helpers/volume"
9+
log "github.com/sirupsen/logrus"
1010
)
1111

1212
const (
@@ -55,13 +55,15 @@ func (n nfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
5555
}
5656
}
5757

58-
if n.mountm.HasMount(resolvedName) && n.mountm.Count(resolvedName) > 0 {
58+
if n.mountm.HasMount(resolvedName) {
5959
log.Infof("Using existing NFS volume mount: %s", hostdir)
6060
n.mountm.Increment(resolvedName)
6161
if err := run(fmt.Sprintf("grep -c %s /proc/mounts", hostdir)); err != nil {
6262
log.Infof("Existing NFS volume not mounted, force remount.")
6363
// maintain count
64-
n.mountm.Decrement(resolvedName)
64+
if n.mountm.Count(resolvedName) > 0 {
65+
n.mountm.Decrement(resolvedName)
66+
}
6567
} else {
6668
//n.mountm.Increment(resolvedName)
6769
return &volume.MountResponse{Mountpoint: hostdir}, nil
@@ -71,6 +73,9 @@ func (n nfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
7173
log.Infof("Mounting NFS volume %s on %s", source, hostdir)
7274

7375
if err := createDest(hostdir); err != nil {
76+
if n.mountm.Count(resolvedName) > 0 {
77+
n.mountm.Decrement(resolvedName)
78+
}
7479
return nil, err
7580
}
7681

@@ -81,13 +86,15 @@ func (n nfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
8186
n.mountm.Add(resolvedName, hostdir)
8287

8388
if err := n.mountVolume(resolvedName, source, hostdir, n.version); err != nil {
89+
n.mountm.Decrement(resolvedName)
8490
return nil, err
8591
}
8692

8793
if n.mountm.GetOption(resolvedName, ShareOpt) != "" && n.mountm.GetOptionAsBool(resolvedName, CreateOpt) {
8894
log.Infof("Mount: Share and Create options enabled - using %s as sub-dir mount", resolvedName)
8995
datavol := filepath.Join(hostdir, resolvedName)
9096
if err := createDest(filepath.Join(hostdir, resolvedName)); err != nil {
97+
n.mountm.Decrement(resolvedName)
9198
return nil, err
9299
}
93100
hostdir = datavol

netshare/netshare.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"syscall"
99
"context"
1010

11-
"github.com/ContainX/docker-volume-netshare/netshare/drivers"
11+
"github.com/jakirpatel/docker-volume-netshare/netshare/drivers"
1212
log "github.com/sirupsen/logrus"
1313
"github.com/docker/go-plugins-helpers/volume"
1414
"github.com/spf13/cobra"

0 commit comments

Comments
 (0)