kubelet: upgrade sourceFile to use fsnotify

Mitigate some flakes for deleted watch directories and use the
maintained fsnotify package.
This commit is contained in:
Ryan Phillips
2019-02-04 11:44:01 -06:00
parent ace0bde081
commit 4000ef006c
3 changed files with 14 additions and 22 deletions

View File

@@ -22,7 +22,6 @@ import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"sync"
"testing"
@@ -428,7 +427,7 @@ func writeFile(filename string, data []byte) error {
func changeFileName(dir, from, to string, t *testing.T) {
fromPath := filepath.Join(dir, from)
toPath := filepath.Join(dir, to)
if err := exec.Command("mv", fromPath, toPath).Run(); err != nil {
if err := os.Rename(fromPath, toPath); err != nil {
t.Errorf("Fail to change file name: %s", err)
}
}