Add cron worker to clean up expired subscriptions from Elasticsearch
What does this MR do?
Since paid subscriptions and trials will automatically be added to the
index we want a way to ensure they are cleaned up if their subscription
expires at some point. Removing from the ElasticsearchIndexedNamespace
table will be sufficient to trigger them to be deleted from the index.
We should wait at least 7 days after they are removed, however, to ensure that we aren't wastefully deleting them if they end up upgrading their plan in this window.
Screenshots
DB Migrations
Up
== 20200805071842 AddIndexOnEndDateAndNamespaceIdToGitlabSubscriptions: migrating
-- transaction_open?()
-> 0.0000s
-- index_exists?(:gitlab_subscriptions, [:end_date, :namespace_id], {:algorithm=>:concurrently})
-> 0.0031s
-- add_index(:gitlab_subscriptions, [:end_date, :namespace_id], {:algorithm=>:concurrently})
-> 0.0085s
== 20200805071842 AddIndexOnEndDateAndNamespaceIdToGitlabSubscriptions: migrated (0.0122s)
Down
== 20200805071842 AddIndexOnEndDateAndNamespaceIdToGitlabSubscriptions: reverting
-- transaction_open?()
-> 0.0000s
-- index_exists?(:gitlab_subscriptions, [:end_date, :namespace_id], {:algorithm=>:concurrently})
-> 0.0038s
-- remove_index(:gitlab_subscriptions, {:algorithm=>:concurrently, :column=>[:end_date, :namespace_id]})
-> 0.0037s
== 20200805071842 AddIndexOnEndDateAndNamespaceIdToGitlabSubscriptions: reverted (0.0079s)
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
Edited by Dylan Griffith