thanos-io / thanos

Highly available Prometheus setup with long term storage capabilities. A CNCF Incubating project.
https://thanos.io
Apache License 2.0
13.13k stars 2.1k forks source link

Fix store debug matchers panic on regex matcher #7903

Closed yeya24 closed 1 week ago

yeya24 commented 1 week ago

Changes

Fixes https://github.com/thanos-io/thanos/issues/7676

ParseMetricSelector tries to copy label matchers but there is a new field re for the underlying regex and it is not copied, causing panic when calling Matches.

    for i, lm := range vs.LabelMatchers {
        matchers[i] = &labels.Matcher{
            Type:  lm.Type,
            Name:  lm.Name,
            Value: lm.Value,
        }
    }

Verification

Added a simple unit test. Without the change in this PR the test will panic when calling Matches.