mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00: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
1 changed files with 2 additions and 7 deletions
|
@ -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 a new issue