Skip to content

Retry a few times to verify the commit SHA

David Dieulivol requested to merge ddieulivol-retry_verify_commit_sha into master

What does this MR do and why?

The verify_commit_sha method when deploying review-apps might fail because the review apps containers are restarting, but the deployed commit sha might be correct.

This MR retries to do the check for two minutes before erroring out.

If after this change, we still notice some errors related to verify_commit_sha, I would propose to remove it, as it is supposed to catch a review-app container build issue, which is a very rare issue.

How to set up and validate locally

Success scenario

# Change this commit to the long version of the commit you'll see in https://gitlab-review-mastermain-mk1cr0.gitlab-review.app/api/v4/version
CI_COMMIT_SHA=4768912acba4a484d381b137911270bc9ae35d94
REVIEW_APPS_ROOT_TOKEN="redacted (`REVIEW_APPS_ROOT_TOKEN` in the CI/CD variables in gitlab-org/gitlab project)"
CI_ENVIRONMENT_URL=https://gitlab-review-mastermain-mk1cr0.gitlab-review.app

source scripts/review_apps/review-apps.sh
verify_commit_sha

Output:

 $ verify_commit_sha
[15:24:04] Checking the correct commit is deployed in the review-app:
Expected commit sha: aaeace537c331e25fc88034a512939bb3680ba3c
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   182  100   182    0     0    319      0 --:--:-- --:--:-- --:--:--   323
review-app revision: aaeace537c3

$ echo $?
0

Failure scenario

You might want to change for i in {1..60}; do for for i in {1..3}; do to avoid waiting for two minutes.

# Change this commit to the long version of the commit you'll see in https://gitlab-review-mastermain-mk1cr0.gitlab-review.app/api/v4/version
CI_COMMIT_SHA=woops
REVIEW_APPS_ROOT_TOKEN="redacted (`REVIEW_APPS_ROOT_TOKEN` in the CI/CD variables in gitlab-org/gitlab project)"
CI_ENVIRONMENT_URL=https://gitlab-review-mastermain-mk1cr0.gitlab-review.app

source scripts/review_apps/review-apps.sh
verify_commit_sha

Output:

$ verify_commit_sha
[15:08:37] Checking the correct commit is deployed in the review-app:
Expected commit sha: woops
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    30  100    30    0     0     69      0 --:--:-- --:--:-- --:--:--    69
review-app revision: null
[15:08:39] Checking the correct commit is deployed in the review-app:
Expected commit sha: woops
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    30  100    30    0     0    105      0 --:--:-- --:--:-- --:--:--   108
review-app revision: null
[15:08:41] Checking the correct commit is deployed in the review-app:
Expected commit sha: woops
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    30  100    30    0     0    106      0 --:--:-- --:--:-- --:--:--   109
review-app revision: null
[15:08:44] Review app revision is not the same as the current commit!

$ echo $?
1

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by David Dieulivol

Merge request reports

Loading