mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmstorage/transport: simplify setupTfss in order to prevent the possibility of nil tfs
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/534
This commit is contained in:
parent
e4cef1b678
commit
01719f4949
@ -874,19 +874,14 @@ var (
|
||||
func (ctx *vmselectRequestCtx) setupTfss() error {
|
||||
tfss := ctx.tfss[:0]
|
||||
for _, tagFilters := range ctx.sq.TagFilterss {
|
||||
if len(tfss) < cap(tfss) {
|
||||
tfss = tfss[:len(tfss)+1]
|
||||
} else {
|
||||
tfss = append(tfss, &storage.TagFilters{})
|
||||
}
|
||||
tfs := tfss[len(tfss)-1]
|
||||
tfs.Reset(ctx.sq.AccountID, ctx.sq.ProjectID)
|
||||
tfs := storage.NewTagFilters(ctx.sq.AccountID, ctx.sq.ProjectID)
|
||||
for i := range tagFilters {
|
||||
tf := &tagFilters[i]
|
||||
if err := tfs.Add(tf.Key, tf.Value, tf.IsNegative, tf.IsRegexp); err != nil {
|
||||
return fmt.Errorf("cannot parse tag filter %s: %s", tf, err)
|
||||
}
|
||||
}
|
||||
tfss = append(tfss, tfs)
|
||||
tfss = append(tfss, tfs.Finalize()...)
|
||||
}
|
||||
ctx.tfss = tfss
|
||||
|
Loading…
Reference in New Issue
Block a user