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
8e5ce8d5
Commit
8e5ce8d5
authored
Jun 18, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
e0a46916
5ee6771c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
34 deletions
+53
-34
app/workers/cleanup_container_repository_worker.rb
app/workers/cleanup_container_repository_worker.rb
+3
-26
changelogs/unreleased/62183-update-response-code-for-bulk-delete-api-for-container-registry.yml
...ponse-code-for-bulk-delete-api-for-container-registry.yml
+5
-0
doc/ci/img/collapsible_log.png
doc/ci/img/collapsible_log.png
+0
-0
doc/ci/pipelines.md
doc/ci/pipelines.md
+14
-0
lib/api/container_registry.rb
lib/api/container_registry.rb
+10
-0
spec/requests/api/container_registry_spec.rb
spec/requests/api/container_registry_spec.rb
+21
-0
spec/workers/cleanup_container_repository_worker_spec.rb
spec/workers/cleanup_container_repository_worker_spec.rb
+0
-8
No files found.
app/workers/cleanup_container_repository_worker.rb
View file @
8e5ce8d5
...
...
@@ -2,12 +2,9 @@
class
CleanupContainerRepositoryWorker
include
ApplicationWorker
include
ExclusiveLeaseGuard
queue_namespace
:container_repository
LEASE_TIMEOUT
=
1
.
hour
attr_reader
:container_repository
,
:current_user
def
perform
(
current_user_id
,
container_repository_id
,
params
)
...
...
@@ -16,11 +13,9 @@ class CleanupContainerRepositoryWorker
return
unless
valid?
try_obtain_lease
do
Projects
::
ContainerRepository
::
CleanupTagsService
.
new
(
project
,
current_user
,
params
)
.
execute
(
container_repository
)
end
Projects
::
ContainerRepository
::
CleanupTagsService
.
new
(
project
,
current_user
,
params
)
.
execute
(
container_repository
)
end
private
...
...
@@ -32,22 +27,4 @@ class CleanupContainerRepositoryWorker
def
project
container_repository
&
.
project
end
# For ExclusiveLeaseGuard concern
def
lease_key
@lease_key
||=
"container_repository:cleanup_tags:
#{
container_repository
.
id
}
"
end
# For ExclusiveLeaseGuard concern
def
lease_timeout
LEASE_TIMEOUT
end
# For ExclusiveLeaseGuard concern
def
lease_release?
# we don't allow to execute this worker
# more often than LEASE_TIMEOUT
# for given container repository
false
end
end
changelogs/unreleased/62183-update-response-code-for-bulk-delete-api-for-container-registry.yml
0 → 100644
View file @
8e5ce8d5
---
title
:
Return 400 when deleting tags more often than once per hour.
merge_request
:
29448
author
:
type
:
changed
doc/ci/img/collapsible_log.png
0 → 100644
View file @
8e5ce8d5
171 KB
doc/ci/pipelines.md
View file @
8e5ce8d5
...
...
@@ -139,6 +139,20 @@ The union of A, B, and C is (1, 4) and (6, 7). Therefore, the total running time
(4 - 1) + (7 - 6) => 4
```
## Expanding and collapsing job log sections
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/14664) in GitLab
> 12.0.
Job logs are divided into sections that can be collapsed or expanded.
In the following example:
-
Two sections are expanded and can be collapsed.
-
One section is collapsed and can be expanded.
![
Collapsible sections
](
img/collapsible_log.png
)
## Configuring pipelines
Pipelines, and their component jobs and stages, are defined in the
[
`.gitlab-ci.yml`
](
yaml/README.md
)
file for each project.
...
...
lib/api/container_registry.rb
View file @
8e5ce8d5
...
...
@@ -68,6 +68,9 @@ module API
delete
':id/registry/repositories/:repository_id/tags'
,
requirements:
REGISTRY_ENDPOINT_REQUIREMENTS
do
authorize_admin_container_image!
message
=
'This request has already been made. You can run this at most once an hour for a given container repository'
render_api_error!
(
message
,
400
)
unless
obtain_new_cleanup_container_lease
CleanupContainerRepositoryWorker
.
perform_async
(
current_user
.
id
,
repository
.
id
,
declared_params
.
except
(
:repository_id
))
# rubocop: disable CodeReuse/ActiveRecord
...
...
@@ -123,6 +126,13 @@ module API
authorize!
:admin_container_image
,
repository
end
def
obtain_new_cleanup_container_lease
Gitlab
::
ExclusiveLease
.
new
(
"container_repository:cleanup_tags:
#{
repository
.
id
}
"
,
timeout:
1
.
hour
)
.
try_obtain
end
def
repository
@repository
||=
user_project
.
container_repositories
.
find
(
params
[
:repository_id
])
end
...
...
spec/requests/api/container_registry_spec.rb
View file @
8e5ce8d5
require
'spec_helper'
describe
API
::
ContainerRegistry
do
include
ExclusiveLeaseHelpers
set
(
:project
)
{
create
(
:project
,
:private
)
}
set
(
:maintainer
)
{
create
(
:user
)
}
set
(
:developer
)
{
create
(
:user
)
}
...
...
@@ -155,7 +157,10 @@ describe API::ContainerRegistry do
older_than:
'1 day'
}
end
let
(
:lease_key
)
{
"container_repository:cleanup_tags:
#{
root_repository
.
id
}
"
}
it
'schedules cleanup of tags repository'
do
stub_exclusive_lease
(
lease_key
,
timeout:
1
.
hour
)
expect
(
CleanupContainerRepositoryWorker
).
to
receive
(
:perform_async
)
.
with
(
maintainer
.
id
,
root_repository
.
id
,
worker_params
)
...
...
@@ -163,6 +168,22 @@ describe API::ContainerRegistry do
expect
(
response
).
to
have_gitlab_http_status
(
:accepted
)
end
context
'called multiple times in one hour'
do
it
'returns 400 with an error message'
do
stub_exclusive_lease_taken
(
lease_key
,
timeout:
1
.
hour
)
subject
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
.
body
).
to
include
(
'This request has already been made.'
)
end
it
'executes service only for the first time'
do
expect
(
CleanupContainerRepositoryWorker
).
to
receive
(
:perform_async
).
once
2
.
times
{
subject
}
end
end
end
end
end
...
...
spec/workers/cleanup_container_repository_worker_spec.rb
View file @
8e5ce8d5
...
...
@@ -35,13 +35,5 @@ describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do
subject
.
perform
(
user
.
id
,
-
1
,
params
)
end
.
not_to
raise_error
end
context
'when executed twice in short period'
do
it
'executes service only for the first time'
do
expect
(
service
).
to
receive
(
:execute
).
once
2
.
times
{
subject
.
perform
(
user
.
id
,
repository
.
id
,
params
)
}
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