Skip to content

Commit 9678a21

Browse files
committed
Matrix: retry docker push on exception, drop to 3 attempts
push() throwing was bypassing the verify loop and failing the build immediately. Wrap push() so a thrown push counts as one of the retry attempts alongside the post-push visibility check. Aligns with review feedback that Harbor push itself is a flaky surface, not only the post-push registry visibility race. Lower attempts from 6 to 3 since the loop now covers both failure modes with one budget.
1 parent f0edcd3 commit 9678a21

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/com/mellanox/cicd/Matrix.groovy

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,18 +1190,27 @@ def buildImage(img, filename, extra_args, config, image) {
11901190
}
11911191

11921192
def pushAndVerify(customImage, String img, config) {
1193-
def attempts = 6
1193+
def attempts = 3
11941194
def delaySeconds = 10
11951195

11961196
for (int i=1; i<=attempts; i++) {
1197-
customImage.push()
1198-
if (imageExistsInRegistry(img, config)) {
1197+
def pushed = false
1198+
try {
1199+
customImage.push()
1200+
pushed = true
1201+
} catch (Exception e) {
1202+
config.logger.warn("docker push failed - ${img} - attempt ${i}/${attempts}: ${e.message}")
1203+
}
1204+
1205+
if (pushed && imageExistsInRegistry(img, config)) {
11991206
config.logger.info("Verified pushed image in registry - ${img}")
12001207
return
12011208
}
12021209

12031210
if (i < attempts) {
1204-
config.logger.warn("Pushed image is not visible in registry yet - ${img} - retry ${i}/${attempts}")
1211+
if (pushed) {
1212+
config.logger.warn("Pushed image is not visible in registry yet - ${img} - retry ${i}/${attempts}")
1213+
}
12051214
sleep(time: delaySeconds, unit: 'SECONDS')
12061215
}
12071216
}

0 commit comments

Comments
 (0)