treewide: dont seed random
As of Go 1.20 there is no reason to call Seed with a random value.
Programs that call Seed with a known value to get a specific sequence
of results should use New(NewSource(seed)) to obtain a local random generator.
Change-Id: Ice1bbfefd900e6e9241428ec345f51f780eed91f
Reviewed-on: https://review.monogon.dev/c/monogon/+/2960
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/dbg/main.go b/metropolis/cli/dbg/main.go
index f7eb1a4..e702083 100644
--- a/metropolis/cli/dbg/main.go
+++ b/metropolis/cli/dbg/main.go
@@ -21,10 +21,8 @@
"flag"
"fmt"
"io"
- "math/rand"
"os"
"strings"
- "time"
"google.golang.org/grpc"
"k8s.io/cli-runtime/pkg/genericclioptions"
@@ -180,7 +178,6 @@
// The base code is straight from:
// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubectl/kubectl.go
os.Setenv("KUBECONFIG", kubeconfigFile.Name())
- rand.Seed(time.Now().UnixNano())
command := cmd.NewDefaultKubectlCommandWithArgs(cmd.KubectlOptions{
PluginHandler: cmd.NewDefaultPluginHandler(plugin.ValidPluginFilenamePrefixes),
Arguments: os.Args[2:],
diff --git a/metropolis/node/kubernetes/hyperkube/main.go b/metropolis/node/kubernetes/hyperkube/main.go
index fd0703d..5f9d443 100644
--- a/metropolis/node/kubernetes/hyperkube/main.go
+++ b/metropolis/node/kubernetes/hyperkube/main.go
@@ -33,10 +33,8 @@
import (
goflag "flag"
- "math/rand"
"os"
"path/filepath"
- "time"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -51,8 +49,6 @@
)
func main() {
- rand.Seed(time.Now().UnixNano())
-
hyperkubeCommand, allCommandFns := NewHyperKubeCommand()
// TODO: once we switch everything over to Cobra commands, we can go back