From 07938f20fcc72e8688837abf4ba8693ee21ce7ba Mon Sep 17 00:00:00 2001 From: xu0o0 Date: Sat, 16 Sep 2023 05:55:02 +0800 Subject: [PATCH] fix incorrect use of fsnotify in configtls (#8439) **Link to tracking Issue:** #8438 --- .chloggen/fix-incorrect-use-of-fsnotify.yaml | 25 ++++++++++++++++++++ config/configtls/clientcasfilereloader.go | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .chloggen/fix-incorrect-use-of-fsnotify.yaml diff --git a/.chloggen/fix-incorrect-use-of-fsnotify.yaml b/.chloggen/fix-incorrect-use-of-fsnotify.yaml new file mode 100644 index 00000000000..a9b21921364 --- /dev/null +++ b/.chloggen/fix-incorrect-use-of-fsnotify.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) +component: configtls + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: fix incorrect use of fsnotify + +# One or more tracking issues or pull requests related to the change +issues: [8438] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/config/configtls/clientcasfilereloader.go b/config/configtls/clientcasfilereloader.go index 01cebc7af78..1ee9c72ef9f 100644 --- a/config/configtls/clientcasfilereloader.go +++ b/config/configtls/clientcasfilereloader.go @@ -112,7 +112,7 @@ func (r *clientCAsFileReloader) handleWatcherEvents() { // NOTE: k8s configmaps uses symlinks, we need this workaround. // original configmap file is removed. // SEE: https://martensson.io/go-fsnotify-and-kubernetes-configmaps/ - if event.Op == fsnotify.Remove || event.Op == fsnotify.Chmod { + if event.Has(fsnotify.Remove) || event.Has(fsnotify.Chmod) { // remove the watcher since the file is removed if err := r.watcher.Remove(event.Name); err != nil { r.lastReloadError = err @@ -123,7 +123,7 @@ func (r *clientCAsFileReloader) handleWatcherEvents() { } r.reload() } - if event.Op == fsnotify.Write { + if event.Has(fsnotify.Write) { r.reload() } }