From 2985077c3591b625c3384d189ae6d4e00ffb423b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 23 Sep 2020 22:46:24 +0300 Subject: [PATCH 1/2] all: consistently use "%w" formatting in fmt.Errorf for wrapped errors --- app/vmalert/config/config.go | 2 +- lib/promscrape/discovery/ec2/api_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/vmalert/config/config.go b/app/vmalert/config/config.go index f027dad59..cd40af7af 100644 --- a/app/vmalert/config/config.go +++ b/app/vmalert/config/config.go @@ -41,7 +41,7 @@ func (g *Group) UnmarshalYAML(unmarshal func(interface{}) error) error { } b, err := yaml.Marshal(g) if err != nil { - return fmt.Errorf("failed to marshal group configuration for checksum: %s", err) + return fmt.Errorf("failed to marshal group configuration for checksum: %w", err) } h := md5.New() h.Write(b) diff --git a/lib/promscrape/discovery/ec2/api_test.go b/lib/promscrape/discovery/ec2/api_test.go index a37c33ce5..b067880b1 100644 --- a/lib/promscrape/discovery/ec2/api_test.go +++ b/lib/promscrape/discovery/ec2/api_test.go @@ -114,7 +114,7 @@ func TestParseARNCredentialsSuccess(t *testing.T) { func mustParseRFC3339(s string) time.Time { expTime, err := time.Parse(time.RFC3339, s) if err != nil { - panic(fmt.Errorf("unexpected error when parsing time from %q: %s", s, err)) + panic(fmt.Errorf("unexpected error when parsing time from %q: %w", s, err)) } return expTime } From c584aece388fa46cd2eecd6080fdd9e70d84325e Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 23 Sep 2020 23:01:29 +0300 Subject: [PATCH 2/2] app/vmselect/promql: properly limit implicitly set rollup window to `-search.maxStalenessInterval` Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/784 --- app/vmselect/promql/rollup.go | 5 +++++ app/vmselect/promql/rollup_test.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index d6351e523..6d612fee9 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -474,6 +474,11 @@ func (rc *rollupConfig) doInternal(dstValues []float64, tsm *timeseriesMap, valu window := rc.Window if window <= 0 { window = rc.Step + if rc.LookbackDelta > 0 && window > rc.LookbackDelta { + // Implicitly set window exceeds -search.maxStalenessInterval, so limit it to -search.maxStalenessInterval + // according to https://github.com/VictoriaMetrics/VictoriaMetrics/issues/784 + window = rc.LookbackDelta + } } if rc.MayAdjustWindow && window < maxPrevInterval { window = maxPrevInterval diff --git a/app/vmselect/promql/rollup_test.go b/app/vmselect/promql/rollup_test.go index c75626f45..d698d8c8e 100644 --- a/app/vmselect/promql/rollup_test.go +++ b/app/vmselect/promql/rollup_test.go @@ -645,7 +645,7 @@ func TestRollupFuncsLookbackDelta(t *testing.T) { } rc.Timestamps = getTimestamps(rc.Start, rc.End, rc.Step) values := rc.Do(nil, testValues, testTimestamps) - valuesExpected := []float64{99, nan, 44, nan, 32, 34, nan} + valuesExpected := []float64{12, nan, nan, nan, 34, 34, nan} timestampsExpected := []int64{80, 90, 100, 110, 120, 130, 140} testRowsEqual(t, values, rc.Timestamps, valuesExpected, timestampsExpected) })