Skip to content

Commit

Permalink
Seed the random number generator
Browse files Browse the repository at this point in the history
Seed the random number generator, as (at least) controller-runtime uses
it to add jitter to shared informer resync periods.

Signed-off-by: Andy Goldstein <goldsteina@vmware.com>
  • Loading branch information
ncdc committed Mar 25, 2020
1 parent 4672438 commit 2f296a3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bootstrap/kubeadm/main.go
Expand Up @@ -18,6 +18,7 @@ package main

import (
"flag"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
Expand Down Expand Up @@ -109,6 +110,8 @@ func InitFlags(fs *pflag.FlagSet) {
}

func main() {
rand.Seed(time.Now().UnixNano())

InitFlags(pflag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
Expand Down
4 changes: 4 additions & 0 deletions cmd/example-provider/main.go
Expand Up @@ -18,7 +18,9 @@ package main

import (
"flag"
"math/rand"
"os"
"time"

"k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog"
Expand All @@ -30,6 +32,8 @@ import (
)

func main() {
rand.Seed(time.Now().UnixNano())

klog.InitFlags(nil)
var enableLeaderElection bool
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
Expand Down
3 changes: 3 additions & 0 deletions controlplane/kubeadm/main.go
Expand Up @@ -18,6 +18,7 @@ package main

import (
"flag"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
Expand Down Expand Up @@ -101,6 +102,8 @@ func InitFlags(fs *pflag.FlagSet) {
"Webhook Server port, disabled by default. When enabled, the manager will only work as webhook server, no reconcilers are installed.")
}
func main() {
rand.Seed(time.Now().UnixNano())

InitFlags(pflag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
Expand Down
3 changes: 3 additions & 0 deletions main.go
Expand Up @@ -17,6 +17,7 @@ package main

import (
"flag"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
Expand Down Expand Up @@ -131,6 +132,8 @@ func InitFlags(fs *pflag.FlagSet) {
}

func main() {
rand.Seed(time.Now().UnixNano())

InitFlags(pflag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
Expand Down
3 changes: 3 additions & 0 deletions test/infrastructure/docker/main.go
Expand Up @@ -18,6 +18,7 @@ package main

import (
"flag"
"math/rand"
"os"
"time"

Expand Down Expand Up @@ -55,6 +56,8 @@ func init() {
}

func main() {
rand.Seed(time.Now().UnixNano())

klog.InitFlags(nil)
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.IntVar(&concurrency, "concurrency", 10, "The number of docker machines to process simultaneously")
Expand Down

0 comments on commit 2f296a3

Please sign in to comment.