Skip to content

Commit

Permalink
Fix issue reloading mount options on restart
Browse files Browse the repository at this point in the history
On daemon restart the local volume driver will read options that it
persisted to disk, however it was reading an incorrect path, causing
volume options to be silently ignored after a daemon restart.

Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed Aug 2, 2016
1 parent ccbdc16 commit c560dd9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion volume/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func New(scope string, rootUID, rootGID int) (*Root, error) {
path: r.DataPath(name),
}
r.volumes[name] = v
if b, err := ioutil.ReadFile(filepath.Join(name, "opts.json")); err == nil {
optsFilePath := filepath.Join(rootDirectory, name, "opts.json")
if b, err := ioutil.ReadFile(optsFilePath); err == nil {
v.opts = &optsConfig{}
if err := json.Unmarshal(b, v.opts); err != nil {
return nil, err
}
Expand Down
15 changes: 15 additions & 0 deletions volume/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package local
import (
"io/ioutil"
"os"
"reflect"
"runtime"
"strings"
"testing"
Expand Down Expand Up @@ -246,4 +247,18 @@ func TestCreateWithOpts(t *testing.T) {
if !mounted {
t.Fatal("expected mount to still be active")
}

r, err = New(rootDir, 0, 0)
if err != nil {
t.Fatal(err)
}

v2, exists := r.volumes["test"]
if !exists {
t.Fatal("missing volume on restart")
}

if !reflect.DeepEqual(v.opts, v2.opts) {
t.Fatal("missing volume options on restart")
}
}

0 comments on commit c560dd9

Please sign in to comment.