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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d87e082e
Commit
d87e082e
authored
Aug 25, 2020
by
Jacob Vosmaer
Committed by
Mayra Cabrera
Aug 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove pages sites asynchronously
parent
3b7d9445
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
107 additions
and
22 deletions
+107
-22
app/controllers/projects/pages_controller.rb
app/controllers/projects/pages_controller.rb
+1
-1
app/services/pages/delete_service.rb
app/services/pages/delete_service.rb
+5
-2
app/workers/all_queues.yml
app/workers/all_queues.yml
+10
-2
app/workers/pages_remove_worker.rb
app/workers/pages_remove_worker.rb
+17
-0
config/feature_flags/development/async_pages_removal.yml
config/feature_flags/development/async_pages_removal.yml
+7
-0
config/sidekiq_queues.yml
config/sidekiq_queues.yml
+2
-0
lib/tasks/gitlab/sidekiq.rake
lib/tasks/gitlab/sidekiq.rake
+1
-1
spec/features/projects/pages_spec.rb
spec/features/projects/pages_spec.rb
+2
-2
spec/requests/api/pages/pages_spec.rb
spec/requests/api/pages/pages_spec.rb
+3
-1
spec/services/pages/delete_services_spec.rb
spec/services/pages/delete_services_spec.rb
+33
-13
spec/workers/pages_remove_worker_spec.rb
spec/workers/pages_remove_worker_spec.rb
+26
-0
No files found.
app/controllers/projects/pages_controller.rb
View file @
d87e082e
...
@@ -21,7 +21,7 @@ class Projects::PagesController < Projects::ApplicationController
...
@@ -21,7 +21,7 @@ class Projects::PagesController < Projects::ApplicationController
format
.
html
do
format
.
html
do
redirect_to
project_pages_path
(
@project
),
redirect_to
project_pages_path
(
@project
),
status: :found
,
status: :found
,
notice:
'Pages were
removed
'
notice:
'Pages were
scheduled for removal
'
end
end
end
end
end
end
...
...
app/services/pages/delete_service.rb
View file @
d87e082e
...
@@ -3,8 +3,11 @@
...
@@ -3,8 +3,11 @@
module
Pages
module
Pages
class
DeleteService
<
BaseService
class
DeleteService
<
BaseService
def
execute
def
execute
project
.
remove_pages
if
Feature
.
enabled?
(
:async_pages_removal
,
project
)
project
.
pages_domains
.
destroy_all
# rubocop: disable Cop/DestroyAll
PagesRemoveWorker
.
perform_async
(
project
.
id
)
else
PagesRemoveWorker
.
new
.
perform
(
project
.
id
)
end
end
end
end
end
end
end
app/workers/all_queues.yml
View file @
d87e082e
...
@@ -1532,6 +1532,14 @@
...
@@ -1532,6 +1532,14 @@
:weight:
1
:weight:
1
:idempotent:
:idempotent:
:tags: []
:tags: []
-
:name: pages_remove
:feature_category: :pages
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight:
1
:idempotent:
:tags: []
-
:name: pages_update_configuration
-
:name: pages_update_configuration
:feature_category: :pages
:feature_category: :pages
:has_external_dependencies:
:has_external_dependencies:
...
...
app/workers/pages_remove_worker.rb
0 → 100644
View file @
d87e082e
# frozen_string_literal: true
class
PagesRemoveWorker
# rubocop:disable Scalability/IdempotentWorker
include
ApplicationWorker
sidekiq_options
retry:
3
feature_category
:pages
loggable_arguments
0
def
perform
(
project_id
)
project
=
Project
.
find_by_id
(
project_id
)
return
unless
project
project
.
remove_pages
project
.
pages_domains
.
delete_all
end
end
config/feature_flags/development/async_pages_removal.yml
0 → 100644
View file @
d87e082e
---
name
:
async_pages_removal
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38313
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/239318
group
:
team::Scalability
type
:
development
default_enabled
:
false
\ No newline at end of file
config/sidekiq_queues.yml
View file @
d87e082e
...
@@ -178,6 +178,8 @@
...
@@ -178,6 +178,8 @@
-
1
-
1
-
-
pages_domain_verification
-
-
pages_domain_verification
-
1
-
1
-
-
pages_remove
-
1
-
-
pages_update_configuration
-
-
pages_update_configuration
-
1
-
1
-
-
personal_access_tokens
-
-
personal_access_tokens
...
...
lib/tasks/gitlab/sidekiq.rake
View file @
d87e082e
...
@@ -5,7 +5,7 @@ return if Rails.env.production?
...
@@ -5,7 +5,7 @@ return if Rails.env.production?
namespace
:gitlab
do
namespace
:gitlab
do
namespace
:sidekiq
do
namespace
:sidekiq
do
def
write_yaml
(
path
,
banner
,
object
)
def
write_yaml
(
path
,
banner
,
object
)
File
.
write
(
path
,
banner
+
YAML
.
dump
(
object
))
File
.
write
(
path
,
banner
+
YAML
.
dump
(
object
)
.
gsub
(
/ *$/m
,
''
)
)
end
end
namespace
:all_queues_yml
do
namespace
:all_queues_yml
do
...
...
spec/features/projects/pages_spec.rb
View file @
d87e082e
...
@@ -380,14 +380,14 @@ RSpec.shared_examples 'pages settings editing' do
...
@@ -380,14 +380,14 @@ RSpec.shared_examples 'pages settings editing' do
expect
(
project
).
to
be_pages_deployed
expect
(
project
).
to
be_pages_deployed
end
end
it
'removes the pages'
do
it
'removes the pages'
,
:sidekiq_inline
do
visit
project_pages_path
(
project
)
visit
project_pages_path
(
project
)
expect
(
page
).
to
have_link
(
'Remove pages'
)
expect
(
page
).
to
have_link
(
'Remove pages'
)
accept_confirm
{
click_link
'Remove pages'
}
accept_confirm
{
click_link
'Remove pages'
}
expect
(
page
).
to
have_content
(
'Pages were
removed
'
)
expect
(
page
).
to
have_content
(
'Pages were
scheduled for removal
'
)
expect
(
project
.
reload
.
pages_deployed?
).
to
be_falsey
expect
(
project
.
reload
.
pages_deployed?
).
to
be_falsey
end
end
end
end
...
...
spec/requests/api/pages/pages_spec.rb
View file @
d87e082e
...
@@ -39,7 +39,9 @@ RSpec.describe API::Pages do
...
@@ -39,7 +39,9 @@ RSpec.describe API::Pages do
expect_any_instance_of
(
Gitlab
::
PagesTransfer
).
to
receive
(
:rename_project
).
and_return
true
expect_any_instance_of
(
Gitlab
::
PagesTransfer
).
to
receive
(
:rename_project
).
and_return
true
expect
(
PagesWorker
).
to
receive
(
:perform_in
).
with
(
5
.
minutes
,
:remove
,
project
.
namespace
.
full_path
,
anything
)
expect
(
PagesWorker
).
to
receive
(
:perform_in
).
with
(
5
.
minutes
,
:remove
,
project
.
namespace
.
full_path
,
anything
)
Sidekiq
::
Testing
.
inline!
do
delete
api
(
"/projects/
#{
project
.
id
}
/pages"
,
admin
)
delete
api
(
"/projects/
#{
project
.
id
}
/pages"
,
admin
)
end
expect
(
project
.
reload
.
pages_metadatum
.
deployed?
).
to
be
(
false
)
expect
(
project
.
reload
.
pages_metadatum
.
deployed?
).
to
be
(
false
)
end
end
...
...
spec/services/pages/delete_services_spec.rb
View file @
d87e082e
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Pages
::
DeleteService
do
RSpec
.
describe
Pages
::
DeleteService
do
shared_examples
'remove pages'
do
let_it_be
(
:project
)
{
create
(
:project
,
path:
"my.project"
)}
let_it_be
(
:project
)
{
create
(
:project
,
path:
"my.project"
)}
let_it_be
(
:admin
)
{
create
(
:admin
)
}
let_it_be
(
:admin
)
{
create
(
:admin
)
}
let_it_be
(
:domain
)
{
create
(
:pages_domain
,
project:
project
)
}
let_it_be
(
:domain
)
{
create
(
:pages_domain
,
project:
project
)
}
...
@@ -12,7 +13,7 @@ RSpec.describe Pages::DeleteService do
...
@@ -12,7 +13,7 @@ RSpec.describe Pages::DeleteService do
expect_any_instance_of
(
Gitlab
::
PagesTransfer
).
to
receive
(
:rename_project
).
and_return
true
expect_any_instance_of
(
Gitlab
::
PagesTransfer
).
to
receive
(
:rename_project
).
and_return
true
expect
(
PagesWorker
).
to
receive
(
:perform_in
).
with
(
5
.
minutes
,
:remove
,
project
.
namespace
.
full_path
,
anything
)
expect
(
PagesWorker
).
to
receive
(
:perform_in
).
with
(
5
.
minutes
,
:remove
,
project
.
namespace
.
full_path
,
anything
)
service
.
execute
Sidekiq
::
Testing
.
inline!
{
service
.
execute
}
expect
(
project
.
reload
.
pages_metadatum
.
deployed?
).
to
be
(
false
)
expect
(
project
.
reload
.
pages_metadatum
.
deployed?
).
to
be
(
false
)
end
end
...
@@ -20,8 +21,27 @@ RSpec.describe Pages::DeleteService do
...
@@ -20,8 +21,27 @@ RSpec.describe Pages::DeleteService do
it
'deletes all domains'
do
it
'deletes all domains'
do
expect
(
project
.
pages_domains
.
count
).
to
be
1
expect
(
project
.
pages_domains
.
count
).
to
be
1
service
.
execute
Sidekiq
::
Testing
.
inline!
{
service
.
execute
}
expect
(
project
.
reload
.
pages_domains
.
count
).
to
be
0
expect
(
project
.
reload
.
pages_domains
.
count
).
to
be
0
end
end
end
context
'with feature flag disabled'
do
before
do
stub_feature_flags
(
async_pages_removal:
false
)
expect
(
PagesRemoveWorker
).
not_to
receive
(
:perform_async
)
end
it_behaves_like
'remove pages'
end
context
'with feature flag enabled'
do
before
do
expect
(
PagesRemoveWorker
).
to
receive
(
:perform_async
).
and_call_original
end
it_behaves_like
'remove pages'
end
end
end
spec/workers/pages_remove_worker_spec.rb
0 → 100644
View file @
d87e082e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
PagesRemoveWorker
do
let_it_be
(
:project
)
{
create
(
:project
,
path:
"my.project"
)}
let_it_be
(
:domain
)
{
create
(
:pages_domain
,
project:
project
)
}
subject
{
described_class
.
new
.
perform
(
project
.
id
)
}
it
'deletes published pages'
do
expect_any_instance_of
(
Gitlab
::
PagesTransfer
).
to
receive
(
:rename_project
).
and_return
true
expect
(
PagesWorker
).
to
receive
(
:perform_in
).
with
(
5
.
minutes
,
:remove
,
project
.
namespace
.
full_path
,
anything
)
subject
expect
(
project
.
reload
.
pages_metadatum
.
deployed?
).
to
be
(
false
)
end
it
'deletes all domains'
do
expect
(
project
.
pages_domains
.
count
).
to
be
1
subject
expect
(
project
.
reload
.
pages_domains
.
count
).
to
be
0
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