Skip to content

Commit 4ad05ed

Browse files
committed
Merge pull request #13808 from Microsoft/10662-volumefixcompile
Windows: Fix PR13278 compile break
2 parents 969cb54 + 71eadd4 commit 4ad05ed

3 files changed

Lines changed: 36 additions & 32 deletions

File tree

daemon/volumes.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"path/filepath"
99
"strings"
1010

11-
"github.com/Sirupsen/logrus"
1211
"github.com/docker/docker/pkg/chrootarchive"
1312
"github.com/docker/docker/runconfig"
1413
"github.com/docker/docker/volume"
@@ -291,37 +290,6 @@ func (daemon *Daemon) verifyVolumesInfo(container *Container) error {
291290
return container.ToDisk()
292291
}
293292

294-
// migrateVolume moves the contents of a volume created pre Docker 1.7
295-
// to the location expected by the local driver. Steps:
296-
// 1. Save old directory that includes old volume's config json file.
297-
// 2. Move virtual directory with content to where the local driver expects it to be.
298-
// 3. Remove the backup of the old volume config.
299-
func (daemon *Daemon) migrateVolume(id, vfs string) error {
300-
volumeInfo := filepath.Join(daemon.root, defaultVolumesPathName, id)
301-
backup := filepath.Join(daemon.root, defaultVolumesPathName, id+".back")
302-
303-
var err error
304-
if err = os.Rename(volumeInfo, backup); err != nil {
305-
return err
306-
}
307-
defer func() {
308-
// Put old configuration back in place in case one of the next steps fails.
309-
if err != nil {
310-
os.Rename(backup, volumeInfo)
311-
}
312-
}()
313-
314-
if err = os.Rename(vfs, volumeInfo); err != nil {
315-
return err
316-
}
317-
318-
if err = os.RemoveAll(backup); err != nil {
319-
logrus.Errorf("Unable to remove volume info backup directory %s: %v", backup, err)
320-
}
321-
322-
return nil
323-
}
324-
325293
func createVolume(name, driverName string) (volume.Volume, error) {
326294
vd, err := getVolumeDriver(driverName)
327295
if err != nil {

daemon/volumes_linux.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/Sirupsen/logrus"
1112
"github.com/docker/docker/daemon/execdriver"
1213
"github.com/docker/docker/pkg/system"
1314
)
@@ -68,3 +69,34 @@ func (m mounts) Swap(i, j int) {
6869
func (m mounts) parts(i int) int {
6970
return len(strings.Split(filepath.Clean(m[i].Destination), string(os.PathSeparator)))
7071
}
72+
73+
// migrateVolume moves the contents of a volume created pre Docker 1.7
74+
// to the location expected by the local driver. Steps:
75+
// 1. Save old directory that includes old volume's config json file.
76+
// 2. Move virtual directory with content to where the local driver expects it to be.
77+
// 3. Remove the backup of the old volume config.
78+
func (daemon *Daemon) migrateVolume(id, vfs string) error {
79+
volumeInfo := filepath.Join(daemon.root, defaultVolumesPathName, id)
80+
backup := filepath.Join(daemon.root, defaultVolumesPathName, id+".back")
81+
82+
var err error
83+
if err = os.Rename(volumeInfo, backup); err != nil {
84+
return err
85+
}
86+
defer func() {
87+
// Put old configuration back in place in case one of the next steps fails.
88+
if err != nil {
89+
os.Rename(backup, volumeInfo)
90+
}
91+
}()
92+
93+
if err = os.Rename(vfs, volumeInfo); err != nil {
94+
return err
95+
}
96+
97+
if err = os.RemoveAll(backup); err != nil {
98+
logrus.Errorf("Unable to remove volume info backup directory %s: %v", backup, err)
99+
}
100+
101+
return nil
102+
}

daemon/volumes_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ func copyOwnership(source, destination string) error {
1212
func (container *Container) setupMounts() ([]execdriver.Mount, error) {
1313
return nil, nil
1414
}
15+
16+
func (daemon *Daemon) migrateVolume(id, vfs string) error {
17+
return nil
18+
}

0 commit comments

Comments
 (0)