Commit d153d950 authored by Nick Thomas's avatar Nick Thomas

Remove cleanup_lfs_during_gc feature flag

This enables the feature, and also adds some documentation for it
parent 12f25f34
...@@ -91,7 +91,6 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -91,7 +91,6 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker
end end
def cleanup_orphan_lfs_file_references(project) def cleanup_orphan_lfs_file_references(project)
return unless Feature.enabled?(:cleanup_lfs_during_gc, project)
return if Gitlab::Database.read_only? # GitGarbageCollectWorker may be run on a Geo secondary return if Gitlab::Database.read_only? # GitGarbageCollectWorker may be run on a Geo secondary
::Gitlab::Cleanup::OrphanLfsFileReferences.new(project, dry_run: false, logger: logger).run! ::Gitlab::Cleanup::OrphanLfsFileReferences.new(project, dry_run: false, logger: logger).run!
......
---
title: Clean up unused LFS objects during repository housekeeping
merge_request: 40979
author:
type: added
---
name: cleanup_lfs_during_gc
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38813
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/238605
group: group::source code
type: development
default_enabled: false
...@@ -28,6 +28,9 @@ the `pushes_since_gc` value is 200 a `git gc` will be run. ...@@ -28,6 +28,9 @@ the `pushes_since_gc` value is 200 a `git gc` will be run.
`git add`. `git add`.
- `git repack` ([man page](https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-repack.html)) re-organize existing packs into a single, more efficient pack. - `git repack` ([man page](https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-repack.html)) re-organize existing packs into a single, more efficient pack.
Housekeeping will also [remove unreferenced LFS files](../raketasks/cleanup.md#remove-unreferenced-lfs-files)
from your project on the same schedule as the `git gc` operation, freeing up storage space for your project.
You can find this option under your project's **Settings > General > Advanced**. You can find this option under your project's **Settings > General > Advanced**.
![Housekeeping settings](img/housekeeping_settings.png) ![Housekeeping settings](img/housekeeping_settings.png)
...@@ -230,6 +230,7 @@ This will: ...@@ -230,6 +230,7 @@ This will:
- Run `git gc` against the repository to remove unreferenced objects. Repacking your repository will temporarily - Run `git gc` against the repository to remove unreferenced objects. Repacking your repository will temporarily
cause the size of your repository to increase significantly, because the old pack files are not removed until the cause the size of your repository to increase significantly, because the old pack files are not removed until the
new pack files have been created. new pack files have been created.
- Unlink any unused LFS objects currently attached to your project, freeing up storage space.
- Recalculate the size of your repository on disk. - Recalculate the size of your repository on disk.
You will receive an email notification with the recalculated repository size after the cleanup has completed. You will receive an email notification with the recalculated repository size after the cleanup has completed.
......
...@@ -129,11 +129,6 @@ RSpec.describe GitGarbageCollectWorker do ...@@ -129,11 +129,6 @@ RSpec.describe GitGarbageCollectWorker do
let_it_be(:lfs_reference) { create(:lfs_objects_project, project: project) } let_it_be(:lfs_reference) { create(:lfs_objects_project, project: project) }
let(:lfs_object) { lfs_reference.lfs_object } let(:lfs_object) { lfs_reference.lfs_object }
context 'with cleanup_lfs_during_gc feature flag enabled' do
before do
stub_feature_flags(cleanup_lfs_during_gc: true)
end
it 'cleans up unreferenced LFS objects' do it 'cleans up unreferenced LFS objects' do
expect_next_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences) do |svc| expect_next_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences) do |svc|
expect(svc.project).to eq(project) expect(svc.project).to eq(project)
...@@ -146,16 +141,6 @@ RSpec.describe GitGarbageCollectWorker do ...@@ -146,16 +141,6 @@ RSpec.describe GitGarbageCollectWorker do
expect(project.lfs_objects.reload).not_to include(lfs_object) expect(project.lfs_objects.reload).not_to include(lfs_object)
end end
it 'does nothing if the database is read-only' do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences).not_to receive(:run!)
subject.perform(*params)
expect(project.lfs_objects.reload).to include(lfs_object)
end
it 'catches and logs exceptions' do it 'catches and logs exceptions' do
expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences) expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences)
.to receive(:run!) .to receive(:run!)
...@@ -166,14 +151,9 @@ RSpec.describe GitGarbageCollectWorker do ...@@ -166,14 +151,9 @@ RSpec.describe GitGarbageCollectWorker do
subject.perform(*params) subject.perform(*params)
end end
end
context 'with cleanup_lfs_during_gc feature flag disabled' do
before do
stub_feature_flags(cleanup_lfs_during_gc: false)
end
it 'does not clean up unreferenced LFS objects' do it 'does nothing if the database is read-only' do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences).not_to receive(:run!) expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences).not_to receive(:run!)
subject.perform(*params) subject.perform(*params)
...@@ -182,7 +162,6 @@ RSpec.describe GitGarbageCollectWorker do ...@@ -182,7 +162,6 @@ RSpec.describe GitGarbageCollectWorker do
end end
end end
end end
end
context 'when no lease can be obtained' do context 'when no lease can be obtained' do
before do before do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment