-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Ignore chmod events on UI config watcher. #2254
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,16 +149,17 @@ func (sH *StaticAssetsHandler) watch() { | |
} | ||
continue | ||
} | ||
if event.Op&fsnotify.Write == fsnotify.Write || event.Op&fsnotify.Create == fsnotify.Create { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2 - I remember something about renaming in k8s, etc. which required watching the directory. And when watching the directory, there could be many other changes happening, although it's still strange that the user experience logs every 0.5s. By checking that the event is actually for the file name we want we can eliminate all other events in the dir. 3 - we can try with just adding the name check, although doing a full comparison on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did all except the content comparison, I don't think we need it at this point but if you think is good I can add it, as you said is a trivial thing to do. |
||
// this will catch events for all files inside the same directory, which is OK if we don't have many changes | ||
sH.options.Logger.Info("reloading UI config", zap.String("filename", sH.options.UIConfigPath)) | ||
|
||
// this will catch events for all files inside the same directory, which is OK if we don't have many changes | ||
sH.options.Logger.Info("reloading UI config", zap.String("filename", sH.options.UIConfigPath)) | ||
content, err := loadIndexBytes(sH.assetsFS.Open, sH.options) | ||
if err != nil { | ||
sH.options.Logger.Error("error while reloading the UI config", zap.Error(err)) | ||
} | ||
|
||
content, err := loadIndexBytes(sH.assetsFS.Open, sH.options) | ||
if err != nil { | ||
sH.options.Logger.Error("error while reloading the UI config", zap.Error(err)) | ||
sH.indexHTML.Store(content) | ||
} | ||
|
||
sH.indexHTML.Store(content) | ||
case err, ok := <-watcher.Errors: | ||
if !ok { | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L140: could we please refactor this nested
go func()
into a top function? There are 5 levels of indentation/nesting here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I separated the
go func()
into another function. That removes some indentation levels.