Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
ac744fd4
Commit
ac744fd4
authored
Apr 30, 2019
by
Vladimir Shushlin
Committed by
Nick Thomas
Apr 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove disabled pages domains
Domain will be removed by verification worker after 1 week of being disabled
parent
9e2958ae
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
112 additions
and
10 deletions
+112
-10
app/models/pages_domain.rb
app/models/pages_domain.rb
+2
-0
app/workers/all_queues.yml
app/workers/all_queues.yml
+1
-0
app/workers/pages_domain_removal_cron_worker.rb
app/workers/pages_domain_removal_cron_worker.rb
+16
-0
changelogs/unreleased/remove-disabled-pages-domains-part-2.yml
...elogs/unreleased/remove-disabled-pages-domains-part-2.yml
+5
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+4
-0
spec/factories/pages_domains.rb
spec/factories/pages_domains.rb
+4
-0
spec/models/pages_domain_spec.rb
spec/models/pages_domain_spec.rb
+28
-0
spec/services/verify_pages_domain_service_spec.rb
spec/services/verify_pages_domain_service_spec.rb
+6
-6
spec/workers/pages_domain_removal_cron_worker_spec.rb
spec/workers/pages_domain_removal_cron_worker_spec.rb
+42
-0
spec/workers/pages_domain_verification_cron_worker_spec.rb
spec/workers/pages_domain_verification_cron_worker_spec.rb
+4
-4
No files found.
app/models/pages_domain.rb
View file @
ac744fd4
...
@@ -38,6 +38,8 @@ class PagesDomain < ApplicationRecord
...
@@ -38,6 +38,8 @@ class PagesDomain < ApplicationRecord
where
(
verified_at
.
eq
(
nil
).
or
(
enabled_until
.
eq
(
nil
).
or
(
enabled_until
.
lt
(
threshold
))))
where
(
verified_at
.
eq
(
nil
).
or
(
enabled_until
.
eq
(
nil
).
or
(
enabled_until
.
lt
(
threshold
))))
end
end
scope
:for_removal
,
->
{
where
(
"remove_at < ?"
,
Time
.
now
)
}
def
verified?
def
verified?
!!
verified_at
!!
verified_at
end
end
...
...
app/workers/all_queues.yml
View file @
ac744fd4
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
-
cronjob:gitlab_usage_ping
-
cronjob:gitlab_usage_ping
-
cronjob:import_export_project_cleanup
-
cronjob:import_export_project_cleanup
-
cronjob:pages_domain_verification_cron
-
cronjob:pages_domain_verification_cron
-
cronjob:pages_domain_removal_cron
-
cronjob:pipeline_schedule
-
cronjob:pipeline_schedule
-
cronjob:prune_old_events
-
cronjob:prune_old_events
-
cronjob:remove_expired_group_links
-
cronjob:remove_expired_group_links
...
...
app/workers/pages_domain_removal_cron_worker.rb
0 → 100644
View file @
ac744fd4
# frozen_string_literal: true
class
PagesDomainRemovalCronWorker
include
ApplicationWorker
include
CronjobQueue
def
perform
return
unless
Feature
.
enabled?
(
:remove_disabled_domains
)
PagesDomain
.
for_removal
.
find_each
do
|
domain
|
domain
.
destroy!
rescue
=>
e
Raven
.
capture_exception
(
e
)
end
end
end
changelogs/unreleased/remove-disabled-pages-domains-part-2.yml
0 → 100644
View file @
ac744fd4
---
title
:
Remove pages domains if they weren't verified for 1 week
merge_request
:
26227
author
:
type
:
added
config/initializers/1_settings.rb
View file @
ac744fd4
...
@@ -338,6 +338,10 @@ Settings.cron_jobs['pages_domain_verification_cron_worker'] ||= Settingslogic.ne
...
@@ -338,6 +338,10 @@ Settings.cron_jobs['pages_domain_verification_cron_worker'] ||= Settingslogic.ne
Settings
.
cron_jobs
[
'pages_domain_verification_cron_worker'
][
'cron'
]
||=
'*/15 * * * *'
Settings
.
cron_jobs
[
'pages_domain_verification_cron_worker'
][
'cron'
]
||=
'*/15 * * * *'
Settings
.
cron_jobs
[
'pages_domain_verification_cron_worker'
][
'job_class'
]
=
'PagesDomainVerificationCronWorker'
Settings
.
cron_jobs
[
'pages_domain_verification_cron_worker'
][
'job_class'
]
=
'PagesDomainVerificationCronWorker'
Settings
.
cron_jobs
[
'pages_domain_removal_cron_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'pages_domain_removal_cron_worker'
][
'cron'
]
||=
'47 0 * * *'
Settings
.
cron_jobs
[
'pages_domain_removal_cron_worker'
][
'job_class'
]
=
'PagesDomainRemovalCronWorker'
Settings
.
cron_jobs
[
'issue_due_scheduler_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'issue_due_scheduler_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'issue_due_scheduler_worker'
][
'cron'
]
||=
'50 00 * * *'
Settings
.
cron_jobs
[
'issue_due_scheduler_worker'
][
'cron'
]
||=
'50 00 * * *'
Settings
.
cron_jobs
[
'issue_due_scheduler_worker'
][
'job_class'
]
=
'IssueDueSchedulerWorker'
Settings
.
cron_jobs
[
'issue_due_scheduler_worker'
][
'job_class'
]
=
'IssueDueSchedulerWorker'
...
...
spec/factories/pages_domains.rb
View file @
ac744fd4
...
@@ -45,6 +45,10 @@ nNp/xedE1YxutQ==
...
@@ -45,6 +45,10 @@ nNp/xedE1YxutQ==
remove_at
{
1
.
day
.
from_now
}
remove_at
{
1
.
day
.
from_now
}
end
end
trait
:should_be_removed
do
remove_at
{
1
.
day
.
ago
}
end
trait
:unverified
do
trait
:unverified
do
verified_at
nil
verified_at
nil
end
end
...
...
spec/models/pages_domain_spec.rb
View file @
ac744fd4
...
@@ -344,4 +344,32 @@ describe PagesDomain do
...
@@ -344,4 +344,32 @@ describe PagesDomain do
end
end
end
end
end
end
describe
'.for_removal'
do
subject
{
described_class
.
for_removal
}
context
'when domain is not schedule for removal'
do
let!
(
:domain
)
{
create
:pages_domain
}
it
'does not return domain'
do
is_expected
.
to
be_empty
end
end
context
'when domain is scheduled for removal yesterday'
do
let!
(
:domain
)
{
create
:pages_domain
,
remove_at:
1
.
day
.
ago
}
it
'returns domain'
do
is_expected
.
to
eq
([
domain
])
end
end
context
'when domain is scheduled for removal tomorrow'
do
let!
(
:domain
)
{
create
:pages_domain
,
remove_at:
1
.
day
.
from_now
}
it
'does not return domain'
do
is_expected
.
to
be_empty
end
end
end
end
end
spec/services/verify_pages_domain_service_spec.rb
View file @
ac744fd4
...
@@ -57,12 +57,12 @@ describe VerifyPagesDomainService do
...
@@ -57,12 +57,12 @@ describe VerifyPagesDomainService do
expect
(
domain
).
not_to
be_verified
expect
(
domain
).
not_to
be_verified
end
end
it
'disables domain and shedules it for removal'
do
it
'disables domain and shedules it for removal
in 1 week
'
do
Timecop
.
freeze
do
service
.
execute
service
.
execute
expect
(
domain
).
not_to
be_enabled
expect
(
domain
).
not_to
be_enabled
expect
(
domain
.
remove_at
).
to
be_within
(
1
.
second
).
of
(
1
.
week
.
from_now
)
e
nd
e
xpect
(
domain
.
remove_at
).
to
be_like_time
(
7
.
days
.
from_now
)
end
end
end
end
...
...
spec/workers/pages_domain_removal_cron_worker_spec.rb
0 → 100644
View file @
ac744fd4
# frozen_string_literal: true
require
'spec_helper'
describe
PagesDomainRemovalCronWorker
do
subject
(
:worker
)
{
described_class
.
new
}
describe
'#perform'
do
context
'when there is domain which should be removed'
do
let!
(
:domain_for_removal
)
{
create
(
:pages_domain
,
:should_be_removed
)
}
before
do
stub_feature_flags
(
remove_disabled_domains:
true
)
end
it
'removes domain'
do
expect
{
worker
.
perform
}.
to
change
{
PagesDomain
.
count
}.
by
(
-
1
)
expect
(
PagesDomain
.
exists?
).
to
eq
(
false
)
end
context
'when domain removal is disabled'
do
before
do
stub_feature_flags
(
remove_disabled_domains:
false
)
end
it
'does not remove pages domain'
do
expect
{
worker
.
perform
}.
not_to
change
{
PagesDomain
.
count
}
expect
(
PagesDomain
.
find_by
(
domain:
domain_for_removal
.
domain
)).
to
be_present
end
end
end
context
'where there is a domain which scheduled for removal in the future'
do
let!
(
:domain_for_removal
)
{
create
(
:pages_domain
,
:scheduled_for_removal
)
}
it
'does not remove pages domain'
do
expect
{
worker
.
perform
}.
not_to
change
{
PagesDomain
.
count
}
expect
(
PagesDomain
.
find_by
(
domain:
domain_for_removal
.
domain
)).
to
be_present
end
end
end
end
spec/workers/pages_domain_verification_cron_worker_spec.rb
View file @
ac744fd4
...
@@ -6,11 +6,11 @@ describe PagesDomainVerificationCronWorker do
...
@@ -6,11 +6,11 @@ describe PagesDomainVerificationCronWorker do
subject
(
:worker
)
{
described_class
.
new
}
subject
(
:worker
)
{
described_class
.
new
}
describe
'#perform'
do
describe
'#perform'
do
it
'enqueues a PagesDomainVerificationWorker for domains needing verification'
do
let!
(
:verified
)
{
create
(
:pages_domain
)
}
verified
=
create
(
:pages_domain
)
let!
(
:reverify
)
{
create
(
:pages_domain
,
:reverify
)
}
reverify
=
create
(
:pages_domain
,
:reverify
)
let!
(
:disabled
)
{
create
(
:pages_domain
,
:disabled
)
}
disabled
=
create
(
:pages_domain
,
:disabled
)
it
'enqueues a PagesDomainVerificationWorker for domains needing verification'
do
[
reverify
,
disabled
].
each
do
|
domain
|
[
reverify
,
disabled
].
each
do
|
domain
|
expect
(
PagesDomainVerificationWorker
).
to
receive
(
:perform_async
).
with
(
domain
.
id
)
expect
(
PagesDomainVerificationWorker
).
to
receive
(
:perform_async
).
with
(
domain
.
id
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment