From 6a666a563d43453b63e9ad220c0d4c8604533523 Mon Sep 17 00:00:00 2001 From: "Bryan A. S." Date: Mon, 18 Nov 2024 00:25:44 -0300 Subject: [PATCH] prometheus: update to 3.0.1. --- .../patches/TestDropOldTimeSeries.patch | 21 + .../TestOOOHeadChunkReader_Chunk.patch | 454 ++++++++++++++++++ .../prometheus/patches/atomic-alignment.patch | 22 + .../patches/promql-topk-bottomk.patch | 77 +++ .../patches/really_large_histograms.patch | 27 ++ srcpkgs/prometheus/template | 18 +- 6 files changed, 614 insertions(+), 5 deletions(-) create mode 100644 srcpkgs/prometheus/patches/TestDropOldTimeSeries.patch create mode 100644 srcpkgs/prometheus/patches/TestOOOHeadChunkReader_Chunk.patch create mode 100644 srcpkgs/prometheus/patches/atomic-alignment.patch create mode 100644 srcpkgs/prometheus/patches/promql-topk-bottomk.patch create mode 100644 srcpkgs/prometheus/patches/really_large_histograms.patch diff --git a/srcpkgs/prometheus/patches/TestDropOldTimeSeries.patch b/srcpkgs/prometheus/patches/TestDropOldTimeSeries.patch new file mode 100644 index 00000000000000..d78836c3201deb --- /dev/null +++ b/srcpkgs/prometheus/patches/TestDropOldTimeSeries.patch @@ -0,0 +1,21 @@ +commit 5935d82988b6f4d36ffc7eaf1a954d662d35e837 +Author: Joel Beckmeyer +Date: Mon Dec 16 08:41:50 2024 -0500 + + fix TestDropOldTimeSeries on 32-bit + + Signed-off-by: Joel Beckmeyer + +diff --git a/storage/remote/queue_manager_test.go b/storage/remote/queue_manager_test.go +index 4b7c5a4e9..2dba17832 100644 +--- a/storage/remote/queue_manager_test.go ++++ b/storage/remote/queue_manager_test.go +@@ -2073,7 +2073,7 @@ func createTimeseriesWithOldSamples(numSamples, numSeries int, extraLabels ...la + for j := 0; j < numSamples/2; j++ { + sample := record.RefSample{ + Ref: chunks.HeadSeriesRef(i), +- T: int64(int(time.Now().UnixMilli()) + j), ++ T: time.Now().UnixMilli() + int64(j), + V: float64(i), + } + samples = append(samples, sample) diff --git a/srcpkgs/prometheus/patches/TestOOOHeadChunkReader_Chunk.patch b/srcpkgs/prometheus/patches/TestOOOHeadChunkReader_Chunk.patch new file mode 100644 index 00000000000000..08dec1b1e5f712 --- /dev/null +++ b/srcpkgs/prometheus/patches/TestOOOHeadChunkReader_Chunk.patch @@ -0,0 +1,454 @@ +commit 08beee52a2fd1163834e2a35e608e37aa2ac4e45 +Author: Joel Beckmeyer +Date: Sun Dec 15 17:53:36 2024 -0500 + + fix TestOOOHeadChunkReader_Chunk on 32-bit + + Signed-off-by: Joel Beckmeyer + +diff --git a/scrape/manager_test.go b/scrape/manager_test.go +index c3544f634..086727d50 100644 +--- a/scrape/manager_test.go ++++ b/scrape/manager_test.go +@@ -915,7 +915,7 @@ func findSamplesForMetric(floats []floatSample, metricName string) (ret []floatS + // generateTestHistogram generates the same thing as tsdbutil.GenerateTestHistogram, + // but in the form of dto.Histogram. + func generateTestHistogram(i int) *dto.Histogram { +- helper := tsdbutil.GenerateTestHistogram(i) ++ helper := tsdbutil.GenerateTestHistogram(int64(i)) + h := &dto.Histogram{} + h.SampleCount = proto.Uint64(helper.Count) + h.SampleSum = proto.Float64(helper.Sum) +diff --git a/storage/merge_test.go b/storage/merge_test.go +index b145743c8..9cbfdaf4a 100644 +--- a/storage/merge_test.go ++++ b/storage/merge_test.go +@@ -385,13 +385,13 @@ func TestMergeChunkQuerierWithNoVerticalChunkSeriesMerger(t *testing.T) { + } + + func histogramSample(ts int64, hint histogram.CounterResetHint) hSample { +- h := tsdbutil.GenerateTestHistogram(int(ts + 1)) ++ h := tsdbutil.GenerateTestHistogram(ts + 1) + h.CounterResetHint = hint + return hSample{t: ts, h: h} + } + + func floatHistogramSample(ts int64, hint histogram.CounterResetHint) fhSample { +- fh := tsdbutil.GenerateTestFloatHistogram(int(ts + 1)) ++ fh := tsdbutil.GenerateTestFloatHistogram(ts + 1) + fh.CounterResetHint = hint + return fhSample{t: ts, fh: fh} + } +diff --git a/tsdb/db_test.go b/tsdb/db_test.go +index 50f50a3a2..b29731c56 100644 +--- a/tsdb/db_test.go ++++ b/tsdb/db_test.go +@@ -4100,7 +4100,7 @@ func TestOOOWALWrite(t *testing.T) { + }, + "integer histogram": { + appendSample: func(app storage.Appender, l labels.Labels, mins int64) (storage.SeriesRef, error) { +- seriesRef, err := app.AppendHistogram(0, l, minutes(mins), tsdbutil.GenerateTestHistogram(int(mins)), nil) ++ seriesRef, err := app.AppendHistogram(0, l, minutes(mins), tsdbutil.GenerateTestHistogram(mins), nil) + require.NoError(t, err) + return seriesRef, nil + }, +@@ -4191,7 +4191,7 @@ func TestOOOWALWrite(t *testing.T) { + }, + "float histogram": { + appendSample: func(app storage.Appender, l labels.Labels, mins int64) (storage.SeriesRef, error) { +- seriesRef, err := app.AppendHistogram(0, l, minutes(mins), nil, tsdbutil.GenerateTestFloatHistogram(int(mins))) ++ seriesRef, err := app.AppendHistogram(0, l, minutes(mins), nil, tsdbutil.GenerateTestFloatHistogram(mins)) + require.NoError(t, err) + return seriesRef, nil + }, +@@ -4735,12 +4735,12 @@ func TestMultipleEncodingsCommitOrder(t *testing.T) { + return sample{t: ts, f: float64(ts)} + } + if valType == chunkenc.ValHistogram { +- h := tsdbutil.GenerateTestHistogram(int(ts)) ++ h := tsdbutil.GenerateTestHistogram(ts) + _, err := app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) + require.NoError(t, err) + return sample{t: ts, h: h} + } +- fh := tsdbutil.GenerateTestFloatHistogram(int(ts)) ++ fh := tsdbutil.GenerateTestFloatHistogram(ts) + _, err := app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, nil, fh) + require.NoError(t, err) + return sample{t: ts, fh: fh} +@@ -5426,37 +5426,37 @@ func TestQuerierOOOQuery(t *testing.T) { + }, + "integer histogram": { + appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { +- h := tsdbutil.GenerateTestHistogram(int(ts)) ++ h := tsdbutil.GenerateTestHistogram(ts) + if counterReset { + h.CounterResetHint = histogram.CounterReset + } + return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) + }, + sampleFunc: func(ts int64) chunks.Sample { +- return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} ++ return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} + }, + }, + "float histogram": { + appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { +- fh := tsdbutil.GenerateTestFloatHistogram(int(ts)) ++ fh := tsdbutil.GenerateTestFloatHistogram(ts) + if counterReset { + fh.CounterResetHint = histogram.CounterReset + } + return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, nil, fh) + }, + sampleFunc: func(ts int64) chunks.Sample { +- return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} ++ return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} + }, + }, + "integer histogram counter resets": { + // Adding counter reset to all histograms means each histogram will have its own chunk. + appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { +- h := tsdbutil.GenerateTestHistogram(int(ts)) ++ h := tsdbutil.GenerateTestHistogram(ts) + h.CounterResetHint = histogram.CounterReset // For this scenario, ignore the counterReset argument. + return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) + }, + sampleFunc: func(ts int64) chunks.Sample { +- return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} ++ return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} + }, + }, + } +@@ -5742,37 +5742,37 @@ func TestChunkQuerierOOOQuery(t *testing.T) { + }, + "integer histogram": { + appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { +- h := tsdbutil.GenerateTestHistogram(int(ts)) ++ h := tsdbutil.GenerateTestHistogram(ts) + if counterReset { + h.CounterResetHint = histogram.CounterReset + } + return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) + }, + sampleFunc: func(ts int64) chunks.Sample { +- return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} ++ return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} + }, + }, + "float histogram": { + appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { +- fh := tsdbutil.GenerateTestFloatHistogram(int(ts)) ++ fh := tsdbutil.GenerateTestFloatHistogram(ts) + if counterReset { + fh.CounterResetHint = histogram.CounterReset + } + return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, nil, fh) + }, + sampleFunc: func(ts int64) chunks.Sample { +- return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} ++ return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} + }, + }, + "integer histogram counter resets": { + // Adding counter reset to all histograms means each histogram will have its own chunk. + appendFunc: func(app storage.Appender, ts int64, counterReset bool) (storage.SeriesRef, error) { +- h := tsdbutil.GenerateTestHistogram(int(ts)) ++ h := tsdbutil.GenerateTestHistogram(ts) + h.CounterResetHint = histogram.CounterReset // For this scenario, ignore the counterReset argument. + return app.AppendHistogram(0, labels.FromStrings("foo", "bar1"), ts, h, nil) + }, + sampleFunc: func(ts int64) chunks.Sample { +- return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} ++ return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} + }, + }, + "integer histogram with recode": { +@@ -6671,7 +6671,7 @@ func TestOOOHistogramCompactionWithCounterResets(t *testing.T) { + app := db.Appender(context.Background()) + tsMs := ts * time.Minute.Milliseconds() + if floatHistogram { +- h := tsdbutil.GenerateTestFloatHistogram(val) ++ h := tsdbutil.GenerateTestFloatHistogram(int64(val)) + h.CounterResetHint = hint + _, err = app.AppendHistogram(0, l, tsMs, nil, h) + require.NoError(t, err) +@@ -6679,7 +6679,7 @@ func TestOOOHistogramCompactionWithCounterResets(t *testing.T) { + return sample{t: tsMs, fh: h.Copy()} + } + +- h := tsdbutil.GenerateTestHistogram(val) ++ h := tsdbutil.GenerateTestHistogram(int64(val)) + h.CounterResetHint = hint + _, err = app.AppendHistogram(0, l, tsMs, h, nil) + require.NoError(t, err) +diff --git a/tsdb/head_test.go b/tsdb/head_test.go +index cc9daa97f..2f5fe0f55 100644 +--- a/tsdb/head_test.go ++++ b/tsdb/head_test.go +@@ -4732,7 +4732,7 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) { + + // OOO histogram + for i := 1; i <= 5; i++ { +- appendHistogram(100+int64(i), tsdbutil.GenerateTestHistogram(1000+i)) ++ appendHistogram(100+int64(i), tsdbutil.GenerateTestHistogram(1000+int64(i))) + } + // Nothing mmapped yet. + checkOOOExpCounterResetHeader() +@@ -4820,7 +4820,7 @@ func TestOOOHistogramCounterResetHeaders(t *testing.T) { + appendHistogram(300, tsdbutil.SetHistogramCounterReset(tsdbutil.GenerateTestHistogram(3000))) + + for i := 1; i <= 4; i++ { +- appendHistogram(300+int64(i), tsdbutil.GenerateTestHistogram(3000+i)) ++ appendHistogram(300+int64(i), tsdbutil.GenerateTestHistogram(3000+int64(i))) + } + + // One mmapped chunk with (ts, val) [(300, 3000), (301, 3001), (302, 3002), (303, 3003), (350, 4000)]. +diff --git a/tsdb/ooo_head_test.go b/tsdb/ooo_head_test.go +index b9badfea2..c51e3c9d4 100644 +--- a/tsdb/ooo_head_test.go ++++ b/tsdb/ooo_head_test.go +@@ -55,12 +55,12 @@ func TestOOOInsert(t *testing.T) { + }, + "integer histogram": { + sampleFunc: func(ts int64) sample { +- return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} ++ return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} + }, + }, + "float histogram": { + sampleFunc: func(ts int64) sample { +- return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} ++ return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} + }, + }, + } +@@ -119,12 +119,12 @@ func TestOOOInsertDuplicate(t *testing.T) { + }, + "integer histogram": { + sampleFunc: func(ts int64) sample { +- return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(ts))} ++ return sample{t: ts, h: tsdbutil.GenerateTestHistogram(ts)} + }, + }, + "float histogram": { + sampleFunc: func(ts int64) sample { +- return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(ts))} ++ return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(ts)} + }, + }, + } +diff --git a/tsdb/querier_test.go b/tsdb/querier_test.go +index aca6c845b..c56f95166 100644 +--- a/tsdb/querier_test.go ++++ b/tsdb/querier_test.go +@@ -1826,12 +1826,12 @@ func checkCurrVal(t *testing.T, valType chunkenc.ValueType, it *populateWithDelS + ts, h := it.AtHistogram(nil) + require.Equal(t, int64(expectedTs), ts) + h.CounterResetHint = histogram.UnknownCounterReset +- require.Equal(t, tsdbutil.GenerateTestHistogram(expectedValue), h) ++ require.Equal(t, tsdbutil.GenerateTestHistogram(int64(expectedValue)), h) + case chunkenc.ValFloatHistogram: + ts, h := it.AtFloatHistogram(nil) + require.Equal(t, int64(expectedTs), ts) + h.CounterResetHint = histogram.UnknownCounterReset +- require.Equal(t, tsdbutil.GenerateTestFloatHistogram(expectedValue), h) ++ require.Equal(t, tsdbutil.GenerateTestFloatHistogram(int64(expectedValue)), h) + default: + panic("unexpected value type") + } +@@ -3565,16 +3565,16 @@ func TestQueryWithDeletedHistograms(t *testing.T) { + ctx := context.Background() + testcases := map[string]func(int) (*histogram.Histogram, *histogram.FloatHistogram){ + "intCounter": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { +- return tsdbutil.GenerateTestHistogram(i), nil ++ return tsdbutil.GenerateTestHistogram(int64(i)), nil + }, + "intgauge": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { +- return tsdbutil.GenerateTestGaugeHistogram(rand.Int() % 1000), nil ++ return tsdbutil.GenerateTestGaugeHistogram(rand.Int63() % 1000), nil + }, + "floatCounter": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { +- return nil, tsdbutil.GenerateTestFloatHistogram(i) ++ return nil, tsdbutil.GenerateTestFloatHistogram(int64(i)) + }, + "floatGauge": func(i int) (*histogram.Histogram, *histogram.FloatHistogram) { +- return nil, tsdbutil.GenerateTestGaugeFloatHistogram(rand.Int() % 1000) ++ return nil, tsdbutil.GenerateTestGaugeFloatHistogram(rand.Int63() % 1000) + }, + } + +diff --git a/tsdb/testutil.go b/tsdb/testutil.go +index 03587f4e2..ded30c3ab 100644 +--- a/tsdb/testutil.go ++++ b/tsdb/testutil.go +@@ -63,45 +63,45 @@ var sampleTypeScenarios = map[string]sampleTypeScenario{ + intHistogram: { + sampleType: sampleMetricTypeHistogram, + appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { +- s := sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))} ++ s := sample{t: ts, h: tsdbutil.GenerateTestHistogram(value)} + ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil) + return ref, s, err + }, + sampleFunc: func(ts, value int64) sample { +- return sample{t: ts, h: tsdbutil.GenerateTestHistogram(int(value))} ++ return sample{t: ts, h: tsdbutil.GenerateTestHistogram(value)} + }, + }, + floatHistogram: { + sampleType: sampleMetricTypeHistogram, + appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { +- s := sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))} ++ s := sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(value)} + ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh) + return ref, s, err + }, + sampleFunc: func(ts, value int64) sample { +- return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(int(value))} ++ return sample{t: ts, fh: tsdbutil.GenerateTestFloatHistogram(value)} + }, + }, + gaugeIntHistogram: { + sampleType: sampleMetricTypeHistogram, + appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { +- s := sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))} ++ s := sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(value)} + ref, err := appender.AppendHistogram(0, lbls, ts, s.h, nil) + return ref, s, err + }, + sampleFunc: func(ts, value int64) sample { +- return sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(int(value))} ++ return sample{t: ts, h: tsdbutil.GenerateTestGaugeHistogram(value)} + }, + }, + gaugeFloatHistogram: { + sampleType: sampleMetricTypeHistogram, + appendFunc: func(appender storage.Appender, lbls labels.Labels, ts, value int64) (storage.SeriesRef, sample, error) { +- s := sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))} ++ s := sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(value)} + ref, err := appender.AppendHistogram(0, lbls, ts, nil, s.fh) + return ref, s, err + }, + sampleFunc: func(ts, value int64) sample { +- return sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(int(value))} ++ return sample{t: ts, fh: tsdbutil.GenerateTestGaugeFloatHistogram(value)} + }, + }, + } +diff --git a/tsdb/tsdbutil/histogram.go b/tsdb/tsdbutil/histogram.go +index ce934a638..60c3e5f72 100644 +--- a/tsdb/tsdbutil/histogram.go ++++ b/tsdb/tsdbutil/histogram.go +@@ -21,7 +21,7 @@ import ( + + func GenerateTestHistograms(n int) (r []*histogram.Histogram) { + for i := 0; i < n; i++ { +- h := GenerateTestHistogram(i) ++ h := GenerateTestHistogram(int64(i)) + if i > 0 { + h.CounterResetHint = histogram.NotCounterReset + } +@@ -31,13 +31,13 @@ func GenerateTestHistograms(n int) (r []*histogram.Histogram) { + } + + func GenerateTestHistogramWithHint(n int, hint histogram.CounterResetHint) *histogram.Histogram { +- h := GenerateTestHistogram(n) ++ h := GenerateTestHistogram(int64(n)) + h.CounterResetHint = hint + return h + } + + // GenerateTestHistogram but it is up to the user to set any known counter reset hint. +-func GenerateTestHistogram(i int) *histogram.Histogram { ++func GenerateTestHistogram(i int64) *histogram.Histogram { + return &histogram.Histogram{ + Count: 12 + uint64(i*9), + ZeroCount: 2 + uint64(i), +@@ -48,16 +48,16 @@ func GenerateTestHistogram(i int) *histogram.Histogram { + {Offset: 0, Length: 2}, + {Offset: 1, Length: 2}, + }, +- PositiveBuckets: []int64{int64(i + 1), 1, -1, 0}, ++ PositiveBuckets: []int64{i + 1, 1, -1, 0}, + NegativeSpans: []histogram.Span{ + {Offset: 0, Length: 2}, + {Offset: 1, Length: 2}, + }, +- NegativeBuckets: []int64{int64(i + 1), 1, -1, 0}, ++ NegativeBuckets: []int64{i + 1, 1, -1, 0}, + } + } + +-func GenerateTestCustomBucketsHistogram(i int) *histogram.Histogram { ++func GenerateTestCustomBucketsHistogram(i int64) *histogram.Histogram { + return &histogram.Histogram{ + Count: 5 + uint64(i*4), + Sum: 18.4 * float64(i+1), +@@ -66,20 +66,20 @@ func GenerateTestCustomBucketsHistogram(i int) *histogram.Histogram { + {Offset: 0, Length: 2}, + {Offset: 1, Length: 2}, + }, +- PositiveBuckets: []int64{int64(i + 1), 1, -1, 0}, ++ PositiveBuckets: []int64{i + 1, 1, -1, 0}, + CustomValues: []float64{0, 1, 2, 3, 4}, + } + } + + func GenerateTestGaugeHistograms(n int) (r []*histogram.Histogram) { + for x := 0; x < n; x++ { +- i := int(math.Sin(float64(x))*100) + 100 ++ i := int64(math.Sin(float64(x))*100) + 100 + r = append(r, GenerateTestGaugeHistogram(i)) + } + return r + } + +-func GenerateTestGaugeHistogram(i int) *histogram.Histogram { ++func GenerateTestGaugeHistogram(i int64) *histogram.Histogram { + h := GenerateTestHistogram(i) + h.CounterResetHint = histogram.GaugeType + return h +@@ -87,7 +87,7 @@ func GenerateTestGaugeHistogram(i int) *histogram.Histogram { + + func GenerateTestFloatHistograms(n int) (r []*histogram.FloatHistogram) { + for i := 0; i < n; i++ { +- h := GenerateTestFloatHistogram(i) ++ h := GenerateTestFloatHistogram(int64(i)) + if i > 0 { + h.CounterResetHint = histogram.NotCounterReset + } +@@ -97,7 +97,7 @@ func GenerateTestFloatHistograms(n int) (r []*histogram.FloatHistogram) { + } + + // GenerateTestFloatHistogram but it is up to the user to set any known counter reset hint. +-func GenerateTestFloatHistogram(i int) *histogram.FloatHistogram { ++func GenerateTestFloatHistogram(i int64) *histogram.FloatHistogram { + return &histogram.FloatHistogram{ + Count: 12 + float64(i*9), + ZeroCount: 2 + float64(i), +@@ -117,7 +117,7 @@ func GenerateTestFloatHistogram(i int) *histogram.FloatHistogram { + } + } + +-func GenerateTestCustomBucketsFloatHistogram(i int) *histogram.FloatHistogram { ++func GenerateTestCustomBucketsFloatHistogram(i int64) *histogram.FloatHistogram { + return &histogram.FloatHistogram{ + Count: 5 + float64(i*4), + Sum: 18.4 * float64(i+1), +@@ -133,13 +133,13 @@ func GenerateTestCustomBucketsFloatHistogram(i int) *histogram.FloatHistogram { + + func GenerateTestGaugeFloatHistograms(n int) (r []*histogram.FloatHistogram) { + for x := 0; x < n; x++ { +- i := int(math.Sin(float64(x))*100) + 100 ++ i := int64(math.Sin(float64(x))*100) + 100 + r = append(r, GenerateTestGaugeFloatHistogram(i)) + } + return r + } + +-func GenerateTestGaugeFloatHistogram(i int) *histogram.FloatHistogram { ++func GenerateTestGaugeFloatHistogram(i int64) *histogram.FloatHistogram { + h := GenerateTestFloatHistogram(i) + h.CounterResetHint = histogram.GaugeType + return h diff --git a/srcpkgs/prometheus/patches/atomic-alignment.patch b/srcpkgs/prometheus/patches/atomic-alignment.patch new file mode 100644 index 00000000000000..00757db664ad14 --- /dev/null +++ b/srcpkgs/prometheus/patches/atomic-alignment.patch @@ -0,0 +1,22 @@ +commit bf80827f6fe4fda2f3f9f41234a3bb3b3cb72d2e +Author: Joel Beckmeyer +Date: Fri Dec 13 20:54:34 2024 -0500 + + fix alignment of atomic uint64 on 32-bit + + Signed-off-by: Joel Beckmeyer + +diff --git a/util/testutil/context.go b/util/testutil/context.go +index 0c9e0f6f6..ea4b0e374 100644 +--- a/util/testutil/context.go ++++ b/util/testutil/context.go +@@ -49,8 +49,8 @@ func (c *MockContext) Value(interface{}) interface{} { + // MockContextErrAfter is a MockContext that will return an error after a certain + // number of calls to Err(). + type MockContextErrAfter struct { ++ count atomic.Uint64 + MockContext +- count atomic.Uint64 + FailAfter uint64 + } + diff --git a/srcpkgs/prometheus/patches/promql-topk-bottomk.patch b/srcpkgs/prometheus/patches/promql-topk-bottomk.patch new file mode 100644 index 00000000000000..d28d66977b4932 --- /dev/null +++ b/srcpkgs/prometheus/patches/promql-topk-bottomk.patch @@ -0,0 +1,77 @@ +commit 132db1f3b67a2c925c2cf29b10e3a5340974be49 +Author: Joel Beckmeyer +Date: Mon Dec 16 10:42:56 2024 -0500 + + fix topk/bottomk with numbers greater than int maxsize on 32-bit + + Signed-off-by: Joel Beckmeyer + +diff --git a/promql/engine.go b/promql/engine.go +index eecb4bcc4..ac73652b4 100644 +--- a/promql/engine.go ++++ b/promql/engine.go +@@ -1352,7 +1352,7 @@ func (ev *evaluator) rangeEvalAgg(ctx context.Context, aggExpr *parser.Aggregate + } + groups := make([]groupedAggregation, groupCount) + +- var k int ++ var k int64 + var ratio float64 + var seriess map[uint64]Series + switch aggExpr.Op { +@@ -1360,9 +1360,9 @@ func (ev *evaluator) rangeEvalAgg(ctx context.Context, aggExpr *parser.Aggregate + if !convertibleToInt64(param) { + ev.errorf("Scalar value %v overflows int64", param) + } +- k = int(param) +- if k > len(inputMatrix) { +- k = len(inputMatrix) ++ k = int64(param) ++ if k > int64(len(inputMatrix)) { ++ k = int64(len(inputMatrix)) + } + if k < 1 { + return nil, warnings +@@ -3126,7 +3126,7 @@ func (ev *evaluator) aggregation(e *parser.AggregateExpr, q float64, inputMatrix + // seriesToResult maps inputMatrix indexes to groups indexes. + // For an instant query, returns a Matrix in descending order for topk or ascending for bottomk, or without any order for limitk / limit_ratio. + // For a range query, aggregates output in the seriess map. +-func (ev *evaluator) aggregationK(e *parser.AggregateExpr, k int, r float64, inputMatrix Matrix, seriesToResult []int, groups []groupedAggregation, enh *EvalNodeHelper, seriess map[uint64]Series) (Matrix, annotations.Annotations) { ++func (ev *evaluator) aggregationK(e *parser.AggregateExpr, k int64, r float64, inputMatrix Matrix, seriesToResult []int, groups []groupedAggregation, enh *EvalNodeHelper, seriess map[uint64]Series) (Matrix, annotations.Annotations) { + op := e.Op + var s Sample + var annos annotations.Annotations +@@ -3171,7 +3171,7 @@ seriesLoop: + case parser.TOPK: + // We build a heap of up to k elements, with the smallest element at heap[0]. + switch { +- case len(group.heap) < k: ++ case int64(len(group.heap)) < k: + heap.Push(&group.heap, &s) + case group.heap[0].F < s.F || (math.IsNaN(group.heap[0].F) && !math.IsNaN(s.F)): + // This new element is bigger than the previous smallest element - overwrite that. +@@ -3184,7 +3184,7 @@ seriesLoop: + case parser.BOTTOMK: + // We build a heap of up to k elements, with the biggest element at heap[0]. + switch { +- case len(group.heap) < k: ++ case int64(len(group.heap)) < k: + heap.Push((*vectorByReverseValueHeap)(&group.heap), &s) + case group.heap[0].F > s.F || (math.IsNaN(group.heap[0].F) && !math.IsNaN(s.F)): + // This new element is smaller than the previous biggest element - overwrite that. +@@ -3195,13 +3195,13 @@ seriesLoop: + } + + case parser.LIMITK: +- if len(group.heap) < k { ++ if int64(len(group.heap)) < k { + heap.Push(&group.heap, &s) + } + // LIMITK optimization: early break if we've added K elem to _every_ group, + // especially useful for large timeseries where the user is exploring labels via e.g. + // limitk(10, my_metric) +- if !group.groupAggrComplete && len(group.heap) == k { ++ if !group.groupAggrComplete && int64(len(group.heap)) == k { + group.groupAggrComplete = true + groupsRemaining-- + if groupsRemaining == 0 { diff --git a/srcpkgs/prometheus/patches/really_large_histograms.patch b/srcpkgs/prometheus/patches/really_large_histograms.patch new file mode 100644 index 00000000000000..f70477144ed3c1 --- /dev/null +++ b/srcpkgs/prometheus/patches/really_large_histograms.patch @@ -0,0 +1,27 @@ +commit 008f930f02eee3a8d55213ccede70ae7abbdaab4 +Author: Joel Beckmeyer +Date: Fri Dec 6 15:57:35 2024 -0500 + + fix TestCuttingNewHeadChunks/really_large_histograms on 32-bit + + Signed-off-by: Joel Beckmeyer + +diff --git a/model/histogram/test_utils.go b/model/histogram/test_utils.go +index 9e9a711c2..e6b33863b 100644 +--- a/model/histogram/test_utils.go ++++ b/model/histogram/test_utils.go +@@ -19,12 +19,12 @@ func GenerateBigTestHistograms(numHistograms, numBuckets int) []*Histogram { + bucketsPerSide := numBuckets / 2 + spanLength := uint32(bucketsPerSide / numSpans) + // Given all bucket deltas are 1, sum bucketsPerSide + 1. +- observationCount := bucketsPerSide * (1 + bucketsPerSide) ++ observationCount := uint64(bucketsPerSide) * (1 + uint64(bucketsPerSide)) + + var histograms []*Histogram + for i := 0; i < numHistograms; i++ { + h := &Histogram{ +- Count: uint64(i + observationCount), ++ Count: uint64(i) + observationCount, + ZeroCount: uint64(i), + ZeroThreshold: 1e-128, + Sum: 18.4 * float64(i+1), diff --git a/srcpkgs/prometheus/template b/srcpkgs/prometheus/template index e18c0d3b610706..c94b0792a12299 100644 --- a/srcpkgs/prometheus/template +++ b/srcpkgs/prometheus/template @@ -1,7 +1,7 @@ # Template file for 'prometheus' pkgname=prometheus -version=2.53.1 -revision=2 +version=3.0.1 +revision=1 build_style=go go_import_path="github.com/prometheus/prometheus" go_package="github.com/prometheus/prometheus/cmd/prometheus github.com/prometheus/prometheus/cmd/promtool" @@ -19,18 +19,28 @@ license="Apache-2.0, MIT" homepage="https://prometheus.io/" changelog="https://raw.githubusercontent.com/prometheus/prometheus/master/CHANGELOG.md" distfiles="https://github.com/prometheus/prometheus/archive/v${version}.tar.gz" -checksum=6a36ad9fd6ce2813c78aab1da98d7725143bcb73e4fe1e2597c873537f7072af +checksum=bd40fd54d5a8f63cbbf5355ee056d23efce29c4af3fbf3fd754238c5d2a27425 system_accounts="_prometheus" make_dirs="/var/lib/prometheus 700 _prometheus _prometheus" +if [ "${XBPS_BUILD_ENVIRONMENT}" != "void-packages-ci" ]; then + make_check_args+=" -skip (TestQueryLog|TestDelayedCompaction)" +fi + pre_build() { # Need to patch node fs to avoid using too many file descriptors (cd web/ui && yarn add --dev -W graceful-fs@4.2.11) echo "require('graceful-fs').gracefulify(require('fs'));" \ > "${wrksrc}/web/ui/use-graceful-fs.js" export NODE_OPTIONS="--require ${wrksrc}/web/ui/use-graceful-fs.js" + + # rollup doesn't support native i686, use wasm instead + if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then + (cd web/ui && npm install --override rollup@npm:@rollup/wasm-node@latest) + fi + CGO_ENABLED=0 GOARCH= make assets assets-compress } @@ -39,8 +49,6 @@ post_install() { vmkdir etc/prometheus vmkdir usr/share/doc/prometheus vmkdir usr/share/examples/prometheus - vcopy consoles etc/prometheus - vcopy console_libraries etc/prometheus vcopy documentation/examples/* usr/share/examples/prometheus/ vcopy documentation/examples/prometheus.yml etc/prometheus/ vcopy documentation/images usr/share/doc/prometheus/