Skip to content

Report that the Runner returns exit codes

Marius Bobin requested to merge ci-report-exit-codes-ff into master

What does this MR do?

We've recently introduced !2562 (merged) which returns the job's exit code back to Rails and we need a way to check if the Runner supports this feature before assigning a job that requires this feature to it: gitlab!49462 (comment 472056902)

Why was this MR needed?

We want to ensure job status consistency. If a job is executed by multiple runners, using different versions, the status might be set to failed instead of the allowed failure.

What's the best way to test this MR?

Add this line to the Rails codebase to log the parameters in a more readable form:

diff --git a/lib/api/ci/runner.rb b/lib/api/ci/runner.rb
index 86e1a939df1..c8f8dd8aeef 100644
--- a/lib/api/ci/runner.rb
+++ b/lib/api/ci/runner.rb
@@ -128,6 +128,7 @@ class Runner < ::API::Base
         parser :build_json, ::Grape::Parser::Json
 
         post '/request' do
+          File.open('log/request_job.log', 'wb') { |f| f.write JSON.pretty_generate(params) }
           authenticate_runner!
 
           unless current_runner.active?

Start the runner and create a new pipeline. The log/request_job.log file should include "return_exit_code": true.

{
  "info": {
    "name": "gitlab-runner",
    "version": "13.8.0~beta.44.ged2cc28f",
    "revision": "ed2cc28f",
    "platform": "darwin",
    "architecture": "amd64",
    "executor": "kubernetes",
    "shell": "bash",
    "features": {
      "variables": true,
      "image": true,
      "services": true,
      "artifacts": true,
      "cache": true,
      "shared": false,
      "upload_multiple_artifacts": true,
      "upload_raw_artifacts": true,
      "session": true,
      "terminal": true,
      "refspecs": true,
      "masking": true,
      "proxy": true,
      "raw_variables": true,
      "artifacts_exclude": true,
      "multi_build_steps": true,
      "trace_reset": true,
      "trace_checksum": true,
      "trace_size": true,
      "vault_secrets": true,
      "cancelable": true,
      "return_exit_code": true
    }
  },
  "token": "token"
}

What are the relevant issue numbers?

gitlab#273157 (closed)

Edited by Marius Bobin

Merge request reports