Update cluster agent tokens with null names
What does this MR do?
We recently added a name
field to Clusters::AgentTokens. We want to require this field but there are old tokens in the database with null
names.
See previous MR: !53920 (merged)
See related issue: #322745 (closed)
This MR will:
- Add
add_not_null_constraint
to name field - Add post-migration that updates tokens with null names
A follow-up MR in 13.11
will:
validate_not_null_constraint
Migrations
up
== 20210303165201 AddNotNullConstraintToClusterTokenName: migrating ===========
-- current_schema()
-> 0.0003s
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE cluster_agent_tokens\nADD CONSTRAINT check_0fb634d04d\nCHECK ( name IS NOT NULL )\nNOT VALID;\n")
-> 0.0011s
== 20210303165201 AddNotNullConstraintToClusterTokenName: migrated (0.0138s) ==
== 20210303165202 CleanupClusterTokensWithNullName: migrating =================
== 20210303165202 CleanupClusterTokensWithNullName: migrated (0.0146s) ========
down
== 20210303165202 CleanupClusterTokensWithNullName: reverting =================
== 20210303165202 CleanupClusterTokensWithNullName: reverted (0.0000s) ========
== 20210303165201 AddNotNullConstraintToClusterTokenName: reverting ===========
-- execute("ALTER TABLE cluster_agent_tokens\nDROP CONSTRAINT IF EXISTS check_0fb634d04d\n")
-> 0.0020s
== 20210303165201 AddNotNullConstraintToClusterTokenName: reverted (0.0103s) ==
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
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 #322745 (closed)
Edited by Emily Ring