Skip to content
Snippets Groups Projects

Admin Token API: Add support for reading Cluster Agent Tokens

All threads resolved!
  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you can request access to GitLab Duo.

What does this MR do and why?

This MR adds support for retrieving information about cluster agent tokens to the Admin Token API. It does not support revoking yet - this will be done in a separate MR to keep things small.

:tools: with :heart: at Siemens

References

  • Issue that implements the token information API for the first few token types.

MR acceptance checklist

MR Checklist ( @nwittstruck)

How to set up and validate locally

  1. You'll need to create two new tokens:

    1. A personal access token with admin_mode and api capabilities at: Preferences > Access tokens > Add new token
    2. A cluster agent token that you can query:
    • If you have configured the GDK with gitlab_k8s_agent enabled, you can create a new cluster token at Any Project > Kubernetes clusters > Connect a cluster. You can now register a new agent.
    • You can also create a new token with rails c. This assumes there is at least project. This example uses the first project, feel free to choose any other project:
       agent = Clusters::Agent.new(name: 'test-agent', project: Project.first)
       agent.save
    
       token = Clusters::AgentToken.new(name: 'test-agent-token', agent: agent)
       # this will print the token:
       token.ensure_token
       # don't forget to save the token to be able to retrieve it:
       token.save
  2. Now you can retrieve information about this token:

curl -k --request POST \
--url 'https://gdk.test:3443/api/v4/admin/token' \
--header 'Authorization: Bearer <Admin Token from Step 1.>' \
--header 'Content-Type: application/json' \
--data '{"token": "glagent-token-from-step-1-2"}'

Related to #443597 (closed)

