Add created_by_user to cluster_agents
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)
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
-
Changelog entry - [-] 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 #293720 (closed)
Edited by Mayra Cabrera