mirror of https://github.com/docker/docs.git
				
				
				
			Fix issue reloading mount options on restart
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 <cpuguy83@gmail.com> (cherry picked from commit c560dd968600ebc9c1ff78f256ee93a6ded9a728) Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
		
							parent
							
								
									aaf3a81086
								
							
						
					
					
						commit
						70f0f7a20e
					
				|  | @ -88,7 +88,9 @@ func New(scope string, rootUID, rootGID int) (*Root, error) { | ||||||
| 			path:       r.DataPath(name), | 			path:       r.DataPath(name), | ||||||
| 		} | 		} | ||||||
| 		r.volumes[name] = v | 		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 { | 			if err := json.Unmarshal(b, v.opts); err != nil { | ||||||
| 				return nil, err | 				return nil, err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ package local | ||||||
| import ( | import ( | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"os" | 	"os" | ||||||
|  | 	"reflect" | ||||||
| 	"runtime" | 	"runtime" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"testing" | 	"testing" | ||||||
|  | @ -246,4 +247,18 @@ func TestCreateWithOpts(t *testing.T) { | ||||||
| 	if !mounted { | 	if !mounted { | ||||||
| 		t.Fatal("expected mount to still be active") | 		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") | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue