functional/agent: copy file, instead of renaming
To retain failure logs in CI testing. Signed-off-by: Gyuho Lee <leegyuho@amazon.com>release-3.5
parent
d1c7be24b0
commit
72e00cea3a
|
@ -15,6 +15,7 @@
|
|||
package agent
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -36,7 +37,8 @@ func archive(baseDir, etcdLogPath, dataDir string) error {
|
|||
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) {
|
||||
return err
|
||||
}
|
||||
|
@ -79,6 +81,25 @@ func getURLAndPort(addr string) (urlAddr *url.URL, port int, err error) {
|
|||
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 {
|
||||
// https://www.kernel.org/doc/Documentation/sysctl/vm.txt
|
||||
// https://github.com/torvalds/linux/blob/master/fs/drop_caches.c
|
||||
|
|
Loading…
Reference in New Issue