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

Fix includeconfigsource handling of multiple file writes #5803

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -705,5 +705,3 @@ replace github.com/pires/go-proxyproto v1.0.0 => github.com/peteski22/go-proxypr

// github.com/veraison/go-cose v1.2.0 doesn't exists but required by the latest github.com/Microsoft/hcsshim
replace github.com/veraison/go-cose v1.2.0 => github.com/veraison/go-cose v1.1.1

replace github.com/fsnotify/fsnotify v1.8.0 => github.com/fsnotify/fsnotify v1.7.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
Expand Down
25 changes: 25 additions & 0 deletions internal/configsource/includeconfigsource/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Splunk, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package includeconfigsource

import (
"testing"

"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
goleak.VerifyTestMain(m)
}
1 change: 0 additions & 1 deletion internal/configsource/includeconfigsource/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func (is *includeConfigSource) watchFile(file string, watcherFunc confmap.Watche
}
if event.Op&fsnotify.Write == fsnotify.Write {
watcherFunc(&confmap.ChangeEvent{Error: nil})
return
}
case watcherErr, ok := <-is.watcher.Errors:
if !ok {
Expand Down
8 changes: 7 additions & 1 deletion internal/configsource/includeconfigsource/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ func TestIncludeConfigSource_WatchFileUpdate(t *testing.T) {

// Perform initial retrieve
watchChannel := make(chan *confmap.ChangeEvent, 1)
watchDone := make(chan struct{}, 1)
ctx := context.Background()
r, err := s.Retrieve(ctx, dst, nil, func(event *confmap.ChangeEvent) {
watchChannel <- event
t.Log(event)
select {
case watchChannel <- event:
case <-watchDone:
}
})
require.NoError(t, err)
require.NotNil(t, r)
Expand All @@ -141,6 +146,7 @@ func TestIncludeConfigSource_WatchFileUpdate(t *testing.T) {
require.NoError(t, os.WriteFile(dst, []byte("val2"), 0600))

ce := <-watchChannel
watchDone <- struct{}{}
assert.NoError(t, ce.Error)
require.NoError(t, r.Close(context.Background()))

Expand Down
Loading