Skip to content

Add created_by_user to cluster_agents

Emily Ring requested to merge 293720-agent-created-by into master

What does this MR do?

We want to track and display the user that creates a Clusters::Agent

See related issue: #293720 (closed)

This MR will:

  • Add created_by_user fields to the database and Clusters::Agent model
  • Update Clusters::Agents::CreateService to capture user information
  • Update GraphQL to display new created_by_user field
  • Update associated tests and docs

Screenshots (strongly suggested)

user

Migrations

up

== 20210211142259 AddCreatedByToClusterAgent: migrating =======================
-- column_exists?(:cluster_agents, :created_by_user_id)
   -> 0.0020s
-- add_column(:cluster_agents, :created_by_user_id, :bigint)
   -> 0.0019s
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:cluster_agents, :created_by_user_id, {:name=>"index_cluster_agents_on_created_by_user_id", :algorithm=>:concurrently})
   -> 0.0023s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- add_index(:cluster_agents, :created_by_user_id, {:name=>"index_cluster_agents_on_created_by_user_id", :algorith
m=>:concurrently})
   -> 0.0037s
-- execute("RESET ALL")
   -> 0.0005s
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:cluster_agents)
   -> 0.0038s
-- execute("ALTER TABLE cluster_agents\nADD CONSTRAINT fk_f7d43dee13\nFOREIGN KEY (created_by_user_id)\nREFERENCES
 users (id)\nON DELETE SET NULL\nNOT VALID;\n")
   -> 0.0034s
-- execute("ALTER TABLE cluster_agents VALIDATE CONSTRAINT fk_f7d43dee13;")
   -> 0.0053s
== 20210211142259 AddCreatedByToClusterAgent: migrated (0.0335s) ==============

down

== 20210216135504 AddCreatedByToClusterAgent: reverting =======================
-- remove_column(:cluster_agents, :created_by_user_id)
   -> 0.0022s
== 20210216135504 AddCreatedByToClusterAgent: reverted (0.0087s) ==============

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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 #293720 (closed)

Edited by Mayra Cabrera

Merge request reports