Merge pull request #1381 from Random-Liu/fix-watch-error
Continue watching other sub directories when there is watch error.
This commit is contained in:
commit
510e6e8bfd
@ -19,6 +19,7 @@ package raw
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -133,9 +134,15 @@ func (self *rawContainerWatcher) watchDirectory(dir string, containerName string
|
|||||||
}
|
}
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
if entry.IsDir() {
|
if entry.IsDir() {
|
||||||
// TODO(vmarmol): We don't have to fail here, maybe we can recover and try to get as many registrations as we can.
|
entryPath := path.Join(dir, entry.Name())
|
||||||
_, err = self.watchDirectory(path.Join(dir, entry.Name()), path.Join(containerName, entry.Name()))
|
_, err = self.watchDirectory(entryPath, path.Join(containerName, entry.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
glog.Errorf("Failed to watch directory %q: %v", entryPath, err)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// The directory may have been removed before watching. Try to watch the other
|
||||||
|
// subdirectories. (https://github.com/kubernetes/kubernetes/issues/28997)
|
||||||
|
continue
|
||||||
|
}
|
||||||
return alreadyWatching, err
|
return alreadyWatching, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user