diff --git a/stackit/internal/wait/postgresflexalpha/wait.go b/stackit/internal/wait/postgresflexalpha/wait.go index 131a14d3..730ccbe3 100644 --- a/stackit/internal/wait/postgresflexalpha/wait.go +++ b/stackit/internal/wait/postgresflexalpha/wait.go @@ -2,10 +2,11 @@ package postgresflexalpha import ( "context" + "crypto/rand" "errors" "fmt" "math" - "math/rand/v2" + "math/big" "net/http" "time" @@ -142,7 +143,13 @@ func CreateInstanceWaitHandler( "failedCount": failedCount, }, ) - time.Sleep(time.Duration(rand.IntN(120)) * time.Second) //nolint:gosec // not that important and temporary + var waitCounter int64 = 1 + maxWait := big.NewInt(7) + n, err := rand.Int(rand.Reader, maxWait) + if err == nil { + waitCounter = n.Int64() + 1 + } + time.Sleep(time.Duration(waitCounter*30) * time.Second) //nolint:gosec // not that important and temporary return false, nil, nil } return true, s, fmt.Errorf( @@ -218,7 +225,13 @@ func PartialUpdateInstanceWaitHandler( "failedCount": failedCount, }, ) - time.Sleep(time.Duration(rand.IntN(120)) * time.Second) //nolint:gosec // not that important and temporary + var waitCounter int64 = 1 + maxWait := big.NewInt(7) + n, err := rand.Int(rand.Reader, maxWait) + if err == nil { + waitCounter = n.Int64() + 1 + } + time.Sleep(time.Duration(waitCounter*30) * time.Second) //nolint:gosec // not that important and temporary return false, nil, nil } return true, s, fmt.Errorf( @@ -352,7 +365,13 @@ func DeleteInstanceWaitHandler( "failedCount": failedCount, }, ) - time.Sleep(time.Duration(rand.IntN(120)) * time.Second) //nolint:gosec // not that important and temporary + var waitCounter int64 = 1 + maxWait := big.NewInt(7) + n, err := rand.Int(rand.Reader, maxWait) + if err == nil { + waitCounter = n.Int64() + 1 + } + time.Sleep(time.Duration(waitCounter*30) * time.Second) //nolint:gosec // not that important and temporary return false, nil, nil } return true, nil, fmt.Errorf("wait handler got status FAILURE for instance: %s", instanceID)