diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-11 18:10:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-11 18:10:32 +0300 |
commit | ec971a05e380fa580ae75dea30ab963112096525 (patch) | |
tree | 33d9fee648491f9900024ba25e681535a7684997 /app/services/container_expiration_policies | |
parent | f469daf1dc805d4c6a689067094112d4ed68d775 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/container_expiration_policies')
-rw-r--r-- | app/services/container_expiration_policies/cleanup_service.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/app/services/container_expiration_policies/cleanup_service.rb b/app/services/container_expiration_policies/cleanup_service.rb index 4719c99af6d..b9e623e2e07 100644 --- a/app/services/container_expiration_policies/cleanup_service.rb +++ b/app/services/container_expiration_policies/cleanup_service.rb @@ -4,6 +4,8 @@ module ContainerExpirationPolicies class CleanupService attr_reader :repository + SERVICE_RESULT_FIELDS = %i[original_size before_truncate_size after_truncate_size before_delete_size].freeze + def initialize(repository) @repository = repository end @@ -13,28 +15,37 @@ module ContainerExpirationPolicies repository.start_expiration_policy! - result = Projects::ContainerRepository::CleanupTagsService + service_result = Projects::ContainerRepository::CleanupTagsService .new(project, nil, policy_params.merge('container_expiration_policy' => true)) .execute(repository) - if result[:status] == :success + if service_result[:status] == :success repository.update!( expiration_policy_cleanup_status: :cleanup_unscheduled, expiration_policy_started_at: nil, expiration_policy_completed_at: Time.zone.now ) - success(:finished) + success(:finished, service_result) else repository.cleanup_unfinished! - success(:unfinished) + success(:unfinished, service_result) end end private - def success(cleanup_status) - ServiceResponse.success(message: "cleanup #{cleanup_status}", payload: { cleanup_status: cleanup_status, container_repository_id: repository.id }) + def success(cleanup_status, service_result) + payload = { + cleanup_status: cleanup_status, + container_repository_id: repository.id + } + + SERVICE_RESULT_FIELDS.each do |field| + payload["cleanup_tags_service_#{field}".to_sym] = service_result[field] + end + + ServiceResponse.success(message: "cleanup #{cleanup_status}", payload: payload) end def policy_params |