mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Do not return err on symlink eval
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
949f2ca8cb
commit
b54305ae23
2 changed files with 78 additions and 3 deletions
|
@ -403,3 +403,77 @@ func TestDaemonKeyMigration(t *testing.T) {
|
|||
|
||||
logDone("daemon - key migration")
|
||||
}
|
||||
|
||||
// Simulate an older daemon (pre 1.3) coming up with volumes specified in containers
|
||||
// without corrosponding volume json
|
||||
func TestDaemonUpgradeWithVolumes(t *testing.T) {
|
||||
d := NewDaemon(t)
|
||||
|
||||
graphDir := filepath.Join(os.TempDir(), "docker-test")
|
||||
defer os.RemoveAll(graphDir)
|
||||
if err := d.StartWithBusybox("-g", graphDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
tmpDir := filepath.Join(os.TempDir(), "test")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
if out, err := d.Cmd("create", "-v", tmpDir+":/foo", "--name=test", "busybox"); err != nil {
|
||||
t.Fatal(err, out)
|
||||
}
|
||||
|
||||
if err := d.Stop(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Remove this since we're expecting the daemon to re-create it too
|
||||
if err := os.RemoveAll(tmpDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
configDir := filepath.Join(graphDir, "volumes")
|
||||
|
||||
if err := os.RemoveAll(configDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := d.Start("-g", graphDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
|
||||
t.Fatalf("expected volume path %s to exist but it does not", tmpDir)
|
||||
}
|
||||
|
||||
dir, err := ioutil.ReadDir(configDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(dir) == 0 {
|
||||
t.Fatalf("expected volumes config dir to contain data for new volume")
|
||||
}
|
||||
|
||||
// Now with just removing the volume config and not the volume data
|
||||
if err := d.Stop(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.RemoveAll(configDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := d.Start("-g", graphDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
dir, err = ioutil.ReadDir(configDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(dir) == 0 {
|
||||
t.Fatalf("expected volumes config dir to contain data for new volume")
|
||||
}
|
||||
|
||||
logDone("daemon - volumes from old(pre 1.3) daemon work")
|
||||
}
|
||||
|
|
|
@ -57,9 +57,10 @@ func (r *Repository) newVolume(path string, writable bool) (*Volume, error) {
|
|||
}
|
||||
path = filepath.Clean(path)
|
||||
|
||||
path, err = filepath.EvalSymlinks(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// Ignore the error here since the path may not exist
|
||||
// Really just want to make sure the path we are using is real(or non-existant)
|
||||
if cleanPath, err := filepath.EvalSymlinks(path); err == nil {
|
||||
path = cleanPath
|
||||
}
|
||||
|
||||
v := &Volume{
|
||||
|
|
Loading…
Reference in a new issue