Commit 4a4b80a6 authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch '340523-delete-es-data-30-after-subscription-expires' into 'master'

Only delete data from Elasticsearch 30 days after subscription expires

See merge request gitlab-org/gitlab!72923
parents 477b4da7 39a1ed5f
...@@ -31,9 +31,9 @@ class GitlabSubscription < ApplicationRecord ...@@ -31,9 +31,9 @@ class GitlabSubscription < ApplicationRecord
scope :preload_for_refresh_seat, -> { preload([{ namespace: :route }, :hosted_plan]) } scope :preload_for_refresh_seat, -> { preload([{ namespace: :route }, :hosted_plan]) }
DAYS_AFTER_EXPIRATION_BEFORE_REMOVING_FROM_INDEX = 7 DAYS_AFTER_EXPIRATION_BEFORE_REMOVING_FROM_INDEX = 30
# We set a 7 days as the threshold for expiration before removing them from # We set a threshold for expiration before removing them from
# the index # the index
def self.yield_long_expired_indexed_namespaces(&blk) def self.yield_long_expired_indexed_namespaces(&blk)
# Since the gitlab_subscriptions table will keep growing in size and the # Since the gitlab_subscriptions table will keep growing in size and the
......
...@@ -476,8 +476,8 @@ RSpec.describe GitlabSubscription do ...@@ -476,8 +476,8 @@ RSpec.describe GitlabSubscription do
let_it_be(:not_expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today + 2) } let_it_be(:not_expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today + 2) }
let_it_be(:not_expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today + 100) } let_it_be(:not_expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today + 100) }
let_it_be(:recently_expired_subscription) { create(:gitlab_subscription, :bronze, end_date: Date.today - 4) } let_it_be(:recently_expired_subscription) { create(:gitlab_subscription, :bronze, end_date: Date.today - 4) }
let_it_be(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 8) } let_it_be(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 31) }
let_it_be(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 10) } let_it_be(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 40) }
before do before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true)
......
...@@ -8,8 +8,8 @@ RSpec.describe ElasticRemoveExpiredNamespaceSubscriptionsFromIndexCronWorker do ...@@ -8,8 +8,8 @@ RSpec.describe ElasticRemoveExpiredNamespaceSubscriptionsFromIndexCronWorker do
let(:not_expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today + 2) } let(:not_expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today + 2) }
let(:not_expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today + 100) } let(:not_expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today + 100) }
let(:recently_expired_subscription) { create(:gitlab_subscription, :bronze, end_date: Date.today - 4) } let(:recently_expired_subscription) { create(:gitlab_subscription, :bronze, end_date: Date.today - 4) }
let(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 8) } let(:expired_subscription1) { create(:gitlab_subscription, :bronze, end_date: Date.today - 31) }
let(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 10) } let(:expired_subscription2) { create(:gitlab_subscription, :bronze, end_date: Date.today - 35) }
before do before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true) allow(::Gitlab).to receive(:dev_env_or_com?).and_return(true)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment