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
9e99bb21
Commit
9e99bb21
authored
Jun 22, 2020
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore expired job artifacts
parent
0e7e33e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
ee/app/finders/geo/job_artifact_registry_finder.rb
ee/app/finders/geo/job_artifact_registry_finder.rb
+1
-1
ee/spec/finders/geo/job_artifact_registry_finder_spec.rb
ee/spec/finders/geo/job_artifact_registry_finder_spec.rb
+56
-0
No files found.
ee/app/finders/geo/job_artifact_registry_finder.rb
View file @
9e99bb21
...
...
@@ -44,7 +44,7 @@ module Geo
#
# @return [Array] the first element is an Array of untracked IDs, and the second element is an Array of tracked IDs that are unused
def
find_registry_differences
(
range
)
source_ids
=
job_artifacts
.
id_in
(
range
).
pluck
(
::
Ci
::
JobArtifact
.
arel_table
[
:id
])
# rubocop:disable CodeReuse/ActiveRecord
source_ids
=
job_artifacts
.
not_expired
.
id_in
(
range
).
pluck
(
::
Ci
::
JobArtifact
.
arel_table
[
:id
])
# rubocop:disable CodeReuse/ActiveRecord
tracked_ids
=
syncable
.
pluck_model_ids_in_range
(
range
)
untracked_ids
=
source_ids
-
tracked_ids
...
...
ee/spec/finders/geo/job_artifact_registry_finder_spec.rb
View file @
9e99bb21
...
...
@@ -106,6 +106,12 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
end
describe
'#find_registry_differences'
do
# Untracked IDs should not contain any of these expired job artifacts.
let!
(
:ci_job_artifact_6
)
{
create
(
:ci_job_artifact
,
:expired
,
project:
synced_project
)
}
let!
(
:ci_job_artifact_7
)
{
create
(
:ci_job_artifact
,
:expired
,
project:
unsynced_project
)
}
let!
(
:ci_job_artifact_8
)
{
create
(
:ci_job_artifact
,
:expired
,
project:
project_broken_storage
)
}
let!
(
:ci_job_artifact_remote_4
)
{
create
(
:ci_job_artifact
,
:expired
,
:remote_store
)
}
context
'untracked IDs'
do
before
do
create
(
:geo_job_artifact_registry
,
artifact_id:
ci_job_artifact_1
.
id
)
...
...
@@ -181,6 +187,26 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
end
end
context
'with an expired registry'
do
let!
(
:expired
)
{
create
(
:geo_job_artifact_registry
,
artifact_id:
ci_job_artifact_6
.
id
)
}
it
'includes expired tracked IDs that exists in the model table'
do
range
=
ci_job_artifact_6
.
id
..
ci_job_artifact_6
.
id
_
,
unused_tracked_ids
=
subject
.
find_registry_differences
(
range
)
expect
(
unused_tracked_ids
).
to
match_array
([
ci_job_artifact_6
.
id
])
end
it
'excludes IDs outside the ID range'
do
range
=
(
ci_job_artifact_6
.
id
+
1
)
..
(
ci_job_artifact_6
.
id
+
10
)
_
,
unused_tracked_ids
=
subject
.
find_registry_differences
(
range
)
expect
(
unused_tracked_ids
).
to
be_empty
end
end
context
'with selective sync by namespace'
do
let
(
:secondary
)
{
create
(
:geo_node
,
selective_sync_type:
'namespaces'
,
namespaces:
[
synced_group
])
}
...
...
@@ -204,6 +230,16 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
expect
(
unused_tracked_ids
).
to
be_empty
end
it
'includes expired tracked IDs that are in selectively synced projects'
do
create
(
:geo_job_artifact_registry
,
artifact_id:
ci_job_artifact_6
.
id
)
range
=
ci_job_artifact_6
.
id
..
ci_job_artifact_6
.
id
_
,
unused_tracked_ids
=
subject
.
find_registry_differences
(
range
)
expect
(
unused_tracked_ids
).
to
match_array
([
ci_job_artifact_6
.
id
])
end
end
end
end
...
...
@@ -231,6 +267,16 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
expect
(
unused_tracked_ids
).
to
be_empty
end
it
'includes expired tracked IDs that are in selectively synced shards'
do
create
(
:geo_job_artifact_registry
,
artifact_id:
ci_job_artifact_8
.
id
)
range
=
ci_job_artifact_8
.
id
..
ci_job_artifact_8
.
id
_
,
unused_tracked_ids
=
subject
.
find_registry_differences
(
range
)
expect
(
unused_tracked_ids
).
to
match_array
([
ci_job_artifact_8
.
id
])
end
end
end
end
...
...
@@ -248,6 +294,16 @@ RSpec.describe Geo::JobArtifactRegistryFinder, :geo do
expect
(
unused_tracked_ids
).
to
match_array
([
ci_job_artifact_remote_1
.
id
])
end
it
'includes expired tracked IDs that are in object storage'
do
create
(
:geo_job_artifact_registry
,
artifact_id:
ci_job_artifact_remote_4
.
id
)
range
=
ci_job_artifact_remote_4
.
id
..
ci_job_artifact_remote_4
.
id
_
,
unused_tracked_ids
=
subject
.
find_registry_differences
(
range
)
expect
(
unused_tracked_ids
).
to
match_array
([
ci_job_artifact_remote_4
.
id
])
end
end
context
'not in object storage'
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