Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed math/rand on start #12200

Merged
merged 1 commit into from
Dec 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/dockerregistry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package main
import (
"flag"
"fmt"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
"runtime"
"time"

log "github.com/Sirupsen/logrus"
"k8s.io/kubernetes/pkg/util/logs"
Expand All @@ -28,6 +30,7 @@ func main() {
defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop()
startProfiler()

rand.Seed(time.Now().UTC().UnixNano())
runtime.GOMAXPROCS(runtime.NumCPU())
flag.Parse()

Expand Down
3 changes: 3 additions & 0 deletions cmd/gitserver/gitserver.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"math/rand"
"os"
"path/filepath"
"runtime"
"time"

"k8s.io/kubernetes/pkg/util/logs"

Expand All @@ -22,6 +24,7 @@ func main() {
defer serviceability.BehaviorOnPanic(os.Getenv("OPENSHIFT_ON_PANIC"))()
defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop()

rand.Seed(time.Now().UTC().UnixNano())
if len(os.Getenv("GOMAXPROCS")) == 0 {
runtime.GOMAXPROCS(runtime.NumCPU())
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/oc/oc.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"math/rand"
"os"
"path/filepath"
"runtime"
"time"

"k8s.io/kubernetes/pkg/util/logs"

Expand All @@ -24,6 +26,7 @@ func main() {
defer serviceability.BehaviorOnPanic(os.Getenv("OPENSHIFT_ON_PANIC"))()
defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop()

rand.Seed(time.Now().UTC().UnixNano())
if len(os.Getenv("GOMAXPROCS")) == 0 {
runtime.GOMAXPROCS(runtime.NumCPU())
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/openshift/openshift.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"math/rand"
"os"
"path/filepath"
"runtime"
"time"

"k8s.io/kubernetes/pkg/util/logs"

Expand All @@ -24,6 +26,7 @@ func main() {
defer serviceability.BehaviorOnPanic(os.Getenv("OPENSHIFT_ON_PANIC"))()
defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop()

rand.Seed(time.Now().UTC().UnixNano())
if len(os.Getenv("GOMAXPROCS")) == 0 {
runtime.GOMAXPROCS(runtime.NumCPU())
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/admin/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path"
"strconv"
"strings"
"time"

"github.com/golang/glog"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -846,6 +847,7 @@ func generateRoleBindingName(name string) string {

// generateStatsPassword creates a random password.
func generateStatsPassword() string {
rand := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
allowableChars := []rune("abcdefghijlkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
allowableCharLength := len(allowableChars)
password := []string{}
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/server/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ type RandomSerialGenerator struct {
}

func (s *RandomSerialGenerator) Next(template *x509.Certificate) (int64, error) {
return mathrand.Int63(), nil
r := mathrand.New(mathrand.NewSource(time.Now().UTC().UnixNano()))
return r.Int63(), nil
}

// EnsureCA returns a CA, whether it was created (as opposed to pre-existing), and any error
Expand Down
3 changes: 3 additions & 0 deletions pkg/sdn/plugin/sdn-cni-plugin/openshift-sdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net"
"net/http"
"os"
"strings"
"time"

"github.com/openshift/origin/pkg/sdn/plugin/cniserver"

Expand Down Expand Up @@ -111,6 +113,7 @@ func (p *cniPlugin) CmdDel(args *skel.CmdArgs) error {
}

func main() {
rand.Seed(time.Now().UTC().UnixNano())
p := NewCNIPlugin(cniserver.CNIServerSocketPath)
skel.PluginMain(p.skelCmdAdd, p.CmdDel, version.Legacy)
}