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
[occm] Rand not being initialised any more with a seed #2120
Comments
/cc zetaab |
CC @zetaab |
|
s := rand.NewSource(n) and then pass Note that as the docs say, when you don't use the global source you would also need to manage concurrency:
Has |
Good to know, thanks.
At a minimum, if the global source is seeded automatically in Go v1.19, we should remove the noop use of |
hmm the deprecation notice you linked mentions that it's 1.20-only:
|
If that’s ok for you, I can take care of reverting the command while making the linter happy. WDYT? |
I am thinking is this math/rand seed even needed. There might be some library that needs that seed were added by dims in #61 |
@zetaab at one point it was part of a kube-controller-manager i believe. I still see a lot of references: but it looks like it's been removed from k/k. |
@pierreprinetti there are still some references in k8s.io/cloud-provider to math/rand. So perhaps its best to add it back.
|
it will be ready for removal once the repo compiles with Go v1.20! Thank you for your time, @zetaab. |
/kind bug
What happened:
#2100 changed the use of
rand.Seed
, which seeds the global PRNG, withrand.NewSource
, that returns a new initialised PRNG. With that change, that line becomes a noop (because the generated PRNG is never assigned to a variable). As a result, as stated by the documentation of math/rand:As a consequence, all random numbers generated by the binary will always be the same in the same order, which doesn't look like the expected behaviour of the PR.
cloud-provider-openstack/cmd/openstack-cloud-controller-manager/main.go
Line 47 in 1bf5a4a
What you expected to happen:
rand.Seed(time.Now().UnixNano())
is left untouched, or is somehow replaced in the whole binary codebase by using the result ofrand.NewSource(time.Now().UnixNano())
.How to reproduce it:
Anything else we need to know?:
Environment:
The text was updated successfully, but these errors were encountered: