Skip to content

Commit

Permalink
remove deprecated call to rand.Seed()
Browse files Browse the repository at this point in the history
  • Loading branch information
linki committed Mar 3, 2025
1 parent 25b4246 commit 76364ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions chaoskube/chaoskube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (suite *Suite) TestVictim() {
{2000, "", bar},
{2000, "app=foo", foo},
} {
rand.Seed(tt.seed)
rand.New(rand.NewSource(tt.seed))

labelSelector, err := labels.Parse(tt.labelSelector)
suite.Require().NoError(err)
Expand Down Expand Up @@ -370,7 +370,7 @@ func (suite *Suite) TestVictims() {
bar := t(podsInfo[1])
baz := t(podsInfo[2])

rand.Seed(2) // yields order of bar, baz, foo
rand.New(rand.NewSource(2)) // yields order of bar, baz, foo

for _, tt := range []struct {
labelSelector string
Expand Down Expand Up @@ -1127,7 +1127,7 @@ func (suite *Suite) TestFilterByOwnerReference() {
expected: []v1.Pod{baz, baz1},
},
} {
rand.Seed(tt.seed)
rand.New(rand.NewSource(tt.seed))

results := filterByOwnerReference(tt.pods)
suite.Require().Len(results, len(tt.expected))
Expand Down
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
Expand Down Expand Up @@ -69,7 +68,6 @@ func cliEnvVar(name string) string {
}

func init() {
rand.Seed(time.Now().UTC().UnixNano())
klog.SetOutput(io.Discard)

kingpin.Flag("labels", "A set of labels to restrict the list of affected pods. Defaults to everything.").Envar(cliEnvVar("LABELS")).StringVar(&labelString)
Expand Down

0 comments on commit 76364ab

Please # to comment.