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
a6c031d1
Commit
a6c031d1
authored
Feb 23, 2021
by
Vladimir Shushlin
Committed by
Kamil Trzciński
Feb 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop updating pages configuration on disk if feature flag is disabled
parent
957d9c62
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
7 deletions
+40
-7
app/services/projects/update_pages_configuration_service.rb
app/services/projects/update_pages_configuration_service.rb
+2
-0
app/workers/pages_update_configuration_worker.rb
app/workers/pages_update_configuration_worker.rb
+6
-0
spec/services/projects/update_pages_configuration_service_spec.rb
...vices/projects/update_pages_configuration_service_spec.rb
+12
-5
spec/workers/pages_update_configuration_worker_spec.rb
spec/workers/pages_update_configuration_worker_spec.rb
+20
-2
No files found.
app/services/projects/update_pages_configuration_service.rb
View file @
a6c031d1
...
@@ -11,6 +11,8 @@ module Projects
...
@@ -11,6 +11,8 @@ module Projects
end
end
def
execute
def
execute
return
success
unless
Feature
.
enabled?
(
:pages_update_legacy_storage
,
default_enabled:
true
)
# If the pages were never deployed, we can't write out the config, as the
# If the pages were never deployed, we can't write out the config, as the
# directory would not exist.
# directory would not exist.
# https://gitlab.com/gitlab-org/gitlab/-/issues/235139
# https://gitlab.com/gitlab-org/gitlab/-/issues/235139
...
...
app/workers/pages_update_configuration_worker.rb
View file @
a6c031d1
...
@@ -6,6 +6,12 @@ class PagesUpdateConfigurationWorker
...
@@ -6,6 +6,12 @@ class PagesUpdateConfigurationWorker
idempotent!
idempotent!
feature_category
:pages
feature_category
:pages
def
self
.
perform_async
(
*
args
)
return
unless
Feature
.
enabled?
(
:pages_update_legacy_storage
,
default_enabled:
true
)
super
(
*
args
)
end
def
perform
(
project_id
)
def
perform
(
project_id
)
project
=
Project
.
find_by_id
(
project_id
)
project
=
Project
.
find_by_id
(
project_id
)
return
unless
project
return
unless
project
...
...
spec/services/projects/update_pages_configuration_service_spec.rb
View file @
a6c031d1
...
@@ -26,11 +26,18 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
...
@@ -26,11 +26,18 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
context
'when configuration changes'
do
context
'when configuration changes'
do
it
'updates the config and reloads the daemon'
do
it
'updates the config and reloads the daemon'
do
allow
(
service
).
to
receive
(
:update_file
).
and_call_original
expect
(
service
).
to
receive
(
:update_file
).
with
(
file
.
path
,
an_instance_of
(
String
))
expect
(
service
).
to
receive
(
:update_file
).
with
(
file
.
path
,
an_instance_of
(
String
))
.
and_call_original
.
and_call_original
expect
(
service
).
to
receive
(
:reload_daemon
).
and_call_original
allow
(
service
).
to
receive
(
:update_file
).
with
(
File
.
join
(
::
Settings
.
pages
.
path
,
'.update'
),
an_instance_of
(
String
)).
and_call_original
expect
(
subject
).
to
include
(
status: :success
)
end
it
"doesn't update configuration files if updates on legacy storage are disabled"
do
stub_feature_flags
(
pages_update_legacy_storage:
false
)
expect
(
service
).
not_to
receive
(
:update_file
)
expect
(
subject
).
to
include
(
status: :success
)
expect
(
subject
).
to
include
(
status: :success
)
end
end
...
@@ -42,8 +49,8 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
...
@@ -42,8 +49,8 @@ RSpec.describe Projects::UpdatePagesConfigurationService do
service
.
execute
service
.
execute
end
end
it
'does not update
the .update file
'
do
it
'does not update
anything
'
do
expect
(
service
).
not_to
receive
(
:
reload_daemon
)
expect
(
service
).
not_to
receive
(
:
update_file
)
expect
(
subject
).
to
include
(
status: :success
)
expect
(
subject
).
to
include
(
status: :success
)
end
end
...
...
spec/workers/pages_update_configuration_worker_spec.rb
View file @
a6c031d1
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
require
"spec_helper"
require
"spec_helper"
RSpec
.
describe
PagesUpdateConfigurationWorker
do
RSpec
.
describe
PagesUpdateConfigurationWorker
do
describe
"#perform"
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
describe
"#perform"
do
it
"does not break if the project doesn't exist"
do
it
"does not break if the project doesn't exist"
do
expect
{
subject
.
perform
(
-
1
)
}.
not_to
raise_error
expect
{
subject
.
perform
(
-
1
)
}.
not_to
raise_error
end
end
...
@@ -42,4 +42,22 @@ RSpec.describe PagesUpdateConfigurationWorker do
...
@@ -42,4 +42,22 @@ RSpec.describe PagesUpdateConfigurationWorker do
end
end
end
end
end
end
describe
'#perform_async'
do
it
"calls the correct service"
,
:sidekiq_inline
do
expect_next_instance_of
(
Projects
::
UpdatePagesConfigurationService
,
project
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
and_return
(
status: :success
)
end
described_class
.
perform_async
(
project
.
id
)
end
it
"doesn't schedule a worker if updates on legacy storage are disabled"
,
:sidekiq_inline
do
stub_feature_flags
(
pages_update_legacy_storage:
false
)
expect
(
Projects
::
UpdatePagesConfigurationService
).
not_to
receive
(
:new
)
described_class
.
perform_async
(
project
.
id
)
end
end
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