fix: add random wait value

[skip ci]
This commit is contained in:
Marcel S. Henselin 2026-03-13 20:49:58 +01:00
parent d1267260cb
commit c1f463935b

View file

@ -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)