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

Backport of fix: revert go mod compat for sdk,api to 1.19 into release/1.15.x #16328

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
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hashicorp/consul/api

go 1.20
go 1.19

replace github.com/hashicorp/consul/sdk => ../sdk

Expand Down
2 changes: 1 addition & 1 deletion envoyextensions/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hashicorp/consul/envoyextensions

go 1.20
go 1.19

replace github.com/hashicorp/consul/api => ../api

Expand Down
6 changes: 5 additions & 1 deletion sdk/freeport/freeport.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ var (
// total is the total number of available ports in the block for use.
total int

// seededRand is a random generator that is pre-seeded from the current time.
seededRand *rand.Rand

// stopCh is used to signal to background goroutines to terminate. Only
// really exists for the safety of reset() during unit tests.
stopCh chan struct{}
Expand Down Expand Up @@ -114,6 +117,7 @@ func initialize() {
panic("freeport: block size too big or too many blocks requested")
}

seededRand = rand.New(rand.NewSource(time.Now().UnixNano())) // This is compatible with go 1.19 but unnecessary in >= go1.20
firstPort, lockLn = alloc()

condNotEmpty = sync.NewCond(&mu)
Expand Down Expand Up @@ -255,7 +259,7 @@ func adjustMaxBlocks() (int, error) {
// be automatically released when the application terminates.
func alloc() (int, net.Listener) {
for i := 0; i < attempts; i++ {
block := int(rand.Int31n(int32(effectiveMaxBlocks)))
block := int(seededRand.Int31n(int32(effectiveMaxBlocks)))
firstPort := lowPort + block*blockSize
ln, err := net.ListenTCP("tcp", tcpAddr("127.0.0.1", firstPort))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion sdk/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hashicorp/consul/sdk

go 1.20
go 1.19

require (
github.com/hashicorp/go-cleanhttp v0.5.1
Expand Down
2 changes: 1 addition & 1 deletion troubleshoot/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hashicorp/consul/troubleshoot

go 1.20
go 1.19

replace github.com/hashicorp/consul/api => ../api

Expand Down