Compare commits

...

9 Commits

Author SHA1 Message Date
Will Chandler 243e9979e4 Merge branch 'wc/no-dup-gitaly-storages' into 'master'
Prevent Gitaly storages from using the same path

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

Merged-by: Will Chandler <wchandler@gitlab.com>
Approved-by: Gabriel Mazetto <gabriel@gitlab.com>
Reviewed-by: Gabriel Mazetto <gabriel@gitlab.com>
Reviewed-by: Will Chandler <wchandler@gitlab.com>
Reviewed-by: Robert Marshall <rmarshall@gitlab.com>
2024-05-06 19:04:58 +00:00
Andrew Patterson 196b5a3326 Merge branch 'deps/19dfc8b-42de0a3' into 'master'
Update gitlab-org/container-registry from v3.93.0-gitlab to v4.0.0-gitlab

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

Merged-by: Andrew Patterson <apatterson@gitlab.com>
Approved-by: Clemens Beck <cbeck@gitlab.com>
Approved-by: Andrew Patterson <apatterson@gitlab.com>
Co-authored-by: deps <bot@dependencies.io>
2024-05-06 17:32:03 +00:00
deps 242873ad43 Update gitlab-org/container-registry from v3.93.0-gitlab to v4.0.0-gitlab
Changelog: changed
2024-05-02 08:21:39 +00:00
Will Chandler 53a378fb7f Don't modify original config object
Use `Marshal` to avoid mutating the original copy of the storage config.
2024-05-01 13:18:42 -04:00
Will Chandler e29a335bd2 Fix path and error assertion 2024-05-01 10:38:06 -04:00
Will Chandler b05ee40fba Apply Rubocop fixes 2024-05-01 09:16:22 -04:00
Will Chandler 0764b6b029 Cleanup tmp dirs in spec 2024-04-30 13:42:55 -04:00
Will Chandler 4b500efe11 Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Gabriel Mazetto <gabriel@gitlab.com>
2024-04-30 17:37:07 +00:00
Will Chandler 4a0233840f Prevent Gitaly storages from using the same path
Gitaly is making a breaking change with v17.0 to prevent multiple
storages from sharing the same local path. This is being done as part of
the work to add a write-ahead log to Gitaly, see
https://gitlab.com/gitlab-org/gitaly/-/issues/5598 for further details.

Validate that Gitaly's config does not have than one storage using the
same path, dereferencing any symlinks.

Changelog: changed
2024-04-24 11:51:16 -04:00
3 changed files with 70 additions and 1 deletions

View File

@ -19,7 +19,7 @@
require "#{Omnibus::Config.project_root}/lib/gitlab/version"
name 'registry'
version = Gitlab::Version.new('registry', 'v3.93.0-gitlab')
version = Gitlab::Version.new('registry', 'v4.0.0-gitlab')
default_version version.print(false)
display_version version.print(false).delete_suffix('-gitlab')

View File

@ -27,6 +27,7 @@ module Gitaly
parse_git_data_dirs
parse_gitaly_storages
parse_gitconfig
check_duplicate_storage_paths
end
def gitaly_address
@ -160,6 +161,32 @@ module Gitaly
Chef::Mixin::DeepMerge.deep_merge!(tmp_source_hash, Gitlab['gitaly'])
end
# Validate that no storages are sharing the same path.
def check_duplicate_storage_paths
# Deep copy storages to avoid mutating the original.
storages = Marshal.load(Marshal.dump(Gitlab['gitaly']['configuration']['storage']))
storages.each do |storage|
storage[:realpath] =
begin
File.realpath(storage[:path])
rescue Errno::ENOENT
storage[:path]
end
end
realpath_duplicates = storages.group_by { |storage| storage[:realpath] }.select { |_, entries| entries.size > 1 }
return if realpath_duplicates.empty?
output = realpath_duplicates.map do |realpath, entries|
names = entries.map { |s| s[:name] }.join(', ')
"#{realpath}: #{names}"
end
raise "More than one Gitaly storage assigned to the same realpath:\n #{output.join('\n ')}"
end
private
def user_config

View File

@ -803,6 +803,48 @@ RSpec.describe 'gitaly' do
.with_content(%r{\[\[storage\]\]\s+name = "nfs1"\s+path = "/mnt/nfs1/repositories"})
end
end
context 'with multiple storages using the same path' do
let(:real_path) { Dir.mktmpdir }
let(:other_dir) { Dir.mktmpdir }
let(:symlink_path) { File.join(other_dir, 'symlink') }
before do
File.symlink(real_path, symlink_path)
stub_gitlab_rb(
gitaly: {
configuration: {
storage: [
{
'name' => 'default',
'path' => '/var/opt/gitlab/git-data/repositories'
},
{
'name' => 'other',
'path' => '/var/opt/gitlab/git-data/repositories'
},
{
'name' => 'realpath',
'path' => real_path
},
{
'name' => 'symlinked',
'path' => symlink_path,
}
]
}
}
)
end
after do
FileUtils.rm_rf([real_path, other_dir])
end
it 'raises an error' do
expect { chef_run }.to raise_error(/More than one Gitaly storage assigned to the same realpath:.*: default.*: realpath/m)
end
end
end
end
end