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

Do not parse string of empty matchers #5980

Merged
merged 1 commit into from
Apr 21, 2022
Merged

Conversation

chaudum
Copy link
Contributor

@chaudum chaudum commented Apr 21, 2022

What this PR does / why we need it:

This fixes a bug in the index gateway when querying values for a label.
Since the gRPC handler for LabelValuesForMetricName in the index gateway
allows empty matchers in the LabelValuesForMetricNameRequest, we need to
check if the matchers string is an empty matcher ({}) before we parse
the string.

This bug was introduced with the index gateway api refactoring in #5892

Signed-off-by: Christian Haudum christian.haudum@gmail.com

Which issue(s) this PR fixes:

Fixes: #5965

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated
  • Is this an important fix or new feature? Add an entry in the CHANGELOG.md.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

This fixes a bug in the index gateway when querying values for a label.
Since the gRPC handler for LabelValuesForMetricName in the index gateway
allows empty matchers in the LabelValuesForMetricNameRequest, we need to
check if the matchers string is an empty matcher (`{}`) before we parse
the string.

This bug was introduced with the index gateway api refactoring in #5892

Fixes: #5965

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
@chaudum chaudum requested a review from a team as a code owner April 21, 2022 06:22
matchers, err = syntax.ParseMatchers(req.Matchers)
if err != nil {
return nil, err
}
}
names, err := g.indexQuerier.LabelValuesForMetricName(ctx, instanceID, req.From, req.Through, req.MetricName, req.LabelName, matchers...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope it's ok to pass empty []*labels.Matcher to g.indexQuerier.LabelValuesForMetricName when req.Matchers == syntax.EmptyMatchers

Also can you add a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index store checks for len(matchers):

if len(matchers) != 0 {
return c.labelValuesForMetricNameWithMatchers(ctx, userID, from, through, metricName, labelName, matchers...)
}

@kavirajk kavirajk merged commit 38e5e41 into main Apr 21, 2022
@kavirajk kavirajk deleted the chaudum/fix-empty-matchers branch April 21, 2022 06:53
chaudum added a commit that referenced this pull request Apr 21, 2022
This fixes a bug in the index gateway when querying values for a label.
Since the gRPC handler for LabelValuesForMetricName in the index gateway
allows empty matchers in the LabelValuesForMetricNameRequest, we need to
check if the matchers string is an empty matcher (`{}`) before we parse
the string.

This bug was introduced with the index gateway api refactoring in #5892

Fixes: #5965

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
chaudum added a commit that referenced this pull request Apr 21, 2022
This fixes a bug in the index gateway when querying values for a label.
Since the gRPC handler for LabelValuesForMetricName in the index gateway
allows empty matchers in the LabelValuesForMetricNameRequest, we need to
check if the matchers string is an empty matcher (`{}`) before we parse
the string.

This bug was introduced with the index gateway api refactoring in #5892

Fixes: #5965

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Index Gateway: Unable to handle GetChunkRefs/LabelValuesForMetricName with empty matchers
2 participants