-
Notifications
You must be signed in to change notification settings - Fork 67
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
Some combinations of wildcards inside alternates fail #50
Comments
I ran into a bug that may or may not be the same, and created a minimal reproduction. Short version is that |
I also ran into this in Bud where the following test was failing (in this case matching unexpectedly): func TestMatchSubdir(t *testing.T) {
is := is.New(t)
matcher, err := glob.Compile(`{generator/**.go,bud/internal/generator/*/**.go}`)
is.NoErr(err)
is.True(!matcher.Match("bud/internal/generator/generator.go"))
} I was able to fix this by manually expanding the globs into Then you can compile each one individually and create a matcher: // Comple
func Compile(pattern string) (Matcher, error) {
patterns, err := Expand(pattern)
if err != nil {
return nil, err
}
globs := make(globs, len(patterns))
for i, pattern := range patterns {
glob, err := glob.Compile(pattern)
if err != nil {
return nil, err
}
globs[i] = glob
}
return globs, nil
}
type globs []glob.Glob
func (globs globs) Match(path string) bool {
for _, glob := range globs {
if glob.Match(path) {
return true
}
}
return false
} |
This glob library is used for a critical bit of functionality in Telegraf -metric filtering. There appear to be a number of cases where it silently fails to match, and one which has caused us much grief recently involves multiple
*
wildcards inside a{ }
alternate construct.Telegraf is configured with a list of patterns for a
namepass/namedrop
function, and internally it composes the list into a single pattern with alternates. I've reduced our test case to one similar to the samples inglob_test.go
; here is the failing test surrounded by variations which all work:The result of running this test in current
master
branch is:This has become a huge problem for us, with huge numbers of metrics being sent to InfluxDB which over time overwhelm it (and post-hoc deletions are unusably slow).
The text was updated successfully, but these errors were encountered: