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
a5ffda8d
Commit
a5ffda8d
authored
Sep 29, 2021
by
Steve Abrams
Committed by
David Fernandez
Sep 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop Composer cache file related workers
parent
7a2f033b
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
11 additions
and
75 deletions
+11
-75
app/models/packages/composer/cache_file.rb
app/models/packages/composer/cache_file.rb
+0
-2
app/services/packages/composer/create_package_service.rb
app/services/packages/composer/create_package_service.rb
+0
-4
app/workers/packages/composer/cache_cleanup_worker.rb
app/workers/packages/composer/cache_cleanup_worker.rb
+1
-13
app/workers/packages/composer/cache_update_worker.rb
app/workers/packages/composer/cache_update_worker.rb
+3
-9
config/feature_flags/development/remove_composer_v1_cache_code.yml
...ature_flags/development/remove_composer_v1_cache_code.yml
+0
-8
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+0
-3
spec/services/packages/composer/create_package_service_spec.rb
...services/packages/composer/create_package_service_spec.rb
+0
-25
spec/workers/every_sidekiq_worker_spec.rb
spec/workers/every_sidekiq_worker_spec.rb
+1
-1
spec/workers/packages/composer/cache_cleanup_worker_spec.rb
spec/workers/packages/composer/cache_cleanup_worker_spec.rb
+2
-6
spec/workers/packages/composer/cache_update_worker_spec.rb
spec/workers/packages/composer/cache_update_worker_spec.rb
+4
-4
No files found.
app/models/packages/composer/cache_file.rb
View file @
a5ffda8d
...
@@ -16,8 +16,6 @@ module Packages
...
@@ -16,8 +16,6 @@ module Packages
scope
:with_namespace
,
->
(
namespace
)
{
where
(
namespace:
namespace
)
}
scope
:with_namespace
,
->
(
namespace
)
{
where
(
namespace:
namespace
)
}
scope
:with_sha
,
->
(
sha
)
{
where
(
file_sha256:
sha
)
}
scope
:with_sha
,
->
(
sha
)
{
where
(
file_sha256:
sha
)
}
scope
:expired
,
->
{
where
(
"delete_at <= ?"
,
Time
.
current
)
}
scope
:without_namespace
,
->
{
where
(
namespace_id:
nil
)
}
end
end
end
end
end
end
app/services/packages/composer/create_package_service.rb
View file @
a5ffda8d
...
@@ -17,10 +17,6 @@ module Packages
...
@@ -17,10 +17,6 @@ module Packages
})
})
end
end
unless
Feature
.
enabled?
(
:remove_composer_v1_cache_code
,
project
)
::
Packages
::
Composer
::
CacheUpdateWorker
.
perform_async
(
created_package
.
project_id
,
created_package
.
name
,
nil
)
end
created_package
created_package
end
end
...
...
app/workers/packages/composer/cache_cleanup_worker.rb
View file @
a5ffda8d
...
@@ -14,19 +14,7 @@ module Packages
...
@@ -14,19 +14,7 @@ module Packages
idempotent!
idempotent!
def
perform
def
perform
::
Packages
::
Composer
::
CacheFile
.
without_namespace
.
find_in_batches
do
|
cache_files
|
# no-op: to be removed after 14.5 https://gitlab.com/gitlab-org/gitlab/-/issues/333694
cache_files
.
each
(
&
:destroy
)
rescue
ActiveRecord
::
RecordNotFound
# ignore. likely due to object already being deleted.
end
::
Packages
::
Composer
::
CacheFile
.
expired
.
find_in_batches
do
|
cache_files
|
cache_files
.
each
(
&
:destroy
)
rescue
ActiveRecord
::
RecordNotFound
# ignore. likely due to object already being deleted.
end
rescue
StandardError
=>
e
Gitlab
::
ErrorTracking
.
log_exception
(
e
)
end
end
end
end
end
end
...
...
app/workers/packages/composer/cache_update_worker.rb
View file @
a5ffda8d
...
@@ -7,20 +7,14 @@ module Packages
...
@@ -7,20 +7,14 @@ module Packages
data_consistency
:always
data_consistency
:always
sidekiq_options
retry:
3
sidekiq_options
retry:
false
feature_category
:package_registry
feature_category
:package_registry
idempotent!
idempotent!
def
perform
(
project_id
,
package_name
,
last_page_sha
)
def
perform
(
*
args
)
project
=
Project
.
find_by_id
(
project_id
)
# no-op: to be removed after 14.5 https://gitlab.com/gitlab-org/gitlab/-/issues/333694
return
unless
project
Gitlab
::
Composer
::
Cache
.
new
(
project:
project
,
name:
package_name
,
last_page_sha:
last_page_sha
).
execute
rescue
StandardError
=>
e
Gitlab
::
ErrorTracking
.
log_exception
(
e
,
project_id:
project_id
)
end
end
end
end
end
end
...
...
config/feature_flags/development/remove_composer_v1_cache_code.yml
deleted
100644 → 0
View file @
7a2f033b
---
name
:
remove_composer_v1_cache_code
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67843
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/338264
milestone
:
'
14.2'
type
:
development
group
:
group::package
default_enabled
:
false
config/initializers/1_settings.rb
View file @
a5ffda8d
...
@@ -466,9 +466,6 @@ Settings.cron_jobs['personal_access_tokens_expired_notification_worker']['job_cl
...
@@ -466,9 +466,6 @@ Settings.cron_jobs['personal_access_tokens_expired_notification_worker']['job_cl
Settings
.
cron_jobs
[
'repository_archive_cache_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'repository_archive_cache_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'repository_archive_cache_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'repository_archive_cache_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'repository_archive_cache_worker'
][
'job_class'
]
=
'RepositoryArchiveCacheWorker'
Settings
.
cron_jobs
[
'repository_archive_cache_worker'
][
'job_class'
]
=
'RepositoryArchiveCacheWorker'
Settings
.
cron_jobs
[
'packages_composer_cache_cleanup_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'packages_composer_cache_cleanup_worker'
][
'cron'
]
||=
'30 * * * *'
Settings
.
cron_jobs
[
'packages_composer_cache_cleanup_worker'
][
'job_class'
]
=
'Packages::Composer::CacheCleanupWorker'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'job_class'
]
=
'ImportExportProjectCleanupWorker'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'job_class'
]
=
'ImportExportProjectCleanupWorker'
...
...
spec/services/packages/composer/create_package_service_spec.rb
View file @
a5ffda8d
...
@@ -24,25 +24,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
...
@@ -24,25 +24,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
let
(
:created_package
)
{
Packages
::
Package
.
composer
.
last
}
let
(
:created_package
)
{
Packages
::
Package
.
composer
.
last
}
shared_examples
'using the cache update worker'
do
context
'with remove_composer_v1_cache_code enabled'
do
it
'does not enqueue a cache update job'
do
expect
(
::
Packages
::
Composer
::
CacheUpdateWorker
).
not_to
receive
(
:perform_async
)
subject
end
end
context
'with remove_composer_v1_cache_code disabled'
do
it
'enqueues a cache update job'
do
stub_feature_flags
(
remove_composer_v1_cache_code:
true
)
expect
(
::
Packages
::
Composer
::
CacheUpdateWorker
).
not_to
receive
(
:perform_async
)
subject
end
end
end
context
'without an existing package'
do
context
'without an existing package'
do
context
'with a branch'
do
context
'with a branch'
do
let
(
:branch
)
{
project
.
repository
.
find_branch
(
'master'
)
}
let
(
:branch
)
{
project
.
repository
.
find_branch
(
'master'
)
}
...
@@ -64,7 +45,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
...
@@ -64,7 +45,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
it_behaves_like
'assigns build to package'
it_behaves_like
'assigns build to package'
it_behaves_like
'assigns status to package'
it_behaves_like
'assigns status to package'
it_behaves_like
'using the cache update worker'
end
end
context
'with a tag'
do
context
'with a tag'
do
...
@@ -89,7 +69,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
...
@@ -89,7 +69,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
it_behaves_like
'assigns build to package'
it_behaves_like
'assigns build to package'
it_behaves_like
'assigns status to package'
it_behaves_like
'assigns status to package'
it_behaves_like
'using the cache update worker'
end
end
end
end
...
@@ -106,8 +85,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
...
@@ -106,8 +85,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
.
to
change
{
Packages
::
Package
.
composer
.
count
}.
by
(
0
)
.
to
change
{
Packages
::
Package
.
composer
.
count
}.
by
(
0
)
.
and
change
{
Packages
::
Composer
::
Metadatum
.
count
}.
by
(
0
)
.
and
change
{
Packages
::
Composer
::
Metadatum
.
count
}.
by
(
0
)
end
end
it_behaves_like
'using the cache update worker'
end
end
context
'belonging to another project'
do
context
'belonging to another project'
do
...
@@ -129,8 +106,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
...
@@ -129,8 +106,6 @@ RSpec.describe Packages::Composer::CreatePackageService do
.
to
change
{
Packages
::
Package
.
composer
.
count
}.
by
(
1
)
.
to
change
{
Packages
::
Package
.
composer
.
count
}.
by
(
1
)
.
and
change
{
Packages
::
Composer
::
Metadatum
.
count
}.
by
(
1
)
.
and
change
{
Packages
::
Composer
::
Metadatum
.
count
}.
by
(
1
)
end
end
it_behaves_like
'using the cache update worker'
end
end
end
end
end
end
...
...
spec/workers/every_sidekiq_worker_spec.rb
View file @
a5ffda8d
...
@@ -359,7 +359,7 @@ RSpec.describe 'Every Sidekiq worker' do
...
@@ -359,7 +359,7 @@ RSpec.describe 'Every Sidekiq worker' do
'ObjectPool::ScheduleJoinWorker'
=>
3
,
'ObjectPool::ScheduleJoinWorker'
=>
3
,
'ObjectStorage::BackgroundMoveWorker'
=>
5
,
'ObjectStorage::BackgroundMoveWorker'
=>
5
,
'ObjectStorage::MigrateUploadsWorker'
=>
3
,
'ObjectStorage::MigrateUploadsWorker'
=>
3
,
'Packages::Composer::CacheUpdateWorker'
=>
3
,
'Packages::Composer::CacheUpdateWorker'
=>
false
,
'Packages::Go::SyncPackagesWorker'
=>
3
,
'Packages::Go::SyncPackagesWorker'
=>
3
,
'Packages::Maven::Metadata::SyncWorker'
=>
3
,
'Packages::Maven::Metadata::SyncWorker'
=>
3
,
'Packages::Nuget::ExtractionWorker'
=>
3
,
'Packages::Nuget::ExtractionWorker'
=>
3
,
...
...
spec/workers/packages/composer/cache_cleanup_worker_spec.rb
View file @
a5ffda8d
...
@@ -18,12 +18,8 @@ RSpec.describe Packages::Composer::CacheCleanupWorker, type: :worker do
...
@@ -18,12 +18,8 @@ RSpec.describe Packages::Composer::CacheCleanupWorker, type: :worker do
cache_file4
.
update_columns
(
namespace_id:
nil
)
cache_file4
.
update_columns
(
namespace_id:
nil
)
end
end
it
'deletes expired packages'
do
it
'does nothing'
do
expect
{
subject
}.
to
change
{
Packages
::
Composer
::
CacheFile
.
count
}.
by
(
-
2
)
expect
{
subject
}.
not_to
change
{
Packages
::
Composer
::
CacheFile
.
count
}
expect
{
cache_file1
.
reload
}.
not_to
raise_error
ActiveRecord
::
RecordNotFound
expect
{
cache_file2
.
reload
}.
not_to
raise_error
ActiveRecord
::
RecordNotFound
expect
{
cache_file3
.
reload
}.
to
raise_error
ActiveRecord
::
RecordNotFound
expect
{
cache_file4
.
reload
}.
to
raise_error
ActiveRecord
::
RecordNotFound
end
end
end
end
end
end
spec/workers/packages/composer/cache_update_worker_spec.rb
View file @
a5ffda8d
...
@@ -21,8 +21,8 @@ RSpec.describe Packages::Composer::CacheUpdateWorker, type: :worker do
...
@@ -21,8 +21,8 @@ RSpec.describe Packages::Composer::CacheUpdateWorker, type: :worker do
include_examples
'an idempotent worker'
do
include_examples
'an idempotent worker'
do
context
'creating a package'
do
context
'creating a package'
do
it
'
updates the cache
'
do
it
'
does nothing
'
do
expect
{
subject
}.
to
change
{
Packages
::
Composer
::
CacheFile
.
count
}.
by
(
1
)
expect
{
subject
}.
to
change
{
Packages
::
Composer
::
CacheFile
.
count
}.
by
(
0
)
end
end
end
end
...
@@ -36,12 +36,12 @@ RSpec.describe Packages::Composer::CacheUpdateWorker, type: :worker do
...
@@ -36,12 +36,12 @@ RSpec.describe Packages::Composer::CacheUpdateWorker, type: :worker do
package
.
destroy!
package
.
destroy!
end
end
it
'
marks the file for deletion
'
do
it
'
does nothing
'
do
expect
{
subject
}.
not_to
change
{
Packages
::
Composer
::
CacheFile
.
count
}
expect
{
subject
}.
not_to
change
{
Packages
::
Composer
::
CacheFile
.
count
}
cache_file
=
Packages
::
Composer
::
CacheFile
.
last
cache_file
=
Packages
::
Composer
::
CacheFile
.
last
expect
(
cache_file
.
reload
.
delete_at
).
not_
to
be_nil
expect
(
cache_file
.
reload
.
delete_at
).
to
be_nil
end
end
end
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