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
4ea8fe08
Commit
4ea8fe08
authored
Sep 13, 2021
by
David Fernandez
Committed by
Saikat Sarkar
Sep 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the dependency worker purge feature
parent
81ba6674
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
46 deletions
+54
-46
app/workers/purge_dependency_proxy_cache_worker.rb
app/workers/purge_dependency_proxy_cache_worker.rb
+1
-1
doc/api/dependency_proxy.md
doc/api/dependency_proxy.md
+0
-3
lib/api/dependency_proxy.rb
lib/api/dependency_proxy.rb
+3
-1
spec/requests/api/dependency_proxy_spec.rb
spec/requests/api/dependency_proxy_spec.rb
+44
-30
spec/workers/purge_dependency_proxy_cache_worker_spec.rb
spec/workers/purge_dependency_proxy_cache_worker_spec.rb
+6
-11
No files found.
app/workers/purge_dependency_proxy_cache_worker.rb
View file @
4ea8fe08
...
@@ -27,6 +27,6 @@ class PurgeDependencyProxyCacheWorker
...
@@ -27,6 +27,6 @@ class PurgeDependencyProxyCacheWorker
def
valid?
def
valid?
return
unless
@group
return
unless
@group
can?
(
@current_user
,
:admin_group
,
@group
)
&&
@group
.
dependency_proxy_feature_available?
can?
(
@current_user
,
:admin_group
,
@group
)
end
end
end
end
doc/api/dependency_proxy.md
View file @
4ea8fe08
...
@@ -14,9 +14,6 @@ info: To determine the technical writer assigned to the Stage/Group associated w
...
@@ -14,9 +14,6 @@ info: To determine the technical writer assigned to the Stage/Group associated w
Deletes the cached manifests and blobs for a group. This endpoint requires the
[
Owner role
](
../user/permissions.md
)
Deletes the cached manifests and blobs for a group. This endpoint requires the
[
Owner role
](
../user/permissions.md
)
for the group.
for the group.
WARNING:
[
A bug exists
](
https://gitlab.com/gitlab-org/gitlab/-/issues/277161
)
for this API.
```
plaintext
```
plaintext
DELETE /groups/:id/dependency_proxy/cache
DELETE /groups/:id/dependency_proxy/cache
```
```
...
...
lib/api/dependency_proxy.rb
View file @
4ea8fe08
...
@@ -15,7 +15,7 @@ module API
...
@@ -15,7 +15,7 @@ module API
end
end
end
end
before
do
after_validation
do
authorize!
:admin_group
,
user_group
authorize!
:admin_group
,
user_group
end
end
...
@@ -35,6 +35,8 @@ module API
...
@@ -35,6 +35,8 @@ module API
# rubocop:disable CodeReuse/Worker
# rubocop:disable CodeReuse/Worker
PurgeDependencyProxyCacheWorker
.
perform_async
(
current_user
.
id
,
user_group
.
id
)
PurgeDependencyProxyCacheWorker
.
perform_async
(
current_user
.
id
,
user_group
.
id
)
# rubocop:enable CodeReuse/Worker
# rubocop:enable CodeReuse/Worker
status
:accepted
end
end
end
end
end
end
...
...
spec/requests/api/dependency_proxy_spec.rb
View file @
4ea8fe08
...
@@ -13,12 +13,12 @@ RSpec.describe API::DependencyProxy, api: true do
...
@@ -13,12 +13,12 @@ RSpec.describe API::DependencyProxy, api: true do
group
.
add_owner
(
user
)
group
.
add_owner
(
user
)
stub_config
(
dependency_proxy:
{
enabled:
true
})
stub_config
(
dependency_proxy:
{
enabled:
true
})
stub_last_activity_update
stub_last_activity_update
group
.
create_dependency_proxy_setting!
(
enabled:
true
)
end
end
describe
'DELETE /groups/:id/dependency_proxy/cache'
do
describe
'DELETE /groups/:id/dependency_proxy/cache'
do
subject
{
delete
api
(
"/groups/
#{
group
.
id
}
/dependency_proxy/cache"
,
user
)
}
subject
{
delete
api
(
"/groups/
#{
group
_
id
}
/dependency_proxy/cache"
,
user
)
}
shared_examples
'responding to purge requests'
do
context
'with feature available and enabled'
do
context
'with feature available and enabled'
do
let_it_be
(
:lease_key
)
{
"dependency_proxy:delete_group_blobs:
#{
group
.
id
}
"
}
let_it_be
(
:lease_key
)
{
"dependency_proxy:delete_group_blobs:
#{
group
.
id
}
"
}
...
@@ -29,7 +29,8 @@ RSpec.describe API::DependencyProxy, api: true do
...
@@ -29,7 +29,8 @@ RSpec.describe API::DependencyProxy, api: true do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
expect
(
response
).
to
have_gitlab_http_status
(
:accepted
)
expect
(
response
.
body
).
to
eq
(
'202'
)
end
end
context
'called multiple times in one hour'
,
:clean_gitlab_redis_shared_state
do
context
'called multiple times in one hour'
,
:clean_gitlab_redis_shared_state
do
...
@@ -61,7 +62,7 @@ RSpec.describe API::DependencyProxy, api: true do
...
@@ -61,7 +62,7 @@ RSpec.describe API::DependencyProxy, api: true do
end
end
end
end
context
'depencency proxy is not enabled
'
do
context
'depencency proxy is not enabled in the config
'
do
before
do
before
do
stub_config
(
dependency_proxy:
{
enabled:
false
})
stub_config
(
dependency_proxy:
{
enabled:
false
})
end
end
...
@@ -69,4 +70,17 @@ RSpec.describe API::DependencyProxy, api: true do
...
@@ -69,4 +70,17 @@ RSpec.describe API::DependencyProxy, api: true do
it_behaves_like
'returning response status'
,
:not_found
it_behaves_like
'returning response status'
,
:not_found
end
end
end
end
context
'with a group id'
do
let
(
:group_id
)
{
group
.
id
}
it_behaves_like
'responding to purge requests'
end
context
'with an url encoded group id'
do
let
(
:group_id
)
{
ERB
::
Util
.
url_encode
(
group
.
full_path
)
}
it_behaves_like
'responding to purge requests'
end
end
end
end
spec/workers/purge_dependency_proxy_cache_worker_spec.rb
View file @
4ea8fe08
...
@@ -11,14 +11,9 @@ RSpec.describe PurgeDependencyProxyCacheWorker do
...
@@ -11,14 +11,9 @@ RSpec.describe PurgeDependencyProxyCacheWorker do
subject
{
described_class
.
new
.
perform
(
user
.
id
,
group_id
)
}
subject
{
described_class
.
new
.
perform
(
user
.
id
,
group_id
)
}
before
do
stub_config
(
dependency_proxy:
{
enabled:
true
})
group
.
create_dependency_proxy_setting!
(
enabled:
true
)
end
describe
'#perform'
do
describe
'#perform'
do
shared_examples
'
returns nil
'
do
shared_examples
'
not removing blobs and manifests
'
do
it
'
returns nil
'
,
:aggregate_failures
do
it
'
does not remove blobs and manifests
'
,
:aggregate_failures
do
expect
{
subject
}.
not_to
change
{
group
.
dependency_proxy_blobs
.
size
}
expect
{
subject
}.
not_to
change
{
group
.
dependency_proxy_blobs
.
size
}
expect
{
subject
}.
not_to
change
{
group
.
dependency_proxy_manifests
.
size
}
expect
{
subject
}.
not_to
change
{
group
.
dependency_proxy_manifests
.
size
}
expect
(
subject
).
to
be_nil
expect
(
subject
).
to
be_nil
...
@@ -43,26 +38,26 @@ RSpec.describe PurgeDependencyProxyCacheWorker do
...
@@ -43,26 +38,26 @@ RSpec.describe PurgeDependencyProxyCacheWorker do
end
end
context
'when admin mode is disabled'
do
context
'when admin mode is disabled'
do
it_behaves_like
'
returns nil
'
it_behaves_like
'
not removing blobs and manifests
'
end
end
end
end
context
'a non-admin user'
do
context
'a non-admin user'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
it_behaves_like
'
returns nil
'
it_behaves_like
'
not removing blobs and manifests
'
end
end
context
'an invalid user id'
do
context
'an invalid user id'
do
let
(
:user
)
{
double
(
'User'
,
id:
99999
)
}
let
(
:user
)
{
double
(
'User'
,
id:
99999
)
}
it_behaves_like
'
returns nil
'
it_behaves_like
'
not removing blobs and manifests
'
end
end
context
'an invalid group'
do
context
'an invalid group'
do
let
(
:group_id
)
{
99999
}
let
(
:group_id
)
{
99999
}
it_behaves_like
'
returns nil
'
it_behaves_like
'
not removing blobs and manifests
'
end
end
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