etcd-agent: ignore error when no file to rename

Fixes https://github.com/coreos/etcd/issues/4512.
When cluster fails before creation of log or data directory
the file does not exist and cannot be renamed. This skips such
error because there's no need to store empty logs in failure_archive.
This commit is contained in:
Gyu-Ho Lee 2016-02-12 16:37:04 -08:00
parent c15b2a5077
commit 205033d25f

View File

@ -194,7 +194,14 @@ func archiveLogAndDataDir(log string, datadir string) error {
return err
}
if err := os.Rename(log, path.Join(dir, log)); err != nil {
return err
if !os.IsNotExist(err) {
return err
}
}
return os.Rename(datadir, path.Join(dir, datadir))
if err := os.Rename(datadir, path.Join(dir, datadir)); err != nil {
if !os.IsNotExist(err) {
return err
}
}
return nil
}