Backup rake task is failing on nodes with services disabled

Summary

gitlab-rake gitlab:backup:create is failing on nodes with services disabled

Steps to reproduce

  1. Ensure a service such as pages, lfs, terraform_state, registry, or packages is disabled, reconfigure has run, and the directories in gitlab.yml don't exist.
  2. Run gitlab-rake gitlab:backup:create
  3. You will see an error like:
    # gitlab-rake gitlab:backup:create
    rake aborted!
    Errno::ENOENT: No such file or directory @ rb_check_realpath_internal - 
    /var/opt/gitlab/gitlab-rails/shared/registry
    /opt/gitlab/embedded/service/gitlab-rails/lib/backup/files.rb:16:in `realpath'
    /opt/gitlab/embedded/service/gitlab-rails/lib/backup/files.rb:16:in `initialize'
    /opt/gitlab/embedded/service/gitlab-rails/lib/backup/registry.rb:10:in `initialize'
    /opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:29:in `new'
    /opt/gitlab/embedded/service/gitlab-rails/lib/backup/manager.rb:29:in `initialize'
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:12:in `new'
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/backup.rake:12:in `block (3 
    levels) in <top (required)>'
    /opt/gitlab/embedded/bin/bundle:23:in `load'
    /opt/gitlab/embedded/bin/bundle:23:in `<main>'
    Tasks: TOP => gitlab:backup:create
    (See full trace by running task with --trace)

Seems to have been introduced by !79809 (merged)

Possible fixes

  • Change usage of File.realpath in https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/backup/files.rb#L14 to something else
  • Check if a service is enabled while building @tasks in https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/backup/manager.rb#L11
Edited Feb 18, 2022 by Nick Nguyen
Assignee Loading
Time tracking Loading