Set defaults for cleanup policy regexes
What does this MR do?
Container cleanup policies use a set of regexes to determine which tags to remove from a given container repository. Right now, there is no default, and blank values are allowed. The problem is, if a policy has a blank name_regex
, no tags will qualify for deletion. If this is the case, the policy should not be valid. Since the name_regex
column does allow NULL and blank values and we cannot change the existing records, we need to validate that the name_regex
has a value only when the policy is enabled.
This MR adds:
- Validation to ensure
name_regex
is not blank whenenabled = true
. - Default value for
name_regex
. The cleanup policies are created automatically when a new project is created. We don't want to continue to create policies with blank values that do nothing. - Change the default from
enabled: true
toenabled: false
. We are disabling by default for now since adding a default regex will cause new policies to run and remove image tags. We want to be sure the user is aware tags may be deleted before enabling by default.
Database
Up migration
== 20201008144854 SetRegexDefaultsOnContainerExpirationPolicies: migrating ====
-- change_column_default(:container_expiration_policies, :name_regex, ".*")
-> 0.0045s
-- change_column_default(:container_expiration_policies, :enabled, false)
-> 0.0021s
== 20201008144854 SetRegexDefaultsOnContainerExpirationPolicies: migrated (0.0099s)
Down migration
== 20201008144854 SetRegexDefaultsOnContainerExpirationPolicies: reverting ====
-- change_column_default(:container_expiration_policies, :name_regex, nil)
-> 0.0080s
-- change_column_default(:container_expiration_policies, :enabled, true)
-> 0.0047s
== 20201008144854 SetRegexDefaultsOnContainerExpirationPolicies: reverted (0.0173s)
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
Merge request reports
Activity
@10io FYI
marked the checklist item Changelog entry as completed
marked the checklist item Database guides as completed
marked the checklist item Style guides as completed
marked the checklist item Merge request performance guidelines as completed
marked the checklist item Code review guidelines as completed
marked the checklist item Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. as completed
marked the checklist item Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. as incomplete
added databasereview pending label
2 Warnings ⚠ For the following files, a review from the Data team and Product Analytics team is recommended
Please check the ~"product analytics(telemetry)" guide and reach out to @gitlab-org/growth/product_analytics/engineers group for a review.spec/lib/gitlab/usage_data_spec.rb
⚠ When adding, changing, or updating metrics, please update the Event dictionary Usage Ping table. 1 Message 📖 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:
doc/user/packages/container_registry/index.md
The review does not need to block merging this merge request. See the:
- Technical Writers assignments for the appropriate technical writer for this review.
- Documentation workflows for information on when to assign a merge request for review.
Reviewer roulette
Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.
To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited, or the chosen person is unavailable.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, mention them as you normally would! Danger does not automatically notify them for you.
Category Reviewer Maintainer frontend Roman Kuba ( @rkuba
) (UTC+1, 7 hours ahead of@sabrams
)Enrique Alcántara ( @ealcantara
) (UTC-4, 2 hours ahead of@sabrams
)backend Felipe Artur ( @felipe_artur
) (UTC-3, 3 hours ahead of@sabrams
)Rémy Coutable ( @rymai
) (UTC+1, 7 hours ahead of@sabrams
)database Alexandru Croitor ( @acroitor
) (UTC+2, 8 hours ahead of@sabrams
)Adam Hegyi ( @ahegyi
) (UTC+1, 7 hours ahead of@sabrams
)test Quality for spec/features/*
Sofia Vistas ( @svistas
) (UTC+2, 8 hours ahead of@sabrams
)Maintainer review is optional for test Quality for spec/features/*
If needed, you can retry the
danger-review
job that generated this comment.Generated by
🚫 DangerEdited by 🤖 GitLab Bot 🤖removed backend database databasereview pending labels
added typefeature label
- Resolved by Robert Speicher
changed milestone to %13.5
added database label