Skip to content

Commit

Permalink
Merge pull request #1 from jakirpatel/development
Browse files Browse the repository at this point in the history
Fixed the bug with mount error.
  • Loading branch information
jakirpatel authored Jun 8, 2018
2 parents 4de87c0 + 969f7e8 commit d353b3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/ContainX/docker-volume-netshare/netshare"
"github.com/jakirpatel/docker-volume-netshare/netshare"
)

var VERSION string = ""
Expand Down
13 changes: 10 additions & 3 deletions netshare/drivers/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"os"
"path/filepath"

log "github.com/sirupsen/logrus"
"github.com/docker/go-plugins-helpers/volume"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -55,13 +55,15 @@ func (n nfsDriver) Mount(r *volume.MountRequest) (*volume.MountResponse, error)
}
}

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

if err := createDest(hostdir); err != nil {
if n.mountm.Count(resolvedName) > 0 {
n.mountm.Decrement(resolvedName)
}
return nil, err
}

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

if err := n.mountVolume(resolvedName, source, hostdir, n.version); err != nil {
n.mountm.Decrement(resolvedName)
return nil, err
}

if n.mountm.GetOption(resolvedName, ShareOpt) != "" && n.mountm.GetOptionAsBool(resolvedName, CreateOpt) {
log.Infof("Mount: Share and Create options enabled - using %s as sub-dir mount", resolvedName)
datavol := filepath.Join(hostdir, resolvedName)
if err := createDest(filepath.Join(hostdir, resolvedName)); err != nil {
n.mountm.Decrement(resolvedName)
return nil, err
}
hostdir = datavol
Expand Down
2 changes: 1 addition & 1 deletion netshare/netshare.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"syscall"
"context"

"github.com/ContainX/docker-volume-netshare/netshare/drivers"
"github.com/jakirpatel/docker-volume-netshare/netshare/drivers"
log "github.com/sirupsen/logrus"
"github.com/docker/go-plugins-helpers/volume"
"github.com/spf13/cobra"
Expand Down

0 comments on commit d353b3a

Please sign in to comment.