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
415c2c6a
Commit
415c2c6a
authored
Jan 14, 2021
by
David Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly log if the tags list has been truncated
parent
62795e9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
app/workers/container_expiration_policies/cleanup_container_repository_worker.rb
...xpiration_policies/cleanup_container_repository_worker.rb
+7
-0
spec/workers/container_expiration_policies/cleanup_container_repository_worker_spec.rb
...tion_policies/cleanup_container_repository_worker_spec.rb
+30
-6
No files found.
app/workers/container_expiration_policies/cleanup_container_repository_worker.rb
View file @
415c2c6a
...
...
@@ -109,6 +109,13 @@ module ContainerExpirationPolicies
log_extra_metadata_on_done
(
field
,
value
)
end
before_truncate_size
=
result
.
payload
[
:cleanup_tags_service_before_truncate_size
]
after_truncate_size
=
result
.
payload
[
:cleanup_tags_service_after_truncate_size
]
truncated
=
before_truncate_size
&&
after_truncate_size
&&
before_truncate_size
!=
after_truncate_size
log_extra_metadata_on_done
(
:cleanup_tags_service_truncated
,
!!
truncated
)
end
end
end
spec/workers/container_expiration_policies/cleanup_container_repository_worker_spec.rb
View file @
415c2c6a
...
...
@@ -3,6 +3,8 @@
require
'spec_helper'
RSpec
.
describe
ContainerExpirationPolicies
::
CleanupContainerRepositoryWorker
do
using
RSpec
::
Parameterized
::
TableSyntax
let_it_be
(
:repository
,
reload:
true
)
{
create
(
:container_repository
,
:cleanup_scheduled
)
}
let_it_be
(
:project
)
{
repository
.
project
}
let_it_be
(
:policy
)
{
project
.
container_expiration_policy
}
...
...
@@ -42,11 +44,32 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do
service_response
=
cleanup_service_response
(
status: :unfinished
,
repository:
repository
,
cleanup_tags_service_after_truncate_size:
10
,
cleanup_tags_service_before_delete_size:
5
)
expect
(
ContainerExpirationPolicies
::
CleanupService
)
.
to
receive
(
:new
).
with
(
repository
).
and_return
(
double
(
execute:
service_response
))
expect_log_extra_metadata
(
service_response:
service_response
,
cleanup_status: :unfinished
)
expect_log_extra_metadata
(
service_response:
service_response
,
cleanup_status: :unfinished
,
truncated:
true
)
subject
end
end
context
'the truncated log field'
do
where
(
:before_truncate_size
,
:after_truncate_size
,
:truncated
)
do
100
|
100
|
false
100
|
80
|
true
nil
|
100
|
false
100
|
nil
|
false
nil
|
nil
|
false
end
with_them
do
it
'is logged properly'
do
service_response
=
cleanup_service_response
(
status: :unfinished
,
repository:
repository
,
cleanup_tags_service_after_truncate_size:
after_truncate_size
,
cleanup_tags_service_before_truncate_size:
before_truncate_size
)
expect
(
ContainerExpirationPolicies
::
CleanupService
)
.
to
receive
(
:new
).
with
(
repository
).
and_return
(
double
(
execute:
service_response
))
expect_log_extra_metadata
(
service_response:
service_response
,
cleanup_status: :unfinished
,
truncated:
truncated
)
subject
end
end
end
end
context
'with policy running shortly'
do
...
...
@@ -189,13 +212,14 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do
)
end
def
expect_log_extra_metadata
(
service_response
:,
cleanup_status: :finished
)
def
expect_log_extra_metadata
(
service_response
:,
cleanup_status: :finished
,
truncated:
false
)
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:cleanup_status
,
cleanup_status
)
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:container_repository_id
,
repository
.
id
)
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:cleanup_tags_service_original_size
,
service_response
.
payload
[
:cleanup_tags_service_original_size
])
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:cleanup_tags_service_before_truncate_size
,
service_response
.
payload
[
:cleanup_tags_service_before_truncate_size
])
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:cleanup_tags_service_after_truncate_size
,
service_response
.
payload
[
:cleanup_tags_service_after_truncate_size
])
expect
(
worker
).
to
receive
(
:log_extra_metadata_on_done
).
with
(
:cleanup_tags_service_before_delete_size
,
service_response
.
payload
[
:cleanup_tags_service_before_delete_size
])
%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
|
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
)
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