Skip to content

Create an activity event when an agent token is revoked

Tiger Watson requested to merge log-activity-event-on-agent-token-revoke into master

What does this MR do and why?

Logs an activity event when an agent token is revoked, so that it can be shown in the agent's activity stream.

Revoking a token is now more than a single record update, so the logic has been extracted into a dedicated service.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. In a Rails console, create agent and token records:

    • agent = Clusters::Agent.create!(project: <project>, name: 'my-test-agent')
    • agent.agent_tokens.create!(name: 'my-test-token')
  2. Use the following GraphQL mutation to revoke the token (this operation is not yet available from the UI):

    mutation {
      clusterAgentTokenRevoke(input: {
        id:"gid://gitlab/Clusters::AgentToken/<token-id>"
      }) {
        errors
      }
    }
  3. Visit http://path/to/your/project/-/cluster_agents/my-test-agent and observe a "token revoked" event now exists in the activity stream:

    image

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

#348386 (closed)

Edited by Tiger Watson

Merge request reports