Merge branch 'create-git-data-dirs-when-gitlab-rails-is-disabled' into 'master'

Create git_data_dirs even if gitlab_rails is disabled

See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7459

Merged-by: Balasankar 'Balu' C <balasankar@gitlab.com>
Approved-by: Jason Plum <jplum@gitlab.com>
Approved-by: Andrew Patterson <apatterson@gitlab.com>
Approved-by: Balasankar 'Balu' C <balasankar@gitlab.com>
Co-authored-by: Ahmad Sherif <ahmad@gitlab.com>
This commit is contained in:
Balasankar 'Balu' C 2024-03-25 09:00:17 +00:00
commit aee82f523b
6 changed files with 74 additions and 27 deletions

View File

@ -32,6 +32,8 @@ cgroups_mountpoint = node.dig('gitaly', 'configuration', 'cgroups', 'mountpoint'
cgroups_hierarchy_root = node.dig('gitaly', 'configuration', 'cgroups', 'hierarchy_root')
use_wrapper = node['gitaly']['use_wrapper']
include_recipe 'gitaly::git_data_dirs'
directory working_dir do
owner account_helper.gitlab_user
mode '0700'

View File

@ -0,0 +1,41 @@
#
# Copyright:: Copyright (c) 2024 GitLab Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
account_helper = AccountHelper.new(node)
gitlab_user = account_helper.gitlab_user
gitlab_group = account_helper.gitlab_group
# Holds git-data, by default one shard at /var/opt/gitlab/git-data
# Can be changed by user using git_data_dirs option
Mash.new(Gitlab['git_data_dirs']).each do |_name, git_data_directory|
storage_directory git_data_directory['path'] do
owner gitlab_user
group gitlab_group
mode "0700"
end
end
# Holds git repositories, by default at /var/opt/gitlab/git-data/repositories
# Should not be changed by user. Different permissions to git_data_dir set.
repositories_storages = node['gitlab']['gitlab_rails']['repositories_storages']
repositories_storages.each do |_name, repositories_storage|
storage_directory repositories_storage['path'] do
owner gitlab_user
group gitlab_group
mode "2770"
end
end

View File

@ -43,26 +43,7 @@ node.normal['gitlab']['gitlab_rails']['registry_key_path'] = File.join(gitlab_ra
gitlab_user = account_helper.gitlab_user
gitlab_group = account_helper.gitlab_group
# Holds git-data, by default one shard at /var/opt/gitlab/git-data
# Can be changed by user using git_data_dirs option
Mash.new(Gitlab['git_data_dirs']).each do |_name, git_data_directory|
storage_directory git_data_directory['path'] do
owner gitlab_user
group gitlab_group
mode "0700"
end
end
# Holds git repositories, by default at /var/opt/gitlab/git-data/repositories
# Should not be changed by user. Different permissions to git_data_dir set.
repositories_storages = node['gitlab']['gitlab_rails']['repositories_storages']
repositories_storages.each do |_name, repositories_storage|
storage_directory repositories_storage['path'] do
owner gitlab_user
group gitlab_group
mode "2770"
end
end
include_recipe 'gitaly::git_data_dirs'
include_recipe 'gitlab::rails_pages_shared_path'

View File

@ -1031,6 +1031,26 @@ end
RSpec.describe 'gitaly::git_data_dirs' do
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab::default') }
before do
allow(Gitlab).to receive(:[]).and_call_original
stub_gitlab_rb(gitlab_rails: {
enable: false,
}, gitaly: {
enable: true,
}, git_data_dirs: {
'default' => {
'path' => '/tmp/git-data'
}
})
end
include_examples "git data directory", "/tmp/git-data"
end
RSpec.describe 'git_data_dirs configuration' do
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab::default') }
before do
allow(Gitlab).to receive(:[]).and_call_original
end

View File

@ -135,13 +135,7 @@ RSpec.describe 'gitlab::gitlab-rails' do
ChefSpec::SoloRunner.converge('gitlab::default')
end
it 'creates the git-data directory' do
expect(chef_run).to create_storage_directory('/tmp/git-data').with(owner: 'git', group: 'git', mode: '0700')
end
it 'creates the repositories directory' do
expect(chef_run).to create_storage_directory('/tmp/git-data/repositories').with(owner: 'git', group: 'git', mode: '2770')
end
include_examples "git data directory", "/tmp/git-data"
it 'creates the shared directory' do
expect(chef_run).to create_storage_directory('/tmp/shared').with(owner: 'git', group: 'gitlab-www', mode: '0751')

View File

@ -0,0 +1,9 @@
RSpec.shared_examples 'git data directory' do |git_data_path|
it 'creates the git-data directory' do
expect(chef_run).to create_storage_directory(git_data_path).with(owner: 'git', group: 'git', mode: '0700')
end
it 'creates the repositories directory' do
expect(chef_run).to create_storage_directory("#{git_data_path}/repositories").with(owner: 'git', group: 'git', mode: '2770')
end
end