Skip to content

Storage calculation is counting LFS objects twice

gitlab-com/infrastructure#1498 is blocked by this.

Disclaimer

I believe this is the right behaviour for 9.0 if you know differently about how 9.0 was supposed to count storage, please let me know.

The high-level problem is a bit of a mind-bend since we are still discussing what we want to count here gitlab-org/gitlab-ce#30300.

What is the current bug behavior?

We add up repository_size + build_artifacts_size + lfs_objects_size + lfs_objects_size

What is the expected correct behavior?

Enforce on: repository_size + lfs_objects_size

Suggested fix

The following method in the Project model seems broken:

  def repository_and_lfs_size
    statistics.storage_size + statistics.lfs_objects_size
  end

It counts LFS objects twice because LFS objects are included in storage_size. Fix might be statistics.total_repository_size