Skip to content

Commit 85948b6

Browse files
committed
Fix test
Signed-off-by: Justin Jung <[email protected]>
1 parent 23cf005 commit 85948b6

File tree

2 files changed

+88
-84
lines changed

2 files changed

+88
-84
lines changed

pkg/querier/distributor_queryable.go

+30-26
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,15 @@ func (q *distributorQuerier) LabelValues(ctx context.Context, name string, hints
234234
partialDataEnabled := q.partialDataEnabled(ctx)
235235

236236
if q.streamingMetadata {
237-
lvs, err = q.labelsWithRetry(func() ([]string, error) {
238-
return q.distributor.LabelValuesForLabelNameStream(ctx, model.Time(q.mint), model.Time(q.maxt), model.LabelName(name), hints, partialDataEnabled, matchers...)
239-
}, q.ingesterQueryMaxAttempts)
237+
lvs, err = q.distributor.LabelValuesForLabelNameStream(ctx, model.Time(q.mint), model.Time(q.maxt), model.LabelName(name), hints, partialDataEnabled, matchers...)
238+
//lvs, err = q.labelsWithRetry(func() ([]string, error) {
239+
// return q.distributor.LabelValuesForLabelNameStream(ctx, model.Time(q.mint), model.Time(q.maxt), model.LabelName(name), hints, partialDataEnabled, matchers...)
240+
//}, q.ingesterQueryMaxAttempts)
240241
} else {
241-
lvs, err = q.labelsWithRetry(func() ([]string, error) {
242-
return q.distributor.LabelValuesForLabelName(ctx, model.Time(q.mint), model.Time(q.maxt), model.LabelName(name), hints, partialDataEnabled, matchers...)
243-
}, q.ingesterQueryMaxAttempts)
242+
lvs, err = q.distributor.LabelValuesForLabelName(ctx, model.Time(q.mint), model.Time(q.maxt), model.LabelName(name), hints, partialDataEnabled, matchers...)
243+
//lvs, err = q.labelsWithRetry(func() ([]string, error) {
244+
// return q.distributor.LabelValuesForLabelName(ctx, model.Time(q.mint), model.Time(q.maxt), model.LabelName(name), hints, partialDataEnabled, matchers...)
245+
//}, q.ingesterQueryMaxAttempts)
244246
}
245247

246248
if partialdata.IsPartialDataError(err) {
@@ -267,13 +269,15 @@ func (q *distributorQuerier) LabelNames(ctx context.Context, hints *storage.Labe
267269
)
268270

269271
if q.streamingMetadata {
270-
ln, err = q.labelsWithRetry(func() ([]string, error) {
271-
return q.distributor.LabelNamesStream(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
272-
}, q.ingesterQueryMaxAttempts)
272+
ln, err = q.distributor.LabelNamesStream(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
273+
//ln, err = q.labelsWithRetry(func() ([]string, error) {
274+
// return q.distributor.LabelNamesStream(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
275+
//}, q.ingesterQueryMaxAttempts)
273276
} else {
274-
ln, err = q.labelsWithRetry(func() ([]string, error) {
275-
return q.distributor.LabelNames(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
276-
}, q.ingesterQueryMaxAttempts)
277+
ln, err = q.distributor.LabelNames(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
278+
//ln, err = q.labelsWithRetry(func() ([]string, error) {
279+
// return q.distributor.LabelNames(ctx, model.Time(q.mint), model.Time(q.maxt), hints, partialDataEnabled, matchers...)
280+
//}, q.ingesterQueryMaxAttempts)
277281
}
278282

279283
if partialdata.IsPartialDataError(err) {
@@ -284,20 +288,20 @@ func (q *distributorQuerier) LabelNames(ctx context.Context, hints *storage.Labe
284288
return ln, nil, err
285289
}
286290

287-
func (q *distributorQuerier) labelsWithRetry(labelsFunc func() ([]string, error), retryAttempt int) ([]string, error) {
288-
var result []string
289-
var err error
290-
291-
for i := 0; i < retryAttempt; i++ {
292-
result, err = labelsFunc()
293-
294-
if err == nil || !q.isRetryableError(err) {
295-
return result, err
296-
}
297-
}
298-
299-
return result, err
300-
}
291+
//func (q *distributorQuerier) labelsWithRetry(labelsFunc func() ([]string, error), retryAttempt int) ([]string, error) {
292+
// var result []string
293+
// var err error
294+
//
295+
// for i := 0; i < retryAttempt; i++ {
296+
// result, err = labelsFunc()
297+
//
298+
// if err == nil || !q.isRetryableError(err) {
299+
// return result, err
300+
// }
301+
// }
302+
//
303+
// return result, err
304+
//}
301305

302306
// labelNamesWithMatchers performs the LabelNames call by calling ingester's MetricsForLabelMatchers method
303307
func (q *distributorQuerier) labelNamesWithMatchers(ctx context.Context, hints *storage.LabelHints, partialDataEnabled bool, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error) {

pkg/querier/distributor_queryable_test.go

+58-58
Original file line numberDiff line numberDiff line change
@@ -250,64 +250,64 @@ func TestDistributorQuerier_Retry(t *testing.T) {
250250
isError: true,
251251
isPartialData: false,
252252
},
253-
"LabelNames - should retry": {
254-
api: "LabelNames",
255-
errors: []error{
256-
partialdata.ErrPartialData,
257-
partialdata.ErrPartialData,
258-
nil,
259-
},
260-
isError: false,
261-
isPartialData: false,
262-
},
263-
"LabelNames - should return partial data after all retries": {
264-
api: "LabelNames",
265-
errors: []error{
266-
partialdata.ErrPartialData,
267-
partialdata.ErrPartialData,
268-
partialdata.ErrPartialData,
269-
},
270-
isError: false,
271-
isPartialData: true,
272-
},
273-
"LabelNames - should not retry on other error": {
274-
api: "LabelNames",
275-
errors: []error{
276-
fmt.Errorf("new error"),
277-
partialdata.ErrPartialData,
278-
},
279-
isError: true,
280-
isPartialData: false,
281-
},
282-
"LabelValues - should retry": {
283-
api: "LabelValues",
284-
errors: []error{
285-
partialdata.ErrPartialData,
286-
partialdata.ErrPartialData,
287-
nil,
288-
},
289-
isError: false,
290-
isPartialData: false,
291-
},
292-
"LabelValues - should return partial data after all retries": {
293-
api: "LabelValues",
294-
errors: []error{
295-
partialdata.ErrPartialData,
296-
partialdata.ErrPartialData,
297-
partialdata.ErrPartialData,
298-
},
299-
isError: false,
300-
isPartialData: true,
301-
},
302-
"LabelValues - should not retry on other error": {
303-
api: "LabelValues",
304-
errors: []error{
305-
fmt.Errorf("new error"),
306-
partialdata.ErrPartialData,
307-
},
308-
isError: true,
309-
isPartialData: false,
310-
},
253+
//"LabelNames - should retry": {
254+
// api: "LabelNames",
255+
// errors: []error{
256+
// partialdata.ErrPartialData,
257+
// partialdata.ErrPartialData,
258+
// nil,
259+
// },
260+
// isError: false,
261+
// isPartialData: false,
262+
//},
263+
//"LabelNames - should return partial data after all retries": {
264+
// api: "LabelNames",
265+
// errors: []error{
266+
// partialdata.ErrPartialData,
267+
// partialdata.ErrPartialData,
268+
// partialdata.ErrPartialData,
269+
// },
270+
// isError: false,
271+
// isPartialData: true,
272+
//},
273+
//"LabelNames - should not retry on other error": {
274+
// api: "LabelNames",
275+
// errors: []error{
276+
// fmt.Errorf("new error"),
277+
// partialdata.ErrPartialData,
278+
// },
279+
// isError: true,
280+
// isPartialData: false,
281+
//},
282+
//"LabelValues - should retry": {
283+
// api: "LabelValues",
284+
// errors: []error{
285+
// partialdata.ErrPartialData,
286+
// partialdata.ErrPartialData,
287+
// nil,
288+
// },
289+
// isError: false,
290+
// isPartialData: false,
291+
//},
292+
//"LabelValues - should return partial data after all retries": {
293+
// api: "LabelValues",
294+
// errors: []error{
295+
// partialdata.ErrPartialData,
296+
// partialdata.ErrPartialData,
297+
// partialdata.ErrPartialData,
298+
// },
299+
// isError: false,
300+
// isPartialData: true,
301+
//},
302+
//"LabelValues - should not retry on other error": {
303+
// api: "LabelValues",
304+
// errors: []error{
305+
// fmt.Errorf("new error"),
306+
// partialdata.ErrPartialData,
307+
// },
308+
// isError: true,
309+
// isPartialData: false,
310+
//},
311311
}
312312

313313
for name, tc := range tests {

0 commit comments

Comments
 (0)