Commit 168af001 authored by Kerri Miller's avatar Kerri Miller

Merge branch '238605-remove-cleanup-lfs-during-gc-feature-flag' into 'master'

Remove cleanup_lfs_during_gc feature flag

Closes #224753 and #238605

See merge request gitlab-org/gitlab!40979
parents a33b43ce d153d950
......@@ -91,7 +91,6 @@ class GitGarbageCollectWorker # rubocop:disable Scalability/IdempotentWorker
end
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
::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.
`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.
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**.
![Housekeeping settings](img/housekeeping_settings.png)
......@@ -230,6 +230,7 @@ This will:
- 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
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.
You will receive an email notification with the recalculated repository size after the cleanup has completed.
......
......@@ -129,57 +129,36 @@ RSpec.describe GitGarbageCollectWorker do
let_it_be(:lfs_reference) { create(:lfs_objects_project, project: project) }
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)
it 'cleans up unreferenced LFS objects' do
expect_next_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences) do |svc|
expect(svc.project).to eq(project)
expect(svc.dry_run).to be_falsy
expect(svc).to receive(:run!).and_call_original
end
it 'cleans up unreferenced LFS objects' do
expect_next_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences) do |svc|
expect(svc.project).to eq(project)
expect(svc.dry_run).to be_falsy
expect(svc).to receive(:run!).and_call_original
end
subject.perform(*params)
expect(project.lfs_objects.reload).not_to include(lfs_object)
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)
subject.perform(*params)
expect(project.lfs_objects.reload).to include(lfs_object)
end
expect(project.lfs_objects.reload).not_to include(lfs_object)
end
it 'catches and logs exceptions' do
expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences)
.to receive(:run!)
.and_raise(/Failed/)
it 'catches and logs exceptions' do
expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences)
.to receive(:run!)
.and_raise(/Failed/)
expect(Gitlab::GitLogger).to receive(:warn)
expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
expect(Gitlab::GitLogger).to receive(:warn)
expect(Gitlab::ErrorTracking).to receive(:track_and_raise_for_dev_exception)
subject.perform(*params)
end
subject.perform(*params)
end
context 'with cleanup_lfs_during_gc feature flag disabled' do
before do
stub_feature_flags(cleanup_lfs_during_gc: false)
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!)
it 'does not clean up unreferenced LFS objects' do
expect_any_instance_of(Gitlab::Cleanup::OrphanLfsFileReferences).not_to receive(:run!)
subject.perform(*params)
subject.perform(*params)
expect(project.lfs_objects.reload).to include(lfs_object)
end
expect(project.lfs_objects.reload).to include(lfs_object)
end
end
end
......
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