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

Merge branch 'cablett-log-exit-as-json' into 'master'

Modify mail_room to crash with json

See merge request gitlab-org/omnibus-gitlab!3960
parents a45352e5 bd6d1537
No related branches found
No related tags found
No related merge requests found
---
title: Modify mail_room to output crash logs as json
merge_request: 3960
author:
type: feature
......@@ -220,6 +220,9 @@
####! The file name for internal `mail_room` JSON logfile
# gitlab_rails['incoming_email_log_file'] = "/var/log/gitlab/mailroom/mail_room_json.log"
####! The format of mail_room crash logs
# mailroom['exit_log_format'] = "plain"
### Job Artifacts
# gitlab_rails['artifacts_enabled'] = true
# gitlab_rails['artifacts_path'] = "/var/opt/gitlab/gitlab-rails/shared/artifacts"
......
......@@ -532,6 +532,7 @@
default['gitlab']['mailroom']['enable'] = false
default['gitlab']['mailroom']['ha'] = false
default['gitlab']['mailroom']['log_directory'] = "/var/log/gitlab/mailroom"
default['gitlab']['mailroom']['exit_log_format'] = "plain" # If mail_room crashes, the structure of the final exception message
####
# GitLab Pages Daemon
......
......@@ -20,6 +20,7 @@
GITLAB_RAILS_SOURCE_DIR = '/opt/gitlab/embedded/service/gitlab-rails'.freeze
exit_log_format = node['gitlab']['mailroom']['exit_log_format']
mailroom_log_dir = node['gitlab']['mailroom']['log_directory']
mail_room_config = File.join(GITLAB_RAILS_SOURCE_DIR, 'config', 'mail_room.yml')
......@@ -35,7 +36,8 @@
user: user,
groupname: group,
log_directory: mailroom_log_dir,
mail_room_config: mail_room_config
mail_room_config: mail_room_config,
exit_log_format: exit_log_format
}.merge(params))
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['mailroom'].to_hash)
end
......
......@@ -4,10 +4,7 @@
exec 2>&1
# This is useful to see in the logs; mail_room is very quiet
echo 'Runit: starting mail_room'
exec chpst -e /opt/gitlab/etc/gitlab-rails/env -P \
-U <%= @options[:user] %>:<%= @options[:groupname] %> \
-u <%= @options[:user] %>:<%= @options[:groupname] %> \
/opt/gitlab/embedded/bin/bundle exec mail_room \
......@@ -10,5 +7,6 @@
exec chpst -e /opt/gitlab/etc/gitlab-rails/env -P \
-U <%= @options[:user] %>:<%= @options[:groupname] %> \
-u <%= @options[:user] %>:<%= @options[:groupname] %> \
/opt/gitlab/embedded/bin/bundle exec mail_room \
-c <%= @options[:mail_room_config] %>
-c <%= @options[:mail_room_config] %> \
--log-exit-as <%= @options[:exit_log_format] %>
......@@ -38,6 +38,10 @@
end
it_behaves_like 'enabled runit service', 'mailroom', 'root', 'root', 'git', 'git'
it 'uses --log-exit-as plain' do
expect(chef_run).to render_file("/opt/gitlab/sv/mailroom/run").with_content(/\-\-log\-exit\-as plain/)
end
end
context 'custom values' do
......@@ -56,4 +60,23 @@
it_behaves_like 'enabled runit service', 'mailroom', 'root', 'root', 'foo', 'bar'
end
end
context 'with specified command line values' do
before do
stub_gitlab_rb(
gitlab_rails: {
incoming_email_enabled: true
},
mailroom: {
exit_log_format: "json"
}
)
end
it 'correctly passes the --log-exit-as ' do
expect(chef_run).to render_file("/opt/gitlab/sv/mailroom/run").with_content(/\-\-log\-exit\-as json/)
end
it_behaves_like 'enabled runit service', 'mailroom', 'root', 'root', 'git', 'git'
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