Implement minimal job confirmation API in Runner Core

As per Joe's comment here: gitlab#464048 (comment 2717231778)

This will be the minimal implementation of the job confirmation API in Runner Core.

The new workflow will immediately send a status update to the GitLab API if the API sents the features.JobStatus feature. This will indicate to Runner that it should provide status updates.

Approach 1

This is closer the original proposal at Capstone issue: Introduce new API for Runner to... (gitlab#464048) • Pedro Pombeiro • 18.7 • On track but is not strictly required for this stage. We could simplify both the Runner and Backend work a bit if we decide to go with Approach 2 by not introducing a new endpoint now. Instead, the API will just need to make sure not to automatically transition jobs into a Running state once they are sent to the Runner (along other side duties such as cleaning up after timeout etc).

Endpoint name TBD but not really important

sequenceDiagram
    participant G as GitLab
    participant R as Runner


    R->>G: GET /jobs/request
    Note over R,G: New workflow on top of the current bare job acceptance
    G-->>R: 201 Created (with features.JobStatus)

    R->>G: POST /jobs/{:job_id}/runner_status {status=running}

Changes should be contained to:

Approach 2

Alternatively we could leverage the UpdateJob method that we already have which sends a PUT /jobs/{:job_id}. We just need to test how this endpoint behaves when only the state is being updated.

I suspect this will work:

sequenceDiagram
    participant G as GitLab
    participant R as Runner


    R->>G: GET /jobs/request
    Note over R,G: New workflow on top of the current bare job acceptance
    G-->>R: 201 Created (with features.JobStatus)

    R->>G: PUT /jobs/{:job_id} {state=running}

Changes should be contained to:

Edited by Georgi N. Georgiev | GitLab