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
83f2a4d8
Commit
83f2a4d8
authored
Feb 17, 2021
by
David Fernandez
Committed by
Thong Kuah
Feb 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup policies: log the number of tags deleted
parent
8b3468a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
7 deletions
+13
-7
app/services/container_expiration_policies/cleanup_service.rb
...services/container_expiration_policies/cleanup_service.rb
+1
-1
app/services/projects/container_repository/cleanup_tags_service.rb
...ces/projects/container_repository/cleanup_tags_service.rb
+1
-0
app/workers/container_expiration_policies/cleanup_container_repository_worker.rb
...xpiration_policies/cleanup_container_repository_worker.rb
+2
-0
spec/services/container_expiration_policies/cleanup_service_spec.rb
...ces/container_expiration_policies/cleanup_service_spec.rb
+4
-2
spec/services/projects/container_repository/cleanup_tags_service_spec.rb
...rojects/container_repository/cleanup_tags_service_spec.rb
+2
-2
spec/workers/container_expiration_policies/cleanup_container_repository_worker_spec.rb
...tion_policies/cleanup_container_repository_worker_spec.rb
+3
-2
No files found.
app/services/container_expiration_policies/cleanup_service.rb
View file @
83f2a4d8
...
...
@@ -4,7 +4,7 @@ module ContainerExpirationPolicies
class
CleanupService
attr_reader
:repository
SERVICE_RESULT_FIELDS
=
%i[original_size before_truncate_size after_truncate_size before_delete_size]
.
freeze
SERVICE_RESULT_FIELDS
=
%i[original_size before_truncate_size after_truncate_size before_delete_size
deleted_size
]
.
freeze
def
initialize
(
repository
)
@repository
=
repository
...
...
app/services/projects/container_repository/cleanup_tags_service.rb
View file @
83f2a4d8
...
...
@@ -25,6 +25,7 @@ module Projects
result
[
:before_truncate_size
]
=
before_truncate_size
result
[
:after_truncate_size
]
=
after_truncate_size
result
[
:before_delete_size
]
=
tags
.
size
result
[
:deleted_size
]
=
result
[
:deleted
]
&
.
size
result
[
:status
]
=
:error
if
before_truncate_size
!=
after_truncate_size
end
...
...
app/workers/container_expiration_policies/cleanup_container_repository_worker.rb
View file @
83f2a4d8
...
...
@@ -18,6 +18,7 @@ module ContainerExpirationPolicies
cleanup_tags_service_before_truncate_size
cleanup_tags_service_after_truncate_size
cleanup_tags_service_before_delete_size
cleanup_tags_service_deleted_size
]
.
freeze
def
perform_work
...
...
@@ -117,6 +118,7 @@ module ContainerExpirationPolicies
after_truncate_size
&&
before_truncate_size
!=
after_truncate_size
log_extra_metadata_on_done
(
:cleanup_tags_service_truncated
,
!!
truncated
)
log_extra_metadata_on_done
(
:running_jobs_count
,
running_jobs_count
)
end
end
end
spec/services/container_expiration_policies/cleanup_service_spec.rb
View file @
83f2a4d8
...
...
@@ -61,7 +61,8 @@ RSpec.describe ContainerExpirationPolicies::CleanupService do
original_size:
1000
,
before_truncate_size:
800
,
after_truncate_size:
200
,
before_delete_size:
100
before_delete_size:
100
,
deleted_size:
100
}
end
...
...
@@ -77,7 +78,8 @@ RSpec.describe ContainerExpirationPolicies::CleanupService do
cleanup_tags_service_original_size:
1000
,
cleanup_tags_service_before_truncate_size:
800
,
cleanup_tags_service_after_truncate_size:
200
,
cleanup_tags_service_before_delete_size:
100
cleanup_tags_service_before_delete_size:
100
,
cleanup_tags_service_deleted_size:
100
)
expect
(
ContainerRepository
.
waiting_for_cleanup
.
count
).
to
eq
(
1
)
expect
(
repository
.
reload
.
cleanup_unfinished?
).
to
be_truthy
...
...
spec/services/projects/container_repository/cleanup_tags_service_spec.rb
View file @
83f2a4d8
...
...
@@ -284,7 +284,7 @@ RSpec.describe Projects::ContainerRepository::CleanupTagsService do
deleted:
nil
)
expect
(
result
).
to
eq
(
service_response
.
compact
)
expect
(
result
).
to
eq
(
service_response
)
end
end
...
...
@@ -369,6 +369,6 @@ RSpec.describe Projects::ContainerRepository::CleanupTagsService do
before_truncate_size:
before_truncate_size
,
after_truncate_size:
after_truncate_size
,
before_delete_size:
before_delete_size
}.
compact
}.
compact
.
merge
(
deleted_size:
deleted
&
.
size
)
end
end
spec/workers/container_expiration_policies/cleanup_container_repository_worker_spec.rb
View file @
83f2a4d8
...
...
@@ -199,7 +199,7 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do
end
end
def
cleanup_service_response
(
status: :finished
,
repository
:,
cleanup_tags_service_original_size:
100
,
cleanup_tags_service_before_truncate_size:
80
,
cleanup_tags_service_after_truncate_size:
80
,
cleanup_tags_service_before_delete_size:
50
)
def
cleanup_service_response
(
status: :finished
,
repository
:,
cleanup_tags_service_original_size:
100
,
cleanup_tags_service_before_truncate_size:
80
,
cleanup_tags_service_after_truncate_size:
80
,
cleanup_tags_service_before_delete_size:
50
,
cleanup_tags_service_deleted_size:
50
)
ServiceResponse
.
success
(
message:
"cleanup
#{
status
}
"
,
payload:
{
...
...
@@ -218,11 +218,12 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:project_id
,
repository
.
project
.
id
)
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:cleanup_status
,
cleanup_status
)
%i[cleanup_tags_service_original_size cleanup_tags_service_before_truncate_size cleanup_tags_service_after_truncate_size cleanup_tags_service_before_delete_size]
.
each
do
|
field
|
%i[cleanup_tags_service_original_size cleanup_tags_service_before_truncate_size cleanup_tags_service_after_truncate_size cleanup_tags_service_before_delete_size
cleanup_tags_service_deleted_size
]
.
each
do
|
field
|
value
=
service_response
.
payload
[
field
]
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
field
,
value
)
unless
value
.
nil?
end
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:cleanup_tags_service_truncated
,
truncated
)
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:running_jobs_count
,
0
)
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