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
e773a8d2
Commit
e773a8d2
authored
Nov 09, 2021
by
drew cimino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use @start_at instance variable in JobArtifact::DestroyAllExpiredService
parent
3d2e7b8e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
app/services/ci/job_artifacts/destroy_all_expired_service.rb
app/services/ci/job_artifacts/destroy_all_expired_service.rb
+10
-9
No files found.
app/services/ci/job_artifacts/destroy_all_expired_service.rb
View file @
e773a8d2
...
...
@@ -14,6 +14,7 @@ module Ci
def
initialize
@removed_artifacts_count
=
0
@start_at
=
Time
.
current
end
##
...
...
@@ -25,9 +26,9 @@ module Ci
def
execute
in_lock
(
EXCLUSIVE_LOCK_KEY
,
ttl:
LOCK_TIMEOUT
,
retries:
1
)
do
if
::
Feature
.
enabled?
(
:ci_destroy_unlocked_job_artifacts
)
destroy_unlocked_job_artifacts
(
Time
.
current
)
destroy_unlocked_job_artifacts
else
destroy_job_artifacts_with_slow_iteration
(
Time
.
current
)
destroy_job_artifacts_with_slow_iteration
end
end
...
...
@@ -36,16 +37,16 @@ module Ci
private
def
destroy_unlocked_job_artifacts
(
start_at
)
def
destroy_unlocked_job_artifacts
loop_until
(
timeout:
LOOP_TIMEOUT
,
limit:
LOOP_LIMIT
)
do
artifacts
=
Ci
::
JobArtifact
.
expired_before
(
start_at
).
artifact_unlocked
.
limit
(
BATCH_SIZE
)
artifacts
=
Ci
::
JobArtifact
.
expired_before
(
@
start_at
).
artifact_unlocked
.
limit
(
BATCH_SIZE
)
service_response
=
destroy_batch
(
artifacts
)
@removed_artifacts_count
+=
service_response
[
:destroyed_artifacts_count
]
end
end
def
destroy_job_artifacts_with_slow_iteration
(
start_at
)
Ci
::
JobArtifact
.
expired_before
(
start_at
).
each_batch
(
of:
BATCH_SIZE
,
column: :expire_at
,
order: :desc
)
do
|
relation
,
index
|
def
destroy_job_artifacts_with_slow_iteration
Ci
::
JobArtifact
.
expired_before
(
@
start_at
).
each_batch
(
of:
BATCH_SIZE
,
column: :expire_at
,
order: :desc
)
do
|
relation
,
index
|
# For performance reasons, join with ci_pipelines after the batch is queried.
# See: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47496
artifacts
=
relation
.
unlocked
...
...
@@ -53,7 +54,7 @@ module Ci
service_response
=
destroy_batch
(
artifacts
)
@removed_artifacts_count
+=
service_response
[
:destroyed_artifacts_count
]
break
if
loop_timeout?
(
start_at
)
break
if
loop_timeout?
break
if
index
>=
LOOP_LIMIT
end
end
...
...
@@ -62,8 +63,8 @@ module Ci
Ci
::
JobArtifacts
::
DestroyBatchService
.
new
(
artifacts
).
execute
end
def
loop_timeout?
(
start_at
)
Time
.
current
>
start_at
+
LOOP_TIMEOUT
def
loop_timeout?
Time
.
current
>
@
start_at
+
LOOP_TIMEOUT
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