@@ -26,7 +26,7 @@ import (
26
26
"strings"
27
27
"time"
28
28
29
- "github.com/sigma/go-inotify "
29
+ "github.com/fsnotify/fsnotify "
30
30
"k8s.io/klog"
31
31
32
32
"k8s.io/api/core/v1"
@@ -77,54 +77,47 @@ func (s *sourceFile) doWatch() error {
77
77
return & retryableError {"path does not exist, ignoring" }
78
78
}
79
79
80
- w , err := inotify .NewWatcher ()
80
+ w , err := fsnotify .NewWatcher ()
81
81
if err != nil {
82
82
return fmt .Errorf ("unable to create inotify: %v" , err )
83
83
}
84
84
defer w .Close ()
85
85
86
- err = w .AddWatch (s .path , inotify . IN_DELETE_SELF | inotify . IN_CREATE | inotify . IN_MOVED_TO | inotify . IN_MODIFY | inotify . IN_MOVED_FROM | inotify . IN_DELETE | inotify . IN_ATTRIB )
86
+ err = w .Add (s .path )
87
87
if err != nil {
88
88
return fmt .Errorf ("unable to create inotify for path %q: %v" , s .path , err )
89
89
}
90
90
91
91
for {
92
92
select {
93
- case event := <- w .Event :
94
- if err = s .produceWatchEvent (event ); err != nil {
93
+ case event := <- w .Events :
94
+ if err = s .produceWatchEvent (& event ); err != nil {
95
95
return fmt .Errorf ("error while processing inotify event (%+v): %v" , event , err )
96
96
}
97
- case err = <- w .Error :
97
+ case err = <- w .Errors :
98
98
return fmt .Errorf ("error while watching %q: %v" , s .path , err )
99
99
}
100
100
}
101
101
}
102
102
103
- func (s * sourceFile ) produceWatchEvent (e * inotify .Event ) error {
103
+ func (s * sourceFile ) produceWatchEvent (e * fsnotify .Event ) error {
104
104
// Ignore file start with dots
105
105
if strings .HasPrefix (filepath .Base (e .Name ), "." ) {
106
106
klog .V (4 ).Infof ("Ignored pod manifest: %s, because it starts with dots" , e .Name )
107
107
return nil
108
108
}
109
109
var eventType podEventType
110
110
switch {
111
- case (e .Mask & inotify .IN_ISDIR ) > 0 :
112
- klog .Errorf ("Not recursing into manifest path %q" , s .path )
113
- return nil
114
- case (e .Mask & inotify .IN_CREATE ) > 0 :
115
- eventType = podAdd
116
- case (e .Mask & inotify .IN_MOVED_TO ) > 0 :
111
+ case (e .Op & fsnotify .Create ) > 0 :
117
112
eventType = podAdd
118
- case (e .Mask & inotify . IN_MODIFY ) > 0 :
113
+ case (e .Op & fsnotify . Write ) > 0 :
119
114
eventType = podModify
120
- case (e .Mask & inotify . IN_ATTRIB ) > 0 :
115
+ case (e .Op & fsnotify . Chmod ) > 0 :
121
116
eventType = podModify
122
- case (e .Mask & inotify . IN_DELETE ) > 0 :
117
+ case (e .Op & fsnotify . Remove ) > 0 :
123
118
eventType = podDelete
124
- case (e .Mask & inotify . IN_MOVED_FROM ) > 0 :
119
+ case (e .Op & fsnotify . Rename ) > 0 :
125
120
eventType = podDelete
126
- case (e .Mask & inotify .IN_DELETE_SELF ) > 0 :
127
- return fmt .Errorf ("the watched path is deleted" )
128
121
default :
129
122
// Ignore rest events
130
123
return nil
0 commit comments