Skip to content

Draft: Never select storages that are weighted zero

James Fargher requested to merge remove_project_default_repository_storage into master

What does this MR do?

Fixes #36175

When creating a new project, the storage that the project repository is put in should be decided by a weighted random configuration in the admin https://docs.gitlab.com/ee/administration/repository_storage_paths.html#configure-where-new-repositories-are-stored. Ideally it wouldn't matter if we had a "default" storage or not, as long as someone has configured the weights.

There are a couple of problems that prevent this from working intuitively:

  • When a new storage is setup, by default it is assumed to have a weight of zero, unless it is called "default" then it is assumed to be 100. So if you have no storage called "default" then by default all weights are assumed to be zero. If all weights are zero, then they act like all weights are 100. This means new projects will be randomly assigned even when the admin doesn't want them to be. This does not follow our docs which say: (storage weight) / (sum of all weights) * 100 = chance % i.e. zero weight = zero chance.
  • If the weighted random finds no candidates, the projects column default will select 'default' regardless of configuration.

To make this work how we might expect this MR:

  • Explicitly filter out any storages that are set to zero. This makes sure when everything is zero on first bootup (because we have no "default") we wont accidentally put projects in unexpected storages.
  • Removes the column default for repository_storage. This makes sure that there's no chance of default being used when it is weighted zero. This column has a presence validation that will prevent projects being created in this case.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by James Fargher

Merge request reports

Loading