Edited by Nicholas Wittstruck

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Jon Glassman added 1 commit

    added 1 commit

    Compare with previous version

  • 1 Warning
    :warning: 401f5a1f: The commit body should not contain more than 72 characters per line. For more information, take a look at our Commit message guidelines.
    1 Message
    :book: This merge request adds or changes documentation files. A review from the Technical Writing team before you merge is recommended. Reviews can happen after you merge.

    Documentation review

    The following files require a review from a technical writer:

    The review does not need to block merging this merge request. See the:

    Reviewer roulette

    Category Reviewer Maintainer
    backend @missy-gitlab profile link current availability (UTC-5) @brytannia profile link current availability (UTC+1)

    Please refer to documentation page for guidance on how you can benefit from the Reviewer Roulette, or use the GitLab Review Workload Dashboard to find other available reviewers.

    If needed, you can retry the :repeat: danger-review job that generated this comment.

    Generated by :no_entry_sign: Danger

  • Jon Glassman removed review request for @jglassman1

    removed review request for @jglassman1

    • Resolved by James Nutt

      @nwittstruck can you please provide directions where to create those tokens as part of the instructions? The links you provided are specific to your own setup, I can update the port, but the second one seems to have some additional issues?

  • Nicholas Wittstruck changed the description

    changed the description

  • Nicholas Wittstruck added 1282 commits

    added 1282 commits

    Compare with previous version

  • added 1 commit

    • 401f5a1f - Admin Token API: Cluster Agent Tokens

    Compare with previous version

  • Janis Altherr approved this merge request

    approved this merge request

  • Janis Altherr requested review from @jnutt

    requested review from @jnutt

  • Before you set this MR to auto-merge

    This merge request will progress on pipeline tiers until it reaches the last tier: pipelinetier-3.

    Before you set this MR to auto-merge, please check the following:

    • You are the last maintainer of this merge request
    • The latest pipeline for this merge request is pipelinetier-3 (You can find which tier it is in the pipeline name)
    • This pipeline is recent enough (created in the last 8 hours)

    If all the criteria above apply, please set auto-merge for this merge request.

    See pipeline tiers and merging a merge request for more details.

  • James Nutt approved this merge request

    approved this merge request

  • James Nutt resolved all threads

    resolved all threads

  • James Nutt changed milestone to %17.7

    changed milestone to %17.7

  • James Nutt enabled automatic add to merge train when checks pass

    enabled automatic add to merge train when checks pass

  • E2E Test Result Summary

    allure-report-publisher generated test report!

    e2e-test-on-gdk: :white_check_mark: test report for 401f5a1f

    expand test summary
    +------------------------------------------------------------------+
    |                          suites summary                          |
    +-------------+--------+--------+---------+-------+-------+--------+
    |             | passed | failed | skipped | flaky | total | result |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Govern      | 75     | 0      | 3       | 0     | 78    | ✅     |
    | Plan        | 76     | 0      | 0       | 0     | 76    | ✅     |
    | Create      | 129    | 0      | 22      | 0     | 151   | ✅     |
    | Verify      | 43     | 0      | 2       | 0     | 45    | ✅     |
    | Data Stores | 33     | 0      | 1       | 0     | 34    | ✅     |
    | Manage      | 1      | 0      | 1       | 0     | 2     | ✅     |
    | Release     | 5      | 0      | 0       | 0     | 5     | ✅     |
    | Secure      | 4      | 0      | 0       | 0     | 4     | ✅     |
    | Analytics   | 2      | 0      | 0       | 0     | 2     | ✅     |
    | Monitor     | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Package     | 24     | 0      | 11      | 0     | 35    | ✅     |
    | Ai-powered  | 0      | 0      | 1       | 0     | 1     | ➖     |
    | Fulfillment | 2      | 0      | 0       | 0     | 2     | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Total       | 402    | 0      | 41      | 0     | 443   | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+

    e2e-test-on-cng: :white_check_mark: test report for 401f5a1f

    expand test summary
    +------------------------------------------------------------------+
    |                          suites summary                          |
    +-------------+--------+--------+---------+-------+-------+--------+
    |             | passed | failed | skipped | flaky | total | result |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Plan        | 86     | 0      | 8       | 0     | 94    | ✅     |
    | Create      | 140    | 0      | 20      | 0     | 160   | ✅     |
    | Monitor     | 8      | 0      | 12      | 0     | 20    | ✅     |
    | Govern      | 84     | 0      | 9       | 1     | 93    | ✅     |
    | Manage      | 1      | 0      | 9       | 0     | 10    | ✅     |
    | Package     | 24     | 0      | 14      | 0     | 38    | ✅     |
    | Verify      | 49     | 0      | 16      | 0     | 65    | ✅     |
    | Secure      | 2      | 0      | 5       | 0     | 7     | ✅     |
    | Fulfillment | 2      | 0      | 7       | 1     | 9     | ✅     |
    | Data Stores | 33     | 0      | 10      | 0     | 43    | ✅     |
    | Analytics   | 2      | 0      | 0       | 1     | 2     | ✅     |
    | Release     | 5      | 0      | 1       | 0     | 6     | ✅     |
    | Configure   | 0      | 0      | 3       | 0     | 3     | ➖     |
    | Ai-powered  | 0      | 0      | 2       | 0     | 2     | ➖     |
    | ModelOps    | 0      | 0      | 1       | 0     | 1     | ➖     |
    | Growth      | 0      | 0      | 2       | 0     | 2     | ➖     |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Total       | 436    | 0      | 119     | 3     | 555   | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+
  • merged

  • James Nutt mentioned in commit 08551959

    mentioned in commit 08551959

  • @nwittstruck, how was your code review experience with this merge request? Please tell us how we can continue to iterate and improve:

    1. React with a :thumbsup: or a :thumbsdown: on this comment to describe your experience.
    2. Create a new comment starting with @gitlab-bot feedback below, and leave any additional feedback you have for us in the comment.

    As a benefit of being a GitLab Community Contributor, you can request access to GitLab Duo. With Code Suggestions, Chat and more AI-powered features, GitLab Duo helps to boost your efficiency and effectiveness by reducing the time required to write and understand code. Visit the Duo access project to request a GitLab Duo license and learn more about the benefits of GitLab Duo.

    Subscribe to the GitLab Community Newsletter for contributor-focused content and opportunities to level up.

    Thanks for your help! :heart:

    This message was generated automatically. Improve it or delete it.

  • added workflowstaging label and removed workflowcanary label

  • Please register or sign in to reply
    Loading