New /job/allowed_agents REST endpoint
What does this MR do?
Our Kubernetes agent would like to use the CI_JOB_TOKEN
as part of a new feature where it integrates with our CI.
Related issue: #324269 (closed)
Related epic: &5528
This MR will:
- Add new ee route
/job/allowed_agents
that returns requested job information and agent information - Add new agent finder
- Update associated tests and docs
DB query
explain SELECT "cluster_agents".* FROM "cluster_agents" WHERE "cluster_agents"."project_id" = 278964
Index Scan using index_cluster_agents_on_project_id_and_name on public.cluster_agents (cost=0.14..3.16 rows=1 width=53) (actual time=0.744..0.744 rows=0 loops=1)
Index Cond: (cluster_agents.project_id = 278964)
Buffers: shared hit=3 read=1
I/O Timings: read=0.708
https://console.postgres.ai/gitlab/gitlab-production-tunnel/sessions/3001/commands/9854
Example API response
{
"allowed_agents":
[
{
"id": 1,
"config_project": {
"id": 1,
"description": nil,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2021-03-26T14:51:50.579Z"
}
}
],
"job": {
"id": 1,
"name": "test",
"stage": "test",
"project_id": 1,
"project_name": "project1"
},
"pipeline": {
"id": 1,
"project_id": 1,
"sha": "b83d6e391c22777fca1ed3012fce84f633d7fed0",
"ref": "master",
"status": "pending",
"created_at": "2021-03-26T14:51:51.107Z",
"updated_at": "2021-03-26T14:51:51.107Z",
"web_url": "http://localhost/namespace1/project1/-/pipelines/1"
},
"project": {
"id": 1,
"description": nil,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2021-03-26T14:51:50.579Z"
},
"user": {
"id": 2,
"name": "John Doe3",
"username": "user2",
"state": "active",
"avatar_url": "https://www.gravatar.com/avatar/10fc7f102b",
"web_url": "http://localhost/user2"
}
}
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #324269 (closed)
Edited by Emily Ring