mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #31265 from cyli/remove_swarm_subdirs
Rather than remove the swarm directory and re-create, remove the subdirs
This commit is contained in:
commit
fd5f9d7941
1 changed files with 10 additions and 3 deletions
|
@ -38,12 +38,19 @@ func savePersistentState(root string, config nodeStartConfig) error {
|
||||||
|
|
||||||
func clearPersistentState(root string) error {
|
func clearPersistentState(root string) error {
|
||||||
// todo: backup this data instead of removing?
|
// 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
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue