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
f5340667
Commit
f5340667
authored
Oct 06, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expire etag cache to force environments.json reload
parent
83d4d557
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
12 deletions
+27
-12
app/assets/javascripts/environments/components/deploy_board_component.vue
...cripts/environments/components/deploy_board_component.vue
+1
-1
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+8
-3
app/models/concerns/reactive_caching.rb
app/models/concerns/reactive_caching.rb
+5
-3
ee/app/models/concerns/ee/kubernetes_service.rb
ee/app/models/concerns/ee/kubernetes_service.rb
+2
-2
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+7
-0
spec/models/concerns/reactive_caching_spec.rb
spec/models/concerns/reactive_caching_spec.rb
+4
-3
No files found.
app/assets/javascripts/environments/components/deploy_board_component.vue
View file @
f5340667
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
return
!
this
.
isLoading
&&
this
.
isEmpty
;
return
!
this
.
isLoading
&&
this
.
isEmpty
;
},
},
instanceTitle
()
{
instanceTitle
()
{
return
n__
(
'
Instance
'
,
'
Instances
'
,
this
.
deployBoardData
.
instances
);
return
n__
(
'
Instance
'
,
'
Instances
'
,
this
.
deployBoardData
.
instances
.
length
);
},
},
projectName
()
{
projectName
()
{
return
'
<projectname>
'
;
return
'
<projectname>
'
;
...
...
app/controllers/projects/environments_controller.rb
View file @
f5340667
...
@@ -7,7 +7,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -7,7 +7,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
before_action
:authorize_admin_environment!
,
only:
[
:terminal
,
:terminal_websocket_authorize
]
before_action
:authorize_admin_environment!
,
only:
[
:terminal
,
:terminal_websocket_authorize
]
before_action
:environment
,
only:
[
:show
,
:edit
,
:update
,
:stop
,
:terminal
,
:terminal_websocket_authorize
,
:metrics
]
before_action
:environment
,
only:
[
:show
,
:edit
,
:update
,
:stop
,
:terminal
,
:terminal_websocket_authorize
,
:metrics
]
before_action
:verify_api_request!
,
only: :terminal_websocket_authorize
before_action
:verify_api_request!
,
only: :terminal_websocket_authorize
before_action
:
refresh_rollout_status
,
only:
[
:index
]
before_action
:
expire_etag_cache
,
only:
[
:index
]
def
index
def
index
@environments
=
project
.
environments
@environments
=
project
.
environments
...
@@ -148,8 +148,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -148,8 +148,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController
Gitlab
::
Workhorse
.
verify_api_request!
(
request
.
headers
)
Gitlab
::
Workhorse
.
verify_api_request!
(
request
.
headers
)
end
end
def
refresh_rollout_status
def
expire_etag_cache
environment
.
rollout_status
return
if
request
.
format
.
json?
# this forces to reload json content
Gitlab
::
EtagCaching
::
Store
.
new
.
tap
do
|
store
|
store
.
touch
(
project_environments_path
(
project
,
format: :json
))
end
end
end
def
environment_params
def
environment_params
...
...
app/models/concerns/reactive_caching.rb
View file @
f5340667
...
@@ -80,9 +80,11 @@ module ReactiveCaching
...
@@ -80,9 +80,11 @@ module ReactiveCaching
locking_reactive_cache
(
*
args
)
do
locking_reactive_cache
(
*
args
)
do
within_reactive_cache_lifetime
(
*
args
)
do
within_reactive_cache_lifetime
(
*
args
)
do
enqueuing_update
(
*
args
)
do
enqueuing_update
(
*
args
)
do
value
=
calculate_reactive_cache
(
*
args
)
key
=
full_reactive_cache_key
(
*
args
)
Rails
.
cache
.
write
(
full_reactive_cache_key
(
*
args
),
value
)
new_value
=
calculate_reactive_cache
(
*
args
)
reactive_cache_updated
(
*
args
)
old_value
=
Rails
.
cache
.
read
(
key
)
Rails
.
cache
.
write
(
key
,
new_value
)
reactive_cache_updated
(
*
args
)
if
new_value
!=
old_value
end
end
end
end
end
end
...
...
ee/app/models/concerns/ee/kubernetes_service.rb
View file @
f5340667
...
@@ -19,9 +19,9 @@ module EE
...
@@ -19,9 +19,9 @@ module EE
def
reactive_cache_updated
def
reactive_cache_updated
super
super
Gitlab
::
EtagCaching
::
Store
.
new
.
tap
do
|
store
|
::
Gitlab
::
EtagCaching
::
Store
.
new
.
tap
do
|
store
|
store
.
touch
(
store
.
touch
(
Gitlab
::
Routing
.
url_helpers
.
project_environments_path
(
project
,
format: :json
))
::
Gitlab
::
Routing
.
url_helpers
.
project_environments_path
(
project
,
format: :json
))
end
end
end
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
f5340667
...
@@ -23,6 +23,13 @@ describe Projects::EnvironmentsController do
...
@@ -23,6 +23,13 @@ describe Projects::EnvironmentsController do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
end
end
it
'expires etag cache to force reload environments list'
do
expect_any_instance_of
(
Gitlab
::
EtagCaching
::
Store
)
.
to
receive
(
:touch
).
with
(
project_environments_path
(
project
,
format: :json
))
get
:index
,
environment_params
end
end
end
context
'when requesting JSON response for folders'
do
context
'when requesting JSON response for folders'
do
...
...
spec/models/concerns/reactive_caching_spec.rb
View file @
f5340667
...
@@ -115,10 +115,11 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
...
@@ -115,10 +115,11 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
go!
go!
end
end
it
"calls a reactive_cache_updated after updated"
do
it
"calls a reactive_cache_updated only once if content did not change on subsequent update"
do
expect
(
instance
).
to
receive
(
:reactive_cache_updated
)
expect
(
instance
).
to
receive
(
:calculate_reactive_cache
).
twice
expect
(
instance
).
to
receive
(
:reactive_cache_updated
).
once
go!
2
.
times
{
instance
.
exclusively_update_reactive_cache!
}
end
end
context
'and #calculate_reactive_cache raises an exception'
do
context
'and #calculate_reactive_cache raises an exception'
do
...
...
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