Skip to content

Commit

Permalink
Merge pull request #2189 from ripienaar/go_1_22
Browse files Browse the repository at this point in the history
(misc) Update to go1.22 and update dependencies
  • Loading branch information
ripienaar authored Aug 15, 2024
2 parents a1dacb7 + 0fc921c commit 1ef1974
Show file tree
Hide file tree
Showing 33 changed files with 186 additions and 205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,4 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_ACCESS_KEY }}
SOURCE_DIR: artifacts/foss
DEST_DIR: release
DEST_DIR: release
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
test:
strategy:
matrix:
go: ["1.21", "1.22"]
go: ["1.22", "1.23"]

runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 3 additions & 3 deletions aagent/machine/info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2022, R.I. Pienaar and the Choria Project contributors
// Copyright (c) 2019-2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -8,7 +8,7 @@ import (
"crypto/md5"
"fmt"
"io"
"math/rand"
"math/rand/v2"
"os"
"strings"
"time"
Expand Down Expand Up @@ -101,7 +101,7 @@ func randStringRunes(n int) string {

b := make([]rune, n)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
b[i] = letterRunes[rand.N(len(letterRunes))]
}
return string(b)
}
Expand Down
4 changes: 2 additions & 2 deletions aagent/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"math/rand/v2"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -546,7 +546,7 @@ func (m *Machine) Start(ctx context.Context, wg *sync.WaitGroup) (started chan s

runf := func() {
if m.SplayStart > 0 {
sleep := time.Duration(rand.Intn(m.SplayStart)) * time.Second
sleep := time.Duration(rand.N(m.SplayStart)) * time.Second
m.Infof(m.MachineName, "Sleeping %v before starting Autonomous Agent", sleep)

t := time.NewTimer(sleep)
Expand Down
4 changes: 2 additions & 2 deletions aagent/watchers/execwatcher/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"math/rand/v2"
"os"
"os/exec"
"sync"
Expand Down Expand Up @@ -168,7 +168,7 @@ func (w *Watcher) intervalWatcher(ctx context.Context, wg *sync.WaitGroup) {

tick := time.NewTicker(w.interval)
if w.properties.GatherInitialState {
splay := time.Duration(rand.Intn(30)) * time.Second
splay := rand.N(30 * time.Second)
w.Infof("Performing initial execution after %v", splay)
if splay < 1 {
splay = 1
Expand Down
4 changes: 2 additions & 2 deletions aagent/watchers/metricwatcher/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"math/rand/v2"
"net"
"os"
"os/exec"
Expand Down Expand Up @@ -108,7 +108,7 @@ func (w *Watcher) Run(ctx context.Context, wg *sync.WaitGroup) {

w.Infof("metric watcher for %s starting", w.properties.Command)

splay := time.Duration(rand.Intn(int(w.properties.Interval.Seconds()))) * time.Second
splay := rand.N(w.properties.Interval)
w.Infof("Splaying first check by %v", splay)

select {
Expand Down
6 changes: 3 additions & 3 deletions aagent/watchers/nagioswatcher/nagios.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022, R.I. Pienaar and the Choria Project contributors
// Copyright (c) 2020-2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -9,7 +9,7 @@ import (
"context"
"fmt"
"html/template"
"math/rand"
"math/rand/v2"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -282,7 +282,7 @@ func (w *Watcher) Run(ctx context.Context, wg *sync.WaitGroup) {
func (w *Watcher) intervalWatcher(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()

splay := time.Duration(rand.Intn(int(w.interval.Seconds()))) * time.Second
splay := rand.N(w.interval)
w.Infof("Splaying first check by %v", splay)

select {
Expand Down
6 changes: 3 additions & 3 deletions aagent/watchers/schedulewatcher/item.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) 2019-2021, R.I. Pienaar and the Choria Project contributors
// Copyright (c) 2019-2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

package schedulewatcher

import (
"context"
"math/rand"
"math/rand/v2"
"sync"
"time"

Expand Down Expand Up @@ -58,7 +58,7 @@ func (s *scheduleItem) check(ctx context.Context) {

sleep := time.Duration(0)
if s.randomize > 0 {
sleep = time.Duration(rand.Int63n(int64(s.randomize)))
sleep = rand.N(s.randomize)
s.watcher.Infof("Splay sleeping %v before starting schedule", sleep)
err := util.InterruptibleSleep(ctx, sleep)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions aagent/watchers/timerwatcher/timer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022, R.I. Pienaar and the Choria Project contributors
// Copyright (c) 2020-2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -7,7 +7,7 @@ package timerwatcher
import (
"context"
"fmt"
"math/rand"
"math/rand/v2"
"sync"
"time"

Expand Down Expand Up @@ -184,7 +184,7 @@ func (w *Watcher) validate() error {
}

if w.properties.Splay {
w.properties.Timer = time.Duration(rand.Int63n(int64(w.properties.Timer)))
w.properties.Timer = rand.N(w.properties.Timer)
w.Infof("Adjusting timer to %v due to splay setting", w.properties.Timer)
}

Expand Down
4 changes: 2 additions & 2 deletions backoff/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package backoff

import (
"context"
"math/rand"
"math/rand/v2"
"time"
)

Expand Down Expand Up @@ -103,5 +103,5 @@ func jitter(millis int) int {
return 0
}

return millis/2 + rand.Intn(millis)
return millis/2 + rand.N(millis)
}
6 changes: 3 additions & 3 deletions broker/network/network_jetstream.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022, R.I. Pienaar and the Choria Project contributors
// Copyright (c) 2020-2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -8,7 +8,7 @@ import (
"context"
"crypto/tls"
"fmt"
"math/rand"
"math/rand/v2"
"time"

"github.com/choria-io/go-choria/backoff"
Expand Down Expand Up @@ -55,7 +55,7 @@ func (s *Server) configureSystemStreams(ctx context.Context) error {

cfg := s.config.Choria
if cfg.NetworkEventStoreReplicas == -1 || cfg.NetworkMachineStoreReplicas == -1 || cfg.NetworkStreamAdvisoryReplicas == -1 || cfg.NetworkLeaderElectionReplicas == -1 {
delay := time.Duration(rand.Intn(60)+10) * time.Second
delay := time.Duration(rand.N(60)+10) * time.Second
s.log.Infof("Configuring system streams after %v", delay)
err = backoff.Default.Sleep(ctx, delay)
if err != nil {
Expand Down
12 changes: 8 additions & 4 deletions client/aaa_signerclient/discover.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

// generated code; DO NOT EDIT

package aaa_signerclient
Expand Down Expand Up @@ -44,7 +48,7 @@ func (b *BroadcastNS) Discover(ctx context.Context, fw inter.Framework, filters
return out
}

if !(b.nodeCache == nil || len(b.nodeCache) == 0) {
if len(b.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -97,7 +101,7 @@ func (p *ExternalNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -150,7 +154,7 @@ func (p *PuppetDBNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -224,7 +228,7 @@ func (p *MetaNS) Discover(ctx context.Context, fw inter.Framework, _ []FilterFun
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down
12 changes: 8 additions & 4 deletions client/choria_provisionclient/discover.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

// generated code; DO NOT EDIT

package choria_provisionclient
Expand Down Expand Up @@ -44,7 +48,7 @@ func (b *BroadcastNS) Discover(ctx context.Context, fw inter.Framework, filters
return out
}

if !(b.nodeCache == nil || len(b.nodeCache) == 0) {
if len(b.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -97,7 +101,7 @@ func (p *ExternalNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -150,7 +154,7 @@ func (p *PuppetDBNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -224,7 +228,7 @@ func (p *MetaNS) Discover(ctx context.Context, fw inter.Framework, _ []FilterFun
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down
12 changes: 8 additions & 4 deletions client/choria_registryclient/discover.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

// generated code; DO NOT EDIT

package choria_registryclient
Expand Down Expand Up @@ -44,7 +48,7 @@ func (b *BroadcastNS) Discover(ctx context.Context, fw inter.Framework, filters
return out
}

if !(b.nodeCache == nil || len(b.nodeCache) == 0) {
if len(b.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -97,7 +101,7 @@ func (p *ExternalNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -150,7 +154,7 @@ func (p *PuppetDBNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -224,7 +228,7 @@ func (p *MetaNS) Discover(ctx context.Context, fw inter.Framework, _ []FilterFun
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down
12 changes: 8 additions & 4 deletions client/choria_utilclient/discover.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

// generated code; DO NOT EDIT

package choria_utilclient
Expand Down Expand Up @@ -44,7 +48,7 @@ func (b *BroadcastNS) Discover(ctx context.Context, fw inter.Framework, filters
return out
}

if !(b.nodeCache == nil || len(b.nodeCache) == 0) {
if len(b.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -97,7 +101,7 @@ func (p *ExternalNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -150,7 +154,7 @@ func (p *PuppetDBNS) Discover(ctx context.Context, fw inter.Framework, filters [
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down Expand Up @@ -224,7 +228,7 @@ func (p *MetaNS) Discover(ctx context.Context, fw inter.Framework, _ []FilterFun
return out
}

if !(p.nodeCache == nil || len(p.nodeCache) == 0) {
if len(p.nodeCache) > 0 {
return copier(), nil
}

Expand Down
Loading

0 comments on commit 1ef1974

Please sign in to comment.