mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
functional/agent: copy file, instead of renaming
To retain failure logs in CI testing. Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
This commit is contained in:
parent
d1c7be24b0
commit
72e00cea3a
@ -15,6 +15,7 @@
|
|||||||
package agent
|
package agent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@ -36,7 +37,8 @@ func archive(baseDir, etcdLogPath, dataDir string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Rename(etcdLogPath, filepath.Join(dir, "etcd.log")); err != nil {
|
dst := filepath.Join(dir, "etcd.log")
|
||||||
|
if err := copyFile(etcdLogPath, dst); err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -79,6 +81,25 @@ func getURLAndPort(addr string) (urlAddr *url.URL, port int, err error) {
|
|||||||
return urlAddr, port, err
|
return urlAddr, port, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func copyFile(src, dst string) error {
|
||||||
|
f, err := os.Open(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
w, err := os.Create(dst)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer w.Close()
|
||||||
|
|
||||||
|
if _, err = io.Copy(w, f); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return w.Sync()
|
||||||
|
}
|
||||||
|
|
||||||
func cleanPageCache() error {
|
func cleanPageCache() error {
|
||||||
// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
|
// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
|
||||||
// https://github.com/torvalds/linux/blob/master/fs/drop_caches.c
|
// https://github.com/torvalds/linux/blob/master/fs/drop_caches.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user