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
48a77e0f
Commit
48a77e0f
authored
Dec 09, 2021
by
drew cimino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature flag for expire artifacts loop limit
parent
9fa56075
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
app/services/ci/job_artifacts/destroy_all_expired_service.rb
app/services/ci/job_artifacts/destroy_all_expired_service.rb
+5
-3
config/feature_flags/development/ci_artifact_fast_removal_large_loop_limit.yml
...development/ci_artifact_fast_removal_large_loop_limit.yml
+8
-0
spec/services/ci/job_artifacts/destroy_all_expired_service_spec.rb
...ices/ci/job_artifacts/destroy_all_expired_service_spec.rb
+4
-3
No files found.
app/services/ci/job_artifacts/destroy_all_expired_service.rb
View file @
48a77e0f
...
...
@@ -8,13 +8,15 @@ module Ci
BATCH_SIZE
=
100
LOOP_TIMEOUT
=
5
.
minutes
LOOP_LIMIT
=
1000
SMALL_LOOP_LIMIT
=
10
LARGE_LOOP_LIMIT
=
100
EXCLUSIVE_LOCK_KEY
=
'expired_job_artifacts:destroy:lock'
LOCK_TIMEOUT
=
6
.
minutes
def
initialize
@removed_artifacts_count
=
0
@start_at
=
Time
.
current
@loop_limit
=
::
Feature
.
enabled?
(
:ci_artifact_fast_removal_large_loop_limit
,
default_enabled: :yaml
)
?
LARGE_LOOP_LIMIT
:
SMALL_LOOP_LIMIT
end
##
...
...
@@ -38,7 +40,7 @@ module Ci
private
def
destroy_unlocked_job_artifacts
loop_until
(
timeout:
LOOP_TIMEOUT
,
limit:
LOOP_LIMIT
)
do
loop_until
(
timeout:
LOOP_TIMEOUT
,
limit:
@loop_limit
)
do
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
]
...
...
@@ -55,7 +57,7 @@ module Ci
@removed_artifacts_count
+=
service_response
[
:destroyed_artifacts_count
]
break
if
loop_timeout?
break
if
index
>=
LOOP_LIMIT
break
if
index
>=
@loop_limit
end
end
...
...
config/feature_flags/development/ci_artifact_fast_removal_large_loop_limit.yml
0 → 100644
View file @
48a77e0f
---
name
:
ci_artifact_fast_removal_large_loop_limit
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76504
rollout_issue_url
:
milestone
:
'
14.6'
type
:
development
group
:
group::pipeline execution
default_enabled
:
false
spec/services/ci/job_artifacts/destroy_all_expired_service_spec.rb
View file @
48a77e0f
...
...
@@ -20,7 +20,7 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
context
'with preloaded relationships'
do
before
do
stub_const
(
"
#{
described_class
}
::LOOP_LIMIT"
,
1
)
stub_const
(
"
#{
described_class
}
::L
ARGE_L
OOP_LIMIT"
,
1
)
end
context
'with ci_destroy_unlocked_job_artifacts feature flag disabled'
do
...
...
@@ -119,7 +119,7 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
let!
(
:artifact
)
{
create
(
:ci_job_artifact
,
:expired
,
job:
job
,
locked:
job
.
pipeline
.
locked
)
}
before
do
stub_const
(
"
#{
described_class
}
::LOOP_LIMIT"
,
10
)
stub_const
(
"
#{
described_class
}
::L
ARGE_L
OOP_LIMIT"
,
10
)
end
context
'when the import fails'
do
...
...
@@ -189,7 +189,8 @@ RSpec.describe Ci::JobArtifacts::DestroyAllExpiredService, :clean_gitlab_redis_s
context
'when loop reached loop limit'
do
before
do
stub_const
(
"
#{
described_class
}
::LOOP_LIMIT"
,
1
)
stub_feature_flags
(
ci_artifact_fast_removal_large_loop_limit:
false
)
stub_const
(
"
#{
described_class
}
::SMALL_LOOP_LIMIT"
,
1
)
end
it
'destroys one artifact'
do
...
...
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