Skip to content

Commit

Permalink
Merge pull request moby#31265 from cyli/remove_swarm_subdirs
Browse files Browse the repository at this point in the history
Rather than remove the swarm directory and re-create, remove the subdirs
  • Loading branch information
cpuguy83 authored Mar 7, 2017
2 parents dd221a1 + 68506bd commit fd5f9d7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions daemon/cluster/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ func savePersistentState(root string, config nodeStartConfig) error {

func clearPersistentState(root string) error {
// todo: backup this data instead of removing?
if err := os.RemoveAll(root); err != nil {
// rather than delete the entire swarm directory, delete the contents in order to preserve the inode
// (for example, allowing it to be bind-mounted)
files, err := ioutil.ReadDir(root)
if err != nil {
return err
}
if err := os.MkdirAll(root, 0700); err != nil {
return err

for _, f := range files {
if err := os.RemoveAll(filepath.Join(root, f.Name())); err != nil {
return err
}
}

return nil
}

Expand Down

0 comments on commit fd5f9d7

Please sign in to comment.