Skip to content

Add retry:exit_codes retry mechanism

What does this MR do and why?

👋 This MR is the second one of a little series to add retry:exit_codes to the CI Config.

It includes:

  • Implementation of the retry mechanism based on the exit code of the job and the retry:exit_codes added in the config (see !135430 (merged) )

New syntax

job:
  script: echo 'hello job script'
  retry:
    max: 2
    exit_codes:
      - 137
      - 255

OR.

job:
  script: echo 'hello job script'
  retry:
    max: 2
    exit_codes: 137

Same behaviours as allowed_failures:exit_codes

Tests

I did some integrations tests and it works as wanted !

build-job:
  stage: test
  tags:
    - "test_maison"
  retry:
    max: 2
    exit_codes: 100
  script:
    - sleep 10
    - exit 100

image

Database Migration

db:check-migration job: https://gitlab.com/gitlab-org/gitlab/-/jobs/6134541214

$ scripts/db_tasks db:migrate:down VERSION=20240130201017
Running: `bundle exec rake db:migrate:down:main VERSION=20240130201017`
main: == [advisory_lock_connection] object_id: 108520, pg_backend_pid: 123
main: == 20240130201017 AddExitCodeToBuildsMetadata: reverting ======================
main: -- remove_column(:p_ci_builds_metadata, :exit_code, :integer, {:null=>true})
main:    -> 0.0020s
main: == 20240130201017 AddExitCodeToBuildsMetadata: reverted (0.0111s) =============
main: == [advisory_lock_connection] object_id: 108520, pg_backend_pid: 123
$ scripts/db_tasks db:schema:dump
Running: `bundle exec rake db:schema:dump:main`
$ git diff master -- db/structure.sql
$ scripts/db_tasks db:migrate
Running: `bundle exec rake db:migrate:main`
main: == [advisory_lock_connection] object_id: 108420, pg_backend_pid: 156
main: == 20240130201017 AddExitCodeToBuildsMetadata: migrating ======================
main: -- add_column(:p_ci_builds_metadata, :exit_code, :integer, {:null=>true})
main:    -> 0.0021s
main: == 20240130201017 AddExitCodeToBuildsMetadata: migrated (0.0083s) =============
main: == [advisory_lock_connection] object_id: 108420, pg_backend_pid: 156

Implementation table

Step Status
1. Add exit_codes to retry class !135430 (merged)
2. Update retry business logic <-- This MR
3. Update CI json schema and documentation !137348 (merged)

MR acceptance checklist

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

Related to #262674 (closed)

Feature Flag: #430037 (closed)

Edited by Baptiste Lalanne

Merge request reports