Skip to content

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

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

#220386 (closed)

Edited by Dylan Griffith

Merge request reports