Skip to content
Open
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
9 changes: 6 additions & 3 deletions scripts/cue-publish/cue-publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,19 @@ func main() {
retryMaxAttempts := 10
// Initial sleep duration between retries: random value between 1s and 10s
sleepBetweenRetries := (1 + time.Duration(rand.Int64N(9))) * time.Second
for attempt := 1; attempt <= retryMaxAttempts; attempt++ {
doesItFail := true
for attempt := 1; attempt <= retryMaxAttempts && doesItFail; attempt++ {
// Wait for a few seconds immediately before the first attempt to reduce collision risk with other jobs running in parallel.
time.Sleep(sleepBetweenRetries)
if err := command.Run("cue", "mod", "publish", version); err != nil {
logrus.WithError(err).Warnf("Attempt %d/%d: Error publishing the module, retrying...", attempt, retryMaxAttempts)
if attempt == retryMaxAttempts {
logrus.Fatal("Max retry attempts reached, failing the publish process")
}
// Wait for a few seconds before retrying
time.Sleep(sleepBetweenRetries)
// Increase the sleep duration for the next attempt with a random value to reduce collision risk with other jobs running in parallel.
sleepBetweenRetries = sleepBetweenRetries + (1+time.Duration(rand.Int64N(19)))*time.Second
} else {
doesItFail = false
}
}
logrus.Infof("CUE module %s published successfully", module)
Expand Down
Loading