diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59cbf1b669..b2638c3413 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: # should also be updated. container: - image: quay.io/prometheus/golang-builder:1.25-base + image: quay.io/prometheus/golang-builder:1.26-base services: maildev-noauth: image: maildev/maildev:2.2.1 diff --git a/.github/workflows/mixin.yml b/.github/workflows/mixin.yml index 18675c71eb..9bf46d1cac 100644 --- a/.github/workflows/mixin.yml +++ b/.github/workflows/mixin.yml @@ -14,7 +14,7 @@ jobs: - name: install Go uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 with: - go-version: 1.25.x + go-version: 1.26.x # pin the mixtool version until https://github.com/monitoring-mixins/mixtool/issues/135 is merged. - run: go install github.com/monitoring-mixins/mixtool/cmd/mixtool@2282201396b69055bb0f92f187049027a16d2130 - run: go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest diff --git a/.promu.yml b/.promu.yml index 0721a29ee9..f54b3eaa8b 100644 --- a/.promu.yml +++ b/.promu.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, # .circle/config.yml should also be updated. - version: 1.25 + version: 1.26 repository: path: github.com/prometheus/alertmanager build: diff --git a/cli/silence_import.go b/cli/silence_import.go index c65566a427..17e7c30c8a 100644 --- a/cli/silence_import.go +++ b/cli/silence_import.go @@ -115,11 +115,9 @@ func (c *silenceImportCmd) bulkImport(ctx context.Context, _ *kingpin.ParseConte } defer closeChannels() for w := 0; w < c.workers; w++ { - wg.Add(1) - go func() { + wg.Go(func() { addSilenceWorker(ctx, amclient.Silence, silencec, errc) - wg.Done() - }() + }) } errCount := 0 diff --git a/cluster/tls_transport_test.go b/cluster/tls_transport_test.go index c582ade7bb..c1c4a737d3 100644 --- a/cluster/tls_transport_test.go +++ b/cluster/tls_transport_test.go @@ -210,11 +210,9 @@ func TestDialTimeout(t *testing.T) { var to net.Conn var wg sync.WaitGroup - wg.Add(1) - go func() { + wg.Go(func() { to = <-t2.StreamCh() - wg.Done() - }() + }) sent := []byte(("test stream")) m, err := from.Write(sent) diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index 0f654b3328..dcb5584241 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -287,11 +287,9 @@ func run() int { notificationLog.SetBroadcast(c.Broadcast) } - wg.Add(1) - go func() { + wg.Go(func() { notificationLog.Maintenance(*maintenanceInterval, filepath.Join(*dataDir, "nflog"), stopc, nil) - wg.Done() - }() + }) marker := types.NewMarker(prometheus.DefaultRegisterer) @@ -317,11 +315,9 @@ func run() int { } // Start providers before router potentially sends updates. - wg.Add(1) - go func() { + wg.Go(func() { silences.Maintenance(*maintenanceInterval, filepath.Join(*dataDir, "silences"), stopc, nil) - wg.Done() - }() + }) defer func() { close(stopc) diff --git a/dispatch/dispatch.go b/dispatch/dispatch.go index 2078cdfba1..9cd1f1a769 100644 --- a/dispatch/dispatch.go +++ b/dispatch/dispatch.go @@ -200,9 +200,7 @@ func (d *Dispatcher) run(it provider.AlertIterator) { defer it.Close() // Start maintenance goroutine - d.finished.Add(1) - go func() { - defer d.finished.Done() + d.finished.Go(func() { ticker := time.NewTicker(d.maintenanceInterval) defer ticker.Stop() @@ -214,12 +212,10 @@ func (d *Dispatcher) run(it provider.AlertIterator) { return } } - }() + }) // Start timer goroutine - d.finished.Add(1) - go func() { - defer d.finished.Done() + d.finished.Go(func() { <-d.startTimer.C if d.state.CompareAndSwap(DispatcherStateWaitingToStart, DispatcherStateRunning) { @@ -232,7 +228,7 @@ func (d *Dispatcher) run(it provider.AlertIterator) { }) } } - }() + }) // Start multiple alert ingestion goroutines alertCh := it.Next() diff --git a/go.mod b/go.mod index 0730775047..48256244d0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/prometheus/alertmanager -go 1.24.0 +go 1.25.0 require ( github.com/KimMachineGun/automemlimit v0.7.5 diff --git a/nflog/nflog_test.go b/nflog/nflog_test.go index b0b1127d32..97a63edc3c 100644 --- a/nflog/nflog_test.go +++ b/nflog/nflog_test.go @@ -156,14 +156,12 @@ func TestWithMaintenance_SupportsCustomCallback(t *testing.T) { var calls atomic.Int32 var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { l.Maintenance(100*time.Millisecond, f.Name(), stopc, func() (int64, error) { calls.Add(1) return 0, nil }) - }() + }) gosched() // Before the first tick, no maintenance executed. diff --git a/provider/mem/mem_test.go b/provider/mem/mem_test.go index e43a4d3312..8de535edbc 100644 --- a/provider/mem/mem_test.go +++ b/provider/mem/mem_test.go @@ -564,10 +564,7 @@ func TestAlertsConcurrently(t *testing.T) { expire := 10 * time.Millisecond wg := sync.WaitGroup{} for range 100 { - wg.Add(1) - go func() { - defer wg.Done() - + wg.Go(func() { j := 0 for { select { @@ -592,7 +589,7 @@ func TestAlertsConcurrently(t *testing.T) { } j++ } - }() + }) } wg.Wait() select { diff --git a/silence/cache_test.go b/silence/cache_test.go index fd8c45d135..4930414524 100644 --- a/silence/cache_test.go +++ b/silence/cache_test.go @@ -157,35 +157,29 @@ func TestCacheConcurrentAccess(t *testing.T) { // Concurrent readers. for range goroutines { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for range 100 { _ = c.get(fp) } - }() + }) } // Concurrent writers. for i := range goroutines { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for j := range 100 { c.set(fp, newCacheEntry(i*100+j, "w")) } - }() + }) } // Concurrent deleters. for range goroutines { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for range 100 { c.delete(fp) } - }() + }) } wg.Wait() diff --git a/silence/silence_test.go b/silence/silence_test.go index a204f902c1..53c32542c9 100644 --- a/silence/silence_test.go +++ b/silence/silence_test.go @@ -553,14 +553,12 @@ func TestSilences_Maintenance_SupportsCustomCallback(t *testing.T) { var calls atomic.Int32 var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { s.Maintenance(10*time.Second, f.Name(), stopc, func() (int64, error) { calls.Add(1) return 0, nil }) - }() + }) gosched() // Before the first tick, no maintenance executed. diff --git a/template/template_test.go b/template/template_test.go index b9639bc69c..549d5391bf 100644 --- a/template/template_test.go +++ b/template/template_test.go @@ -660,9 +660,7 @@ func TestTemplateFuncs(t *testing.T) { t.Run(tc.title, func(t *testing.T) { wg := sync.WaitGroup{} for range 10 { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { got, err := tmpl.ExecuteTextString(tc.in, tc.data) if tc.expErr == "" { require.NoError(t, err) @@ -671,7 +669,7 @@ func TestTemplateFuncs(t *testing.T) { require.EqualError(t, err, tc.expErr) require.Empty(t, got) } - }() + }) } wg.Wait() })