Use `AgentTokensFinder` to find single agent tokens
What does this MR do and why?
The AgentTokensFinder
was introduced in these MRs: !103170 (merged) & !104038 (merged) and used for fetching all agent tokens of an agent.
Here, the AgentTokensFinder
class is used for fetching a single agent_token record in the GET /projects/:id/cluster_agents/:agent_id/tokens/:token_id
endpoint. The FinderMethods
module is included to support finding a single record.
Note that this follows the original behavior of returning the token regardless of status (active or revoked).
Issue: #363119 (closed)
Screenshots or screen recordings
Setup
Example project (ID=27):
Project Agent -> Tokens page
Project agent and agent tokens in the database
Test
Fetching a single agent token
Fetching a single agent token that is revoked
When specified agent_id is not under the specified project
When specified agent does not exist
How to set up and validate locally
Setup
- Create a project (or use an existing one)
-
Set up an agent in that project
- This will register an agent and create one agent token
- Create more agent tokens:
- Go to project Infrastructure -> Kubernetes clusters page
- Go to the agent's page
- Select the Access tokens tab
- Click the Create token button
Validate
Use curl
to test the API endpoint
-
Set up a project or personal access token to make sure your curl request is authorized
-
Run the following
curl
request:curl -ki -X GET \ --header "Authorization: Bearer <your project or personal access token>" \ "https://<local gitlab url>/api/v4/projects/<project_id>/cluster_agents/<agent_id>/tokens/<token_id>"
Example:
curl -ki -X GET \ --header "Authorization: Bearer <token>" \ "https://gdk.test:3443/api/v4/projects/27/cluster_agents/7/tokens/6"
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Merge request reports
Activity
assigned to @partiaga
- A deleted user
added backend database databasereview pending labels
1 Warning This merge request does not refer to an existing milestone. 1 Message This merge request adds or changes files that require a review from the Database team. This merge request requires a database review. To make sure these changes are reviewed, take the following steps:
- Ensure the merge request has database and databasereview pending labels. If the merge request modifies database files, Danger will do this for you.
- Prepare your MR for database review according to the docs.
- Assign and mention the database reviewer suggested by Reviewer Roulette.
The following files require a review from the Database team:
app/finders/clusters/agent_tokens_finder.rb
Reviewer roulette
Changes that require review have been detected!
Please refer to the table below for assigning reviewers and maintainers suggested by Danger in the specified category:
Category Reviewer Maintainer backend Dominic Bauer (
@bauerdominic
) (UTC+1)Vitali Tatarintev (
@ck3g
) (UTC+1)database Eulyeon K. (
@euko
) (UTC+9)Adam Hegyi (
@ahegyi
) (UTC+1)To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
Dangeradded devopsconfigure [DEPRECATED] groupconfigure [DEPRECATED] maintenancerefactor sectionops typemaintenance labels and removed database databasereview pending labels
Allure report
allure-report-publisher
generated test report!e2e-review-qa:
test report for e212a783expand test summary
+-----------------------------------------------------------------------------------------+ | suites summary | +------------------------------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Create | 28 | 0 | 1 | 0 | 29 | ✅ | | Plan | 49 | 0 | 1 | 0 | 50 | ✅ | | Manage | 39 | 0 | 4 | 3 | 43 | ❗ | | Configure | 0 | 0 | 3 | 0 | 3 | ➖ | | Verify | 12 | 0 | 1 | 0 | 13 | ✅ | | Govern | 10 | 0 | 5 | 1 | 15 | ❗ | | Feature flag handler sanity checks | 9 | 0 | 0 | 0 | 9 | ✅ | | Package | 0 | 0 | 1 | 0 | 1 | ➖ | | Version sanity check | 0 | 0 | 1 | 0 | 1 | ➖ | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Total | 147 | 0 | 17 | 4 | 164 | ❗ | +------------------------------------+--------+--------+---------+-------+-------+--------+
mentioned in merge request !103300 (merged)
- Resolved by Pam Artiaga
mentioned in merge request !103170 (merged)
added 4 commits
-
f6261f2f...2cec222d - 2 commits from branch
pam/agent-tokens-finder
- 3794f664 - Use AgentTokensFinder in API endpoint for fetching a single token
- bc9aa460 - Add test for revoked agent_token
-
f6261f2f...2cec222d - 2 commits from branch
- A deleted user
added database databasereview pending labels
Hi @Alexand @timofurrer could you also give this a
please.requested review from @Alexand and @timofurrer
- Resolved by Pam Artiaga
@partiaga I really appreciate the great MR descriptions in all of the MRs in this series. Thank you!
@timofurrer
, thanks for approving this merge request.This is the first time the merge request is approved. To ensure full test coverage, a new pipeline will be started shortly.
For more info, please refer to the following links:
removed review request for @timofurrer
added 1113 commits
-
03476a44...6892a52f - 1110 commits from branch
master
- 1013234c - Use AgentTokensFinder in API endpoint for fetching a single token
- adb81e1f - Add test for revoked agent_token
- b2ec84a9 - Test status of the agent token
Toggle commit list-
03476a44...6892a52f - 1110 commits from branch
Hi @Alexand did you have any comments about this MR? Will assign to the maintainer if not
Btw, the review-app deploy step is running into timeouts and currently being investigated, thus the failed pipeline. The MR code still be ok to review
mentioned in merge request !103897 (merged)
- Resolved by Pam Artiaga
- Resolved by João Alexandre Cunha
- Resolved by Pam Artiaga
Thanks, @partiaga.
I've only had 2 very minor suggestions. Since those are really trivial to fix, I'll approve this so you don't have to wait for another review cycle from me. So feel free to pass forward to the database and backend maintainers after you address those 2 threads. But also feel free to send it back to me if you'd like.
Edited by João Alexandre Cunhaadded databasereviewed label and removed databasereview pending label
removed review request for @Alexand
- Resolved by Pam Artiaga
Putting this on
Draft
for now until the discussion here is resolved: !103897 (comment 1170436850)
mentioned in merge request !104038 (merged)
added 396 commits
-
4ea0da28...8fdbfce3 - 390 commits from branch
master
- fb99ead1 - Update AgentTokensFinder to expect agent argument
- 6e2f447e - Use AgentTokensFinder in API endpoint for fetching a single token
- 06462eda - Add test for revoked agent_token
- 7d67b994 - Test status of the agent token
- 2df9f0e9 - Follow testing guidelines
- 81594b1c - Pass the agent as argument to AgentTokensFinder
Toggle commit list-
4ea0da28...8fdbfce3 - 390 commits from branch
added 7 commits
-
cd9d5f72 - 1 commit from branch
pam/agent-tokens-finder-agent-arg
- 3be71988 - Use AgentTokensFinder in API endpoint for fetching a single token
- 52caa594 - Add test for revoked agent_token
- fd6202cc - Test status of the agent token
- dac47858 - Follow testing guidelines
- e29f3551 - Pass the agent as argument to AgentTokensFinder
- 00c3e7e3 - Update arguments passed to AgentTokensFinder
Toggle commit list-
cd9d5f72 - 1 commit from branch
added 7 commits
-
6017ef6b - 1 commit from branch
pam/agent-tokens-finder-agent-arg
- 2fecb209 - Use AgentTokensFinder in API endpoint for fetching a single token
- 6acd2596 - Add test for revoked agent_token
- 3c6853fd - Test status of the agent token
- d6802ed5 - Follow testing guidelines
- 7ff3b932 - Pass the agent as argument to AgentTokensFinder
- 55e2ad74 - Update arguments passed to AgentTokensFinder
Toggle commit list-
6017ef6b - 1 commit from branch
added 1031 commits
-
55e2ad74...e51f4c53 - 1025 commits from branch
master
- 7a11edce - Use AgentTokensFinder in API endpoint for fetching a single token
- efa13a2f - Add test for revoked agent_token
- c97f6644 - Test status of the agent token
- a9523cf8 - Follow testing guidelines
- 2e1833f1 - Pass the agent as argument to AgentTokensFinder
- b1b594da - Update arguments passed to AgentTokensFinder
Toggle commit list-
55e2ad74...e51f4c53 - 1025 commits from branch
added 2 commits
requested review from @Alexand
- Resolved by Pam Artiaga
removed review request for @Alexand
- Resolved by Vitali Tatarintev
added databaseapproved label and removed databasereviewed label
removed review request for @ahegyi
mentioned in commit a65a5c92
added workflowstaging-canary label
added workflowcanary label and removed workflowstaging-canary label
added workflowstaging label and removed workflowcanary label
added workflowproduction label and removed workflowstaging label
added workflowpost-deploy-db-staging label and removed workflowproduction label
added workflowpost-deploy-db-production label and removed workflowpost-deploy-db-staging label
mentioned in issue Alexand/growth-and-development#1 (closed)
changed milestone to %15.7
added releasedcandidate label
added releasedpublished label and removed releasedcandidate label
added groupenvironments label and removed groupconfigure [DEPRECATED] label