diff options
author | Stan Hu <stanhu@gmail.com> | 2018-09-06 09:33:30 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-09-07 22:42:59 +0300 |
commit | 5830d1143dbf6b2958153233279896961e9a44df (patch) | |
tree | c3828d2fb9a5fbd2edc1c0c4a74537c6efe95d8c /app/services | |
parent | 272281e4729c9e2193acea84394a191cfe2496af (diff) |
Delete a container registry asynchronously
When a container registry has many tags, it's easy for the DELETE call to take more
than 60 seconds and fail. This can also leave the registry in a bad state with
null bytes since some of the images have been deleted with tags still pointing to them.
In addition, we have to prevent users from accidentally initiating the delete multiple
times or this could leave the registry with orphaned tags.
This commit also adds a flash message to notify the user the registry is scheduled
for deletion.
Closes #49926, #51063
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/projects/container_repository/destroy_service.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/services/projects/container_repository/destroy_service.rb b/app/services/projects/container_repository/destroy_service.rb new file mode 100644 index 00000000000..a8e7eab6068 --- /dev/null +++ b/app/services/projects/container_repository/destroy_service.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Projects + module ContainerRepository + class DestroyService < BaseService + def execute(container_repository) + return false unless can?(current_user, :update_container_image, project) + + container_repository.destroy + end + end + end +end |