Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch additional certificate events after write/create #334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func iNotifyCertMonitoring(watcher *fsnotify.Watcher, telemetryCfg *TelemetryCon
if testReadySignal != nil { // for testing only
testReadySignal <- 0
}

for {
select {
case event := <-watcher.Events:
Expand All @@ -285,9 +286,20 @@ func iNotifyCertMonitoring(watcher *fsnotify.Watcher, telemetryCfg *TelemetryCon
log.V(1).Infof("Inotify watcher has received event: %v", event)
if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Create == fsnotify.Create {
log.V(1).Infof("Cert File has been modified: %s", event.Name)
serverControlSignal <- ServerStart // let server know that a write/create event occurred
done <- true
return
// Continue reading events as a batch of events for the next 3 seconds
timer := time.NewTimer(3 * time.Second)
for {
select {
case event := <-watcher.Events:
if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Create == fsnotify.Create || event.Op&fsnotify.Remove == fsnotify.Remove || event.Op&fsnotify.Rename == fsnotify.Rename {
log.V(1).Infof("Additional events detected: %v", event)
}
case <-timer.C:
serverControlSignal <- ServerStart // let server know that a write/create event occurred
done <- true
return
}
}
}
if event.Op&fsnotify.Remove == fsnotify.Remove || event.Op&fsnotify.Rename == fsnotify.Rename {
log.V(1).Infof("Cert file has been deleted: %s", event.Name)
Expand Down
Loading