Rugged feature flags default to enabled when using local storage

Summary

The Rugged feature flags are being enabled by default when using local storage. These should ONLY default to enabled when using NFS.

As a result most customers using v12.2+ will have Rugged enabled and must explicitly disable the feature flags to get rid of it.

Steps to reproduce

  1. Create new GitLab instance - use default storage of /var/opt/gitlab/git-data
  2. Create a new project
  3. Validate that Rugged is enabled for project with:
sudo gitlab-rails console
include Gitlab::Git::RuggedImpl::UseRugged 
repo = Project.find_by_full_path('group/project').repository
flag = 'rugged_find_commit'
use_rugged?(repo, flag)

What is the current bug behavior?

Rugged feature flags are enabled for repos using local storage

What is the expected correct behavior?

Rugged feature flags are ONLY enabled for repos hosted on NFS

Relevant logs and/or screenshots

Log from fresh 12.5.3 instance, note that rugged_calls and rugged_duration_ms are present:

{
  "method": "GET",
  "path": "/root/storage-test",
  "format": "html",
  "controller": "ProjectsController",
  "action": "show",
  "status": 200,
  "duration": 2373.19,
  "view": 2027.3,
  "db": 233.96,
  "time": "2019-12-03T15:42:14.352Z",
  "params": [
    {
      "key": "namespace_id",
      "value": "root"
    },
    {
      "key": "id",
      "value": "storage-test"
    }
  ],
  "remote_ip": "68.235.43.84",
  "user_id": 1,
  "username": "root",
  "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
  "queue_duration": 5.08,
  "gitaly_calls": 6,
  "gitaly_duration": 23.8,
  "rugged_calls": 7,
  "rugged_duration_ms": 2.77,
  "correlation_id": "96xNR5TO8b7",
  "cpu_s": 1.443483253000000

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

System information System: Ubuntu 18.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.6.3p62 Gem Version: 2.7.9 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 3.2.12 Git Version: 2.22.0 Sidekiq Version:5.2.7 Go Version: unknown

GitLab information Version: 12.5.3-ee Revision: 63955893276 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 10.9 Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers:

GitLab Shell Version: 10.2.0 Repository storage paths:

  • default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 10.2.0 ? ... OK (10.2.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 1/1 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.3) Git version >= 2.22.0 ? ... yes (2.22.0) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Possible fixes

The current logic in Gitlab::Git::RuggedImpl::UseRugged#use_rugged is:

  • IF RUGGED_FEATURE_FLAG is explicitly set, use that value
  • ELSE turn on RUGGED_FEATURE IF Gitlab::GitalyClient#can_use_disk? returns true

can_use_disk?'s logic is:

  • IF the repo's storage filesystem_id exists
  • AND the filesystem_id present in Rails matches the filesystem_id in the .gitaly-metadata file
  • THEN return true

These two filesystem_ids will NOT match when using a remote Gitaly server, but will when using EITHER local storage OR NFS. We need to distinguish between NFS and local storage here.

Original issue: gitlab-foss#60931 (closed)

Initial MR: gitlab-foss!29725 (merged)

Follow-up MR: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/30871

/cc @johncai @stanhu

Assignee Loading
Time tracking Loading