mirror of https://github.com/k3s-io/k3s
Merge pull request #60962 from technicianted/flex_race_fix
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Added missing error check that could cause kubelet to crash **What this PR does / why we need it**: Adds missing error check. An error can happen due to a race condition when watched files change, or become inaccessible. This can happen if a file was added to the driver directory then quickly removed, in which case the callback will be called with non-nil `err` and nil `info`, which is not checked, causing kubelet to crash. **Which issue(s) this PR fixes**: Fixes #60861 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/6/head
commit
6571be1311
|
@ -176,7 +176,7 @@ func (prober *flexVolumeProber) updateProbeNeeded() {
|
||||||
// on its parent directory.
|
// on its parent directory.
|
||||||
func (prober *flexVolumeProber) addWatchRecursive(filename string) error {
|
func (prober *flexVolumeProber) addWatchRecursive(filename string) error {
|
||||||
addWatch := func(path string, info os.FileInfo, err error) error {
|
addWatch := func(path string, info os.FileInfo, err error) error {
|
||||||
if info.IsDir() {
|
if err == nil && info.IsDir() {
|
||||||
if err := prober.watcher.AddWatch(path); err != nil {
|
if err := prober.watcher.AddWatch(path); err != nil {
|
||||||
glog.Errorf("Error recursively adding watch: %v", err)
|
glog.Errorf("Error recursively adding watch: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue