diff --git a/files/gitlab-cookbooks/gitlab-ee/recipes/geo-logcursor.rb b/files/gitlab-cookbooks/gitlab-ee/recipes/geo-logcursor.rb index 5b31e14c59fa24d0a89a0ae29518908668e23598_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvcmVjaXBlcy9nZW8tbG9nY3Vyc29yLnJi..578aa3a670d4547c5fb5aa96877c75db34810526_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvcmVjaXBlcy9nZW8tbG9nY3Vyc29yLnJi 100644 --- a/files/gitlab-cookbooks/gitlab-ee/recipes/geo-logcursor.rb +++ b/files/gitlab-cookbooks/gitlab-ee/recipes/geo-logcursor.rb @@ -44,6 +44,7 @@ start_down node['gitlab']['geo-logcursor']['ha'] options({ user: account_helper.gitlab_user, + groupname: account_helper.gitlab_group, working_dir: working_dir, env_dir: env_directory, log_directory: log_directory diff --git a/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-geo-logcursor-run.erb b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-geo-logcursor-run.erb index 5b31e14c59fa24d0a89a0ae29518908668e23598_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvdGVtcGxhdGVzL2RlZmF1bHQvc3YtZ2VvLWxvZ2N1cnNvci1ydW4uZXJi..578aa3a670d4547c5fb5aa96877c75db34810526_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWItZWUvdGVtcGxhdGVzL2RlZmF1bHQvc3YtZ2VvLWxvZ2N1cnNvci1ydW4uZXJi 100644 --- a/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-geo-logcursor-run.erb +++ b/files/gitlab-cookbooks/gitlab-ee/templates/default/sv-geo-logcursor-run.erb @@ -7,7 +7,7 @@ cd <%= @options[:working_dir] %> exec chpst -P \ --U <%= @options[:user] %> \ --u <%= @options[:user] %> \ +-U <%= @options[:user] %>:<%= @options[:groupname] %> \ +-u <%= @options[:user] %>:<%= @options[:groupname] %> \ -e <%= @options[:env_dir] %> \ <%= File.join(@options[:working_dir], 'ee', 'bin', 'geo_log_cursor') %> diff --git a/spec/chef/cookbooks/consul/recipes/consul_spec.rb b/spec/chef/cookbooks/consul/recipes/consul_spec.rb index 5b31e14c59fa24d0a89a0ae29518908668e23598_c3BlYy9jaGVmL2Nvb2tib29rcy9jb25zdWwvcmVjaXBlcy9jb25zdWxfc3BlYy5yYg==..578aa3a670d4547c5fb5aa96877c75db34810526_c3BlYy9jaGVmL2Nvb2tib29rcy9jb25zdWwvcmVjaXBlcy9jb25zdWxfc3BlYy5yYg== 100644 --- a/spec/chef/cookbooks/consul/recipes/consul_spec.rb +++ b/spec/chef/cookbooks/consul/recipes/consul_spec.rb @@ -38,7 +38,7 @@ end describe 'consul::enable' do - it_behaves_like 'enabled runit service', 'consul', 'gitlab-consul', 'gitlab-consul', 'gitlab-consul', 'gitlab-consul' + it_behaves_like 'enabled runit service', 'consul', 'gitlab-consul', 'gitlab-consul', 'gitlab-consul', 'gitlab-consul', true it 'creates the consul system user and group' do expect(chef_run).to create_account('Consul user and group').with(username: 'gitlab-consul', groupname: 'gitlab-consul') @@ -149,7 +149,7 @@ } end - it_behaves_like 'enabled runit service', 'consul', 'foo', 'bar', 'foo', 'bar' + it_behaves_like 'enabled runit service', 'consul', 'foo', 'bar', 'foo', 'bar', true end context 'server enabled' do diff --git a/spec/chef/cookbooks/gitlab-ee/recipes/geo-logcursor_spec.rb b/spec/chef/cookbooks/gitlab-ee/recipes/geo-logcursor_spec.rb index 5b31e14c59fa24d0a89a0ae29518908668e23598_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWItZWUvcmVjaXBlcy9nZW8tbG9nY3Vyc29yX3NwZWMucmI=..578aa3a670d4547c5fb5aa96877c75db34810526_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWItZWUvcmVjaXBlcy9nZW8tbG9nY3Vyc29yX3NwZWMucmI= 100644 --- a/spec/chef/cookbooks/gitlab-ee/recipes/geo-logcursor_spec.rb +++ b/spec/chef/cookbooks/gitlab-ee/recipes/geo-logcursor_spec.rb @@ -28,11 +28,15 @@ end describe 'when enabled' do - before do - stub_gitlab_rb( - geo_logcursor: { - enable: true, - } - ) + context 'with default settings' do + before do + stub_gitlab_rb( + geo_logcursor: { + enable: true, + } + ) + end + + it_behaves_like 'enabled runit service', 'geo-logcursor', 'root', 'root' end @@ -37,5 +41,19 @@ end - it_behaves_like 'enabled runit service', 'geo-logcursor', 'root', 'root' + context 'with user specified settings' do + before do + stub_gitlab_rb( + geo_logcursor: { + enable: true, + }, + user: { + username: 'foo', + group: 'bar' + } + ) + end + + it_behaves_like 'enabled runit service', 'geo-logcursor', 'root', 'root', 'foo', 'bar' + end end end diff --git a/spec/chef/cookbooks/postgresql/recipes/postgresql_spec.rb b/spec/chef/cookbooks/postgresql/recipes/postgresql_spec.rb index 5b31e14c59fa24d0a89a0ae29518908668e23598_c3BlYy9jaGVmL2Nvb2tib29rcy9wb3N0Z3Jlc3FsL3JlY2lwZXMvcG9zdGdyZXNxbF9zcGVjLnJi..578aa3a670d4547c5fb5aa96877c75db34810526_c3BlYy9jaGVmL2Nvb2tib29rcy9wb3N0Z3Jlc3FsL3JlY2lwZXMvcG9zdGdyZXNxbF9zcGVjLnJi 100644 --- a/spec/chef/cookbooks/postgresql/recipes/postgresql_spec.rb +++ b/spec/chef/cookbooks/postgresql/recipes/postgresql_spec.rb @@ -39,7 +39,7 @@ end context 'with default settings' do - it_behaves_like 'enabled runit service', 'postgresql', 'root', 'root', 'gitlab-psql', 'gitlab-psql' + it_behaves_like 'enabled runit service', 'postgresql', 'root', 'root', 'gitlab-psql', 'gitlab-psql', true context 'when rendering postgresql.conf' do it 'correctly sets the shared_preload_libraries default setting' do @@ -337,7 +337,7 @@ }) end - it_behaves_like 'enabled runit service', 'postgresql', 'root', 'root', 'foo', 'bar' + it_behaves_like 'enabled runit service', 'postgresql', 'root', 'root', 'foo', 'bar', true context 'when rendering postgresql.conf' do it 'correctly sets the shared_preload_libraries setting' do diff --git a/spec/chef/support/shared_examples/runit_service.rb b/spec/chef/support/shared_examples/runit_service.rb index 5b31e14c59fa24d0a89a0ae29518908668e23598_c3BlYy9jaGVmL3N1cHBvcnQvc2hhcmVkX2V4YW1wbGVzL3J1bml0X3NlcnZpY2UucmI=..578aa3a670d4547c5fb5aa96877c75db34810526_c3BlYy9jaGVmL3N1cHBvcnQvc2hhcmVkX2V4YW1wbGVzL3J1bml0X3NlcnZpY2UucmI= 100644 --- a/spec/chef/support/shared_examples/runit_service.rb +++ b/spec/chef/support/shared_examples/runit_service.rb @@ -6,7 +6,7 @@ env_string end -RSpec.shared_examples 'enabled runit service' do |svc_name, owner, group, username = nil, groupname = nil| +RSpec.shared_examples 'enabled runit service' do |svc_name, owner, group, username = nil, groupname = nil, has_supervisor = nil| it 'creates directories' do expect(chef_run).to create_directory("/opt/gitlab/sv/#{svc_name}").with( owner: owner, @@ -78,6 +78,8 @@ context 'gitlab customization' do # These are specs related to changes we have made to the upstream runit cookbook before do + skip "Service does not have a supervisor" unless has_supervisor + %w(ok status control).each do |target| file_name = ::File.join('/opt/gitlab/service', svc_name, 'log', 'supervise', target) allow_any_instance_of(OmnibusHelper).to receive(:expected_owner?).with(file_name, username, groupname).and_return(false) @@ -86,15 +88,13 @@ it 'sets the supervise log files with correct permissions' do # For some services, we set the ownership on the sv log files to allow supervisor_owner to run commands - unless username.nil? - expect(chef_run).to create_directory("/opt/gitlab/service/#{svc_name}/log/supervise").with(mode: '0755') - %w(ok status control).each do |target| - file_name = ::File.join('/opt/gitlab/service', svc_name, 'log', 'supervise', target) - expect(chef_run).to touch_file(file_name).with( - owner: username, - group: groupname - ) - end + expect(chef_run).to create_directory("/opt/gitlab/service/#{svc_name}/log/supervise").with(mode: '0755') + %w(ok status control).each do |target| + file_name = ::File.join('/opt/gitlab/service', svc_name, 'log', 'supervise', target) + expect(chef_run).to touch_file(file_name).with( + owner: username, + group: groupname + ) end end end