Skip to content
Snippets Groups Projects
Commit fc3986469884 authored by Balasankar 'Balu' C's avatar Balasankar 'Balu' C
Browse files

Add Gitaly role


Changelog: added
Signed-off-by: default avatarBalasankar "Balu" C <balasankar@gitlab.com>
parent 0439e0b74868
No related branches found
No related tags found
3 merge requests!165Merge upstream Omnibus GitLab into Omnibus Heptapod,!164Merge upstream Omnibus GitLab into Omnibus Heptapod,!163Merge upstream Omnibus GitLab into Omnibus Heptapod
...@@ -188,3 +188,14 @@ ...@@ -188,3 +188,14 @@
Configures the server with spamcheck and spam-classifier services. Configures the server with spamcheck and spam-classifier services.
*By default, enables no other services.* *By default, enables no other services.*
### Gitaly Roles
Gitaly roles are used to set up and configure Gitaly services. For additional
information, see the [Gitaly documentation](https://docs.gitlab.com/ee/administration/gitaly/)
- **gitaly_role** (`gitlab-ce`/`gitlab-ee`)
Configures the server with Gitaly service.
*By default, enables no other services.*
...@@ -34,8 +34,21 @@ ...@@ -34,8 +34,21 @@
## Roles for multi-instance GitLab ## Roles for multi-instance GitLab
##! The default is to have no roles enabled, which results in GitLab running as an all-in-one instance. ##! The default is to have no roles enabled, which results in GitLab running as an all-in-one instance.
##! Options: ##! Options:
##! redis_sentinel_role redis_master_role redis_replica_role geo_primary_role geo_secondary_role ##! application_role
##! postgres_role consul_role application_role monitoring_role ##! redis_sentinel_role
##! redis_master_role
##! redis_replica_role
##! monitoring_role
##! geo_primary_role
##! geo_secondary_role
##! postgres_role
##! patroni_role
##! consul_role
##! pgbouncer_role
##! pages_role
##! sidekiq_role
##! spamcheck_role
##! gitaly_role
##! For more details on each role, see: ##! For more details on each role, see:
##! https://docs.gitlab.com/omnibus/roles/index.html#roles ##! https://docs.gitlab.com/omnibus/roles/index.html#roles
##! ##!
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
role('consul').use { ConsulRole } role('consul').use { ConsulRole }
role('pages').use { PagesRole } role('pages').use { PagesRole }
role('spamcheck').use { SpamcheckRole } role('spamcheck').use { SpamcheckRole }
role('gitaly').use { GitalyRole }
## Attributes directly on the node ## Attributes directly on the node
attribute('package').use { Package } attribute('package').use { Package }
......
module GitalyRole
def self.load_role
return unless Gitlab['gitaly_role']['enable']
# Turning off GitLab Rails unless explicitly enabled.
Gitlab['gitlab_rails']['enable'] ||= false
Services.enable_group('gitaly_role')
end
end
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
service 'sidekiq', groups: [DEFAULT_GROUP, 'rails', 'sidekiq', 'sidekiq_role'] service 'sidekiq', groups: [DEFAULT_GROUP, 'rails', 'sidekiq', 'sidekiq_role']
service 'gitlab_exporter', groups: [DEFAULT_GROUP, 'rails', 'monitoring'] service 'gitlab_exporter', groups: [DEFAULT_GROUP, 'rails', 'monitoring']
service 'gitlab_workhorse', groups: [DEFAULT_GROUP, 'rails'] service 'gitlab_workhorse', groups: [DEFAULT_GROUP, 'rails']
service 'gitaly', groups: [DEFAULT_GROUP, 'rails'] service 'gitaly', groups: [DEFAULT_GROUP, 'rails', 'gitaly_role']
service 'redis', groups: [DEFAULT_GROUP, 'redis', 'redis_node'] service 'redis', groups: [DEFAULT_GROUP, 'redis', 'redis_node']
service 'redis_exporter', groups: [DEFAULT_GROUP, 'redis', 'redis_node', 'monitoring'] service 'redis_exporter', groups: [DEFAULT_GROUP, 'redis', 'redis_node', 'monitoring']
service 'postgresql', groups: [DEFAULT_GROUP, 'postgres', 'postgres_role', 'patroni_role'] service 'postgresql', groups: [DEFAULT_GROUP, 'postgres', 'postgres_role', 'patroni_role']
......
...@@ -122,4 +122,16 @@ ...@@ -122,4 +122,16 @@
expect(Services).to have_received(:enable_group).with('monitoring_role').once expect(Services).to have_received(:enable_group).with('monitoring_role').once
end end
end end
include_context 'recipes'
describe 'GitalyRole' do
context 'by default' do
include_examples 'enable only default service recipes'
end
context 'when enabled' do
include_examples 'enable recipes required for the service only', ['gitaly_role'], ['gitaly::enable', 'gitaly::git_data_dirs'], ['gitaly::disable']
end
end
end end
require 'chef_helper'
RSpec.shared_context 'recipes' do
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab-ee::default') }
let(:mandatory_recipes) do
recipes =
[
"gitlab-ee::default",
"pgbouncer::user",
"gitlab::default",
"gitlab::config",
"postgresql::directory_locations",
"gitlab::web-server",
"gitlab::users",
"gitlab::selinux",
"gitlab::add_trusted_certs",
"package::runit",
"package::sysctl",
"logrotate::enable",
"logrotate::folders_and_configs",
"postgresql::bin",
"gitlab::bootstrap",
"monitoring::default",
"monitoring::node-exporter",
"monitoring::user"
]
runit_recipe = if File.directory?('/run/systemd/system')
["package::runit_systemd"]
else
[]
end
recipes + runit_recipe
end
let(:default_service_enable_recipes) do
["gitlab::gitlab-rails",
"gitaly::git_data_dirs",
"gitlab::rails_pages_shared_path",
"gitlab::gitlab-shell",
"redis::enable",
"gitaly::enable",
"postgresql::enable",
"postgresql::user",
"postgresql::sysctl",
"postgresql::standalone",
"gitlab-kas::enable",
"gitlab::database_migrations",
"gitlab::puma",
"gitlab::sidekiq",
"gitlab::gitlab-workhorse",
"gitlab::nginx",
"nginx::enable",
"gitlab::gitlab-healthcheck",
"monitoring::gitlab-exporter",
"monitoring::redis-exporter",
"monitoring::prometheus",
"monitoring::alertmanager",
"monitoring::postgres-exporter",
"gitlab-ee::suggested_reviewers"]
end
let(:default_service_disable_recipes) do
[
"redis::disable",
"gitaly::disable",
"postgresql::disable",
"gitlab-kas::disable",
"gitlab::puma_disable",
"gitlab::sidekiq_disable",
"gitlab::gitlab-workhorse_disable",
"gitlab::nginx_disable",
"monitoring::gitlab-exporter_disable",
"monitoring::redis-exporter_disable",
"monitoring::prometheus_disable",
"monitoring::alertmanager_disable",
"monitoring::postgres-exporter_disable",
]
end
let(:extra_disable_recipes) do
[
"spamcheck::disable",
"praefect::disable",
"crond::disable",
"gitlab::mailroom_disable",
"gitlab::remote-syslog_disable",
"gitlab::storage-check_disable",
"gitlab-pages::disable",
"registry::disable",
"mattermost::disable",
"letsencrypt::disable",
"monitoring::pgbouncer-exporter_disable",
"gitlab::gitlab-backup-cli_disable",
"gitlab::database_reindexing_disable",
"gitlab-ee::sentinel_disable",
"gitlab-ee::geo-postgresql_disable",
"gitlab-ee::geo-logcursor_disable",
"consul::disable",
"consul::disable_daemon",
"pgbouncer::disable",
"patroni::disable",
"gitlab-ee::geo-secondary_disable",
]
end
shared_examples 'enable only default service recipes' do
it 'only default service recipes are run' do
expected_recipes = mandatory_recipes + default_service_enable_recipes + extra_disable_recipes
expect(chef_run.run_context.loaded_recipes).to match_array(expected_recipes)
end
end
shared_examples 'enable recipes required for the service only' do |roles, include_recipes, exclude_recipes|
before do
stub_gitlab_rb(
roles: roles
)
end
it 'only recipes required for the service are run' do
expected_recipes = mandatory_recipes + default_service_disable_recipes + extra_disable_recipes + include_recipes - exclude_recipes
expect(chef_run.run_context.loaded_recipes).to match_array(expected_recipes)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment