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
1afc1574
Commit
1afc1574
authored
Apr 07, 2020
by
Nicolò Maria Mezzopera
Committed by
James Lopez
Apr 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle delete_status in container registry
- controller update - entity update - destroy_service update
parent
96df6dcd
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
3 deletions
+43
-3
app/controllers/projects/registry/repositories_controller.rb
app/controllers/projects/registry/repositories_controller.rb
+1
-0
app/models/container_repository.rb
app/models/container_repository.rb
+2
-0
app/serializers/container_repository_entity.rb
app/serializers/container_repository_entity.rb
+1
-1
app/services/projects/container_repository/destroy_service.rb
...services/projects/container_repository/destroy_service.rb
+1
-1
changelogs/unreleased/208429-add-delete-status.yml
changelogs/unreleased/208429-add-delete-status.yml
+5
-0
db/migrate/20200402135250_add_delete_status_to_container_repository.rb
...200402135250_add_delete_status_to_container_repository.rb
+13
-0
db/structure.sql
db/structure.sql
+3
-1
spec/controllers/projects/registry/repositories_controller_spec.rb
...rollers/projects/registry/repositories_controller_spec.rb
+1
-0
spec/fixtures/api/schemas/registry/repository.json
spec/fixtures/api/schemas/registry/repository.json
+6
-0
spec/services/projects/container_repository/destroy_service_spec.rb
...ces/projects/container_repository/destroy_service_spec.rb
+10
-0
No files found.
app/controllers/projects/registry/repositories_controller.rb
View file @
1afc1574
...
...
@@ -28,6 +28,7 @@ module Projects
end
def
destroy
image
.
delete_scheduled!
DeleteContainerRepositoryWorker
.
perform_async
(
current_user
.
id
,
image
.
id
)
# rubocop:disable CodeReuse/Worker
track_event
(
:delete_repository
)
...
...
app/models/container_repository.rb
View file @
1afc1574
...
...
@@ -8,6 +8,8 @@ class ContainerRepository < ApplicationRecord
validates
:name
,
length:
{
minimum:
0
,
allow_nil:
false
}
validates
:name
,
uniqueness:
{
scope: :project_id
}
enum
status:
{
delete_scheduled:
0
,
delete_failed:
1
}
delegate
:client
,
to: :registry
scope
:ordered
,
->
{
order
(
:name
)
}
...
...
app/serializers/container_repository_entity.rb
View file @
1afc1574
...
...
@@ -3,7 +3,7 @@
class
ContainerRepositoryEntity
<
Grape
::
Entity
include
RequestAwareEntity
expose
:id
,
:name
,
:path
,
:location
,
:created_at
expose
:id
,
:name
,
:path
,
:location
,
:created_at
,
:status
expose
:tags_path
do
|
repository
|
project_registry_repository_tags_path
(
project
,
repository
,
format: :json
)
...
...
app/services/projects/container_repository/destroy_service.rb
View file @
1afc1574
...
...
@@ -8,7 +8,7 @@ module Projects
# Delete tags outside of the transaction to avoid hitting an idle-in-transaction timeout
container_repository
.
delete_tags!
container_repository
.
destroy
container_repository
.
de
lete_failed!
unless
container_repository
.
de
stroy
end
end
end
...
...
changelogs/unreleased/208429-add-delete-status.yml
0 → 100644
View file @
1afc1574
---
title
:
Add status column to container_registry
merge_request
:
28682
author
:
type
:
changed
db/migrate/20200402135250_add_delete_status_to_container_repository.rb
0 → 100644
View file @
1afc1574
# frozen_string_literal: true
class
AddDeleteStatusToContainerRepository
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
up
add_column
(
:container_repositories
,
:status
,
:integer
,
limit:
2
)
end
def
down
remove_column
(
:container_repositories
,
:status
)
end
end
db/structure.sql
View file @
1afc1574
...
...
@@ -1850,7 +1850,8 @@ CREATE TABLE public.container_repositories (
project_id
integer
NOT
NULL
,
name
character
varying
NOT
NULL
,
created_at
timestamp
without
time
zone
NOT
NULL
,
updated_at
timestamp
without
time
zone
NOT
NULL
updated_at
timestamp
without
time
zone
NOT
NULL
,
status
smallint
);
CREATE
SEQUENCE
public
.
container_repositories_id_seq
...
...
@@ -12935,6 +12936,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200330123739
20200330132913
20200331220930
20200402135250
20200403184110
20200403185127
20200403185422
...
...
spec/controllers/projects/registry/repositories_controller_spec.rb
View file @
1afc1574
...
...
@@ -110,6 +110,7 @@ describe Projects::Registry::RepositoriesController do
delete_repository
(
repository
)
expect
(
repository
.
reload
).
to
be_delete_scheduled
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
...
...
spec/fixtures/api/schemas/registry/repository.json
View file @
1afc1574
...
...
@@ -32,6 +32,12 @@
"destroy_path"
:
{
"type"
:
"string"
},
"status"
:
{
"oneOf"
:
[
{
"type"
:
"null"
},
{
"type"
:
"string"
,
"enum"
:
[
"delete_scheduled"
,
"delete_failed"
]
}
]
},
"tags"
:
{
"$ref"
:
"tags.json"
}
},
"additionalProperties"
:
false
...
...
spec/services/projects/container_repository/destroy_service_spec.rb
View file @
1afc1574
...
...
@@ -36,6 +36,16 @@ describe Projects::ContainerRepository::DestroyService do
expect
(
repository
).
to
receive
(
:delete_tags!
).
and_call_original
expect
{
described_class
.
new
(
project
,
user
).
execute
(
repository
)
}.
to
change
{
ContainerRepository
.
all
.
count
}.
by
(
-
1
)
end
context
'when destroy fails'
do
it
'set delete_status'
do
allow
(
repository
).
to
receive
(
:destroy
).
and_return
(
false
)
subject
.
execute
(
repository
)
expect
(
repository
).
to
be_delete_failed
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