Child pipelines and their jobs are not found by API endpoints
Summary
Unable to perform API calls on a child-pipeline. Running 12.7.6-ee (32aad7c4) (Free license).
Steps to reproduce
Given CI_PROJECT_ID
of 123
...
- Have a pipeline containing a child pipeline:
###
# .gitlab-ci.yml
stages:
- stage1
- stage2
- stage3
job1:
stage: stage1
script:
- echo "job1"
job2:
stage: stage2
trigger:
strategy: depend
include: ".gitlab-ci.child.yml"
job3:
stage: stage2
trigger:
strategy: depend
include: ".gitlab-ci.child.yml"
job4:
stage: stage3
script:
- echo "job4"
###
# .gitlab-ci.child.yml
stages:
- child-stage1
child-job1:
stage: child-stage1
script:
- echo "child-job1"
- Run this pipeline (resulting in ID
12345
and child ID12346
) - Call the API on the parent and child pipelines
Example Project
n/a
What is the current bug behavior?
-
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12345/jobs
: missingjob2
andjob3
and no reference to the created child-pipelines -
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12346
: HTTP 404 -
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12346/jobs
: HTTP 404
What is the expected correct behavior?
-
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12345/jobs
showing alsojob2
andjob3
in some way, with some reference to the created child-pipelines -
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12346
showing details on the child-pipeline -
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12346/jobs
showing jobs of the child-pipeline (in the same way as the parent pipeline)
Relevant logs and/or screenshots
# jobs of parent pipeline
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12345/jobs
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 19 Feb 2020 11:18:20 GMT
Content-Type: application/json
Content-Length: 3477
Connection: keep-alive
Cache-Control: max-age=0, private, must-revalidate
Etag: W/"ce5fe6c65395f9fd691095864c7d5b40"
Link: <https://gitlab.example.com/api/v4/projects/123/pipelines/12345/jobs?id=123&page=1&per_page=20&pipeline_id=12345>; rel="first", <https://gitlab.example.com/api/v4/projects/123/pipelines/12345/jobs?id=123&page=1&per_page=20&pipeline_id=12345>; rel="last"
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Next-Page:
X-Page: 1
X-Per-Page: 20
X-Prev-Page:
X-Request-Id: JQZhpGJzxJ1
X-Runtime: 0.114634
X-Total: 2
X-Total-Pages: 1
Strict-Transport-Security: max-age=31536000
Referrer-Policy: strict-origin-when-cross-origin
[
{
"id": 23456,
"status": "success",
"stage": "stage1",
"name": "job1",
"ref": "master",
"tag": false,
"coverage": null,
"allow_failure": false,
"created_at": "2020-02-18T15:42:32.002Z",
"started_at": "2020-02-18T15:42:35.324Z",
"finished_at": "2020-02-18T15:42:51.978Z",
"duration": 16.654342,
"user": {
"id": 1,
"name": "My Name",
"username": "my.user",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/1/avatar.png",
"web_url": "https://gitlab.example.com/my.user",
"created_at": "2018-07-31T08:35:42.223Z",
"bio": "",
"location": "",
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
},
"commit": {
"id": "2f3e6708487de7438e42f5872806944283be7723",
"short_id": "2f3e6708",
"created_at": "2020-02-18T16:42:27.000+01:00",
"parent_ids": [
"f922840acccb444795c9b06cb49f7729d5aa9bcb"
],
"title": "envs",
"message": "envs\n",
"author_name": "My User",
"author_email": "my.user@my.email",
"authored_date": "2020-02-18T16:42:27.000+01:00",
"committer_name": "My User",
"committer_email": "my.user@my.email",
"committed_date": "2020-02-18T16:42:27.000+01:00"
},
"pipeline": {
"id": 12345,
"sha": "2f3e6708487de7438e42f5872806944283be7723",
"ref": "master",
"status": "success",
"created_at": "2020-02-18T15:42:31.990Z",
"updated_at": "2020-02-18T15:43:28.223Z",
"web_url": "https://gitlab.example.com/my.user/my-pipeline-poc/pipelines/12345"
},
"web_url": "https://gitlab.example.com/my.user/my-pipeline-poc/-/jobs/23456",
"artifacts": [
{
"file_type": "trace",
"size": 4630,
"filename": "job.log",
"file_format": null
}
],
"runner": {
"id": 1,
"description": "gitlab-runner-01",
"ip_address": "1.2.3.4",
"active": true,
"is_shared": false,
"name": "gitlab-runner",
"online": true,
"status": "online"
},
"artifacts_expire_at": null
},
{
"id": 23457,
"status": "success",
"stage": "stage3",
"name": "job4",
"ref": "master",
"tag": false,
"coverage": null,
"allow_failure": false,
"created_at": "2020-02-18T15:42:32.031Z",
"started_at": "2020-02-18T15:43:11.338Z",
"finished_at": "2020-02-18T15:43:28.109Z",
"duration": 16.770916,
"user": {
"id": 1,
"name": "My Name",
"username": "my.user",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/1/avatar.png",
"web_url": "https://gitlab.example.com/my.user",
"created_at": "2018-07-31T08:35:42.223Z",
"bio": "",
"location": "",
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
},
"commit": {
"id": "2f3e6708487de7438e42f5872806944283be7723",
"short_id": "2f3e6708",
"created_at": "2020-02-18T16:42:27.000+01:00",
"parent_ids": [
"f922840acccb444795c9b06cb49f7729d5aa9bcb"
],
"title": "envs",
"message": "envs\n",
"author_name": "My User",
"author_email": "my.user@my.email",
"authored_date": "2020-02-18T16:42:27.000+01:00",
"committer_name": "My User",
"committer_email": "my.user@my.email",
"committed_date": "2020-02-18T16:42:27.000+01:00"
},
"pipeline": {
"id": 12345,
"sha": "2f3e6708487de7438e42f5872806944283be7723",
"ref": "master",
"status": "success",
"created_at": "2020-02-18T15:42:31.990Z",
"updated_at": "2020-02-18T15:43:28.223Z",
"web_url": "https://gitlab.example.com/my.user/my-pipeline-poc/pipelines/12345"
},
"web_url": "https://gitlab.example.com/my.user/my-pipeline-poc/-/jobs/23457",
"artifacts": [
{
"file_type": "trace",
"size": 4444,
"filename": "job.log",
"file_format": null
}
],
"runner": {
"id": 1,
"description": "gitlab-runner-01",
"ip_address": "1.2.3.4",
"active": true,
"is_shared": false,
"name": "gitlab-runner",
"online": true,
"status": "online"
},
"artifacts_expire_at": null
}
]
###
# child pipeline
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12346
HTTP/1.1 404 Not Found
Server: nginx
Date: Wed, 19 Feb 2020 11:27:16 GMT
Content-Type: application/json
Content-Length: 27
Connection: keep-alive
Cache-Control: no-cache
Vary: Origin
X-Request-Id: lV0dNzx54i8
X-Runtime: 0.067778
{
"message": "404 Not found"
}
###
# jobs of child pipeline
GET https://gitlab.example.com/api/v4/projects/123/pipelines/12346/jobs
HTTP/1.1 404 Not Found
Server: nginx
Date: Wed, 19 Feb 2020 11:28:48 GMT
Content-Type: application/json
Content-Length: 27
Connection: keep-alive
Cache-Control: no-cache
Vary: Origin
X-Request-Id: shWM36bdKZ9
X-Runtime: 0.041495
{
"message": "404 Not found"
}
###
# specific job of child pipeline, requested on project level
GET https://gitlab.example.com/api/v4/projects/123/jobs/23457
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 19 Feb 2020 11:30:16 GMT
Content-Type: application/json
Content-Length: 1836
Connection: keep-alive
Cache-Control: max-age=0, private, must-revalidate
Etag: W/"8069405d93e9b476dfba08b5fe95c38b"
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: kbGZrMP2eE8
X-Runtime: 0.095520
Strict-Transport-Security: max-age=31536000
Referrer-Policy: strict-origin-when-cross-origin
{
"id": 23457,
"status": "success",
"stage": "child-stage1",
"name": "child-job1",
"ref": "master",
"tag": false,
"coverage": null,
"allow_failure": true,
"created_at": "2020-02-18T16:06:40.629Z",
"started_at": "2020-02-18T16:22:59.608Z",
"finished_at": "2020-02-18T16:23:16.376Z",
"duration": 16.768032,
"user": {
"id": 1,
"name": "My Name",
"username": "my.user",
"state": "active",
"avatar_url": "https://gitlab.example.com/uploads/-/system/user/avatar/1/avatar.png",
"web_url": "https://gitlab.example.com/my.user",
"created_at": "2018-07-31T08:35:42.223Z",
"bio": "",
"location": "",
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
},
"commit": {
"id": "87e9b298b8b92a2a08ed9575a1da125726af6218",
"short_id": "87e9b298",
"created_at": "2020-02-18T17:06:14.000+01:00",
"parent_ids": [
"4f3cc7a7e38379385fe848e4c0cba5b20f37846e"
],
"title": "poc",
"message": "poc\n",
"author_name": "My User",
"author_email": "my.user@my.email",
"authored_date": "2020-02-18T17:06:14.000+01:00",
"committer_name": "My User",
"committer_email": "my.user@my.email",
"committed_date": "2020-02-18T17:06:14.000+01:00"
},
"pipeline": {
"id": 12346,
"sha": "87e9b298b8b92a2a08ed9575a1da125726af6218",
"ref": "master",
"status": "success",
"created_at": "2020-02-18T16:06:40.598Z",
"updated_at": "2020-02-18T16:23:16.545Z",
"web_url": "https://gitlab.example.com/my.user/my-pipeline-poc/pipelines/12346"
},
"web_url": "https://gitlab.example.com/my.user/my-pipeline-poc/-/jobs/23457",
"artifacts": [
{
"file_type": "trace",
"size": 4814,
"filename": "job.log",
"file_format": null
}
],
"runner": {
"id": 22,
"description": "gitlab-runner-01",
"ip_address": "1.2.3.4",
"active": true,
"is_shared": false,
"name": "gitlab-runner",
"online": true,
"status": "online"
},
"artifacts_expire_at": null
}
Output of checks
n/a
Results of GitLab environment info
root@gitlab-01:~# gitlab-rake gitlab:env:info
System information
System: Ubuntu 18.04
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.6.5p114
Gem Version: 2.7.10
Bundler Version:1.17.3
Rake Version: 12.3.3
Redis Version: 5.0.7
Git Version: 2.24.1
Sidekiq Version:5.2.7
Go Version: unknown
GitLab information
Version: 12.7.6-ee
Revision: 32aad7c42f1
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 10.9
URL: https://gitlab.example.com
HTTP Clone URL: https://gitlab.example.com/some-group/some-project.git
SSH Clone URL: git@gitlab.example.com:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: yes
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 11.0.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
root@gitlab-01:~# gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 11.0.0 ? ... OK (11.0.0)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: OK
Redis available via internal API: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
User output sanitized. Found 100 users of 100 limit.
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... no
Try fixing it:
sudo chown -R git /var/opt/gitlab/gitlab-rails/uploads
sudo find /var/opt/gitlab/gitlab-rails/uploads -type f -exec chmod 0644 {} \;
sudo find /var/opt/gitlab/gitlab-rails/uploads -type d -not -path /var/opt/gitlab/gitlab-rails/uploads -exec chmod 0700 {} \;
For more information see:
doc/install/installation.md in section "GitLab"
Please fix the error above and rerun the checks.
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Projects have namespace: ...
49/1 ... yes
49/2 ... yes
49/3 ... yes
49/4 ... yes
49/5 ... yes
49/6 ... yes
49/8 ... yes
49/10 ... yes
49/12 ... yes
49/14 ... yes
49/18 ... yes
49/19 ... yes
49/21 ... yes
91/22 ... yes
49/24 ... yes
49/25 ... yes
94/28 ... yes
49/30 ... yes
76/31 ... yes
95/32 ... yes
49/34 ... yes
92/36 ... yes
91/37 ... yes
49/38 ... yes
49/39 ... yes
49/40 ... yes
49/42 ... yes
49/43 ... yes
49/44 ... yes
49/45 ... yes
49/46 ... yes
49/47 ... yes
49/48 ... yes
49/49 ... yes
49/52 ... yes
49/53 ... yes
49/54 ... yes
49/59 ... yes
49/60 ... yes
49/61 ... yes
91/62 ... yes
49/63 ... yes
92/64 ... yes
49/65 ... yes
91/66 ... yes
49/67 ... yes
49/68 ... yes
49/69 ... yes
30/72 ... yes
49/74 ... yes
92/76 ... yes
49/78 ... yes
49/79 ... yes
49/80 ... yes
49/81 ... yes
49/82 ... yes
49/88 ... yes
49/89 ... yes
49/90 ... yes
49/91 ... yes
49/92 ... yes
49/93 ... yes
49/96 ... yes
65/99 ... yes
49/101 ... yes
49/103 ... yes
65/105 ... yes
49/106 ... yes
12/107 ... yes
65/108 ... yes
65/109 ... yes
65/112 ... yes
48/113 ... yes
65/114 ... yes
48/115 ... yes
76/116 ... yes
48/118 ... yes
48/119 ... yes
91/120 ... yes
49/121 ... yes
76/123 ... yes
12/124 ... yes
92/125 ... yes
92/126 ... yes
49/127 ... yes
54/129 ... yes
54/130 ... yes
93/133 ... yes
99/135 ... yes
99/136 ... yes
59/138 ... yes
59/140 ... yes
99/141 ... yes
94/142 ... yes
2/143 ... yes
54/144 ... yes
99/145 ... yes
59/146 ... yes
59/147 ... yes
54/149 ... yes
59/150 ... yes
92/151 ... yes
57/152 ... yes
54/153 ... yes
12/154 ... yes
14/155 ... yes
54/156 ... yes
2/157 ... yes
2/158 ... yes
2/159 ... yes
2/160 ... yes
92/162 ... yes
54/164 ... yes
67/165 ... yes
54/170 ... yes
67/172 ... yes
67/173 ... yes
67/174 ... yes
67/175 ... yes
67/179 ... yes
67/180 ... yes
67/181 ... yes
67/182 ... yes
67/183 ... yes
59/184 ... yes
97/185 ... yes
77/186 ... yes
77/188 ... yes
77/189 ... yes
65/190 ... yes
49/191 ... yes
80/192 ... yes
81/196 ... yes
49/202 ... yes
77/203 ... yes
12/204 ... yes
79/206 ... yes
83/207 ... yes
79/208 ... yes
83/213 ... yes
89/223 ... yes
79/230 ... yes
2/231 ... yes
83/233 ... yes
12/234 ... yes
12/235 ... yes
2/237 ... yes
2/242 ... yes
59/247 ... yes
98/261 ... yes
98/262 ... yes
98/263 ... yes
97/264 ... yes
97/265 ... yes
97/266 ... yes
98/267 ... yes
59/268 ... yes
86/270 ... yes
2/271 ... yes
101/272 ... yes
54/273 ... yes
2/275 ... yes
9/282 ... yes
54/284 ... yes
103/285 ... yes
77/286 ... yes
2/287 ... yes
103/288 ... yes
76/289 ... yes
104/290 ... yes
104/291 ... yes
59/292 ... yes
103/293 ... yes
59/294 ... yes
105/295 ... yes
59/296 ... yes
2/297 ... yes
108/304 ... yes
103/310 ... yes
110/311 ... yes
105/312 ... yes
112/313 ... yes
114/314 ... yes
86/316 ... yes
54/317 ... yes
54/318 ... yes
54/319 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.5.3 ? ... yes (2.6.5)
Git version >= 2.22.0 ? ... yes (2.24.1)
Git user has default SSH configuration? ... yes
Active users: ... 16
Is authorized keys file accessible? ... yes
Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Proposal
In this issue we are going to fix the 404
status that is returned for child pipelines. In #207996 (closed) instead we will fix the missing trigger jobs from the API response.
To fix the 404
we will need to find the pipeline and jobs within project.all_pipelines
instead of project.ci_pipelines
